Mantid
Loading...
Searching...
No Matches
DataItem.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2011 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
9//-----------------------------------------------------------------------------
10// Includes
11//-----------------------------------------------------------------------------
12#include "MantidKernel/DllConfig.h"
13#ifndef Q_MOC_RUN
14#include <memory>
15#endif
16#include <string>
17
18// Poco forward declarations
19namespace Poco {
20class RWLock;
21}
22
23// Forward declaration to allow Friend class.
24namespace Mantid {
25namespace API {
26class Algorithm;
27}
28} // namespace Mantid
29
30namespace Mantid {
31namespace Kernel {
32
39class MANTID_KERNEL_DLL DataItem {
40public:
41 DataItem();
42 DataItem(const DataItem &other);
43 virtual ~DataItem();
44
48 virtual const std::string id() const = 0;
50 virtual const std::string &getName() const = 0;
52 virtual bool threadSafe() const = 0;
54 virtual const std::string toString() const = 0;
56
59 void readLock();
60 void unlock();
61
62protected:
63 Poco::RWLock *getLock() const;
64
65private:
68 std::unique_ptr<Poco::RWLock> m_lock;
69
71 friend class ReadLock;
73 friend class WriteLock;
77 /* WARNING: Do not add other friend classes unless you really know what
78 * you are doing. Write locks are INTENTIONALLY restricted to
79 * only the Algorithm base class.
80 */
81};
82
84using DataItem_sptr = std::shared_ptr<DataItem>;
86using DataItem_const_sptr = std::shared_ptr<const DataItem>;
87
88} // namespace Kernel
89} // namespace Mantid
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:85
This class forms the base class of any item that wishes to be stored in the analysis data service.
Definition: DataItem.h:39
virtual const std::string & getName() const =0
The name of the object.
virtual ~DataItem()
Destructor.
virtual const std::string toString() const =0
Serializes the object to a string.
virtual const std::string id() const =0
A string ID for the class.
virtual bool threadSafe() const =0
Can this object be accessed from multiple threads safely.
std::unique_ptr< Poco::RWLock > m_lock
Multiple-reader/single-writer lock to restrict multithreaded access to the data item.
Definition: DataItem.h:68
Scoped, read-only lock for thread-safe access to DataItems.
Definition: ReadLock.h:37
Scoped write-lock for thread-safe access to DataItems.
Definition: WriteLock.h:41
std::shared_ptr< const DataItem > DataItem_const_sptr
Shared pointer to a const DataItem.
Definition: DataItem.h:86
std::shared_ptr< DataItem > DataItem_sptr
Shared pointer to a DataItem.
Definition: DataItem.h:84
Helper class which provides the Collimation Length for SANS instruments.
Definition: Algorithm.h:30