All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
DataObject.cpp
Go to the documentation of this file.
1 // Experiment specific include files
7 #include <vector>
8 #include <memory>
9 
10 static std::string _sDataObjectCppNotRegistered("NotRegistered");
11 
14  : m_pLinkMgr{LinkManager::newInstance()}
15 {
16 }
17 
20  : m_version{rhs.m_version},
22 {
23 }
24 
27  m_version = rhs.m_version;
29  return *this;
30 }
31 
34  : m_version{std::move(rhs.m_version)},
35  m_pLinkMgr{std::move(rhs.m_pLinkMgr)}
36 {
37 }
38 
41  m_version = std::move(rhs.m_version);
42  m_pLinkMgr = std::move(rhs.m_pLinkMgr);
43  return *this;
44 }
45 
48  // Issue a warning if the object is being deleted and the reference
49  // count is non-zero.
50  if ( m_refCount > 0 ) {
51  // Insert warning here
52  }
53 }
54 
56 unsigned long DataObject::release() {
57  unsigned long cnt = --m_refCount;
58  if ( 0 == cnt ) delete this;
59  return cnt;
60 }
61 
63 unsigned long DataObject::addRef() {
64  return ++m_refCount;
65 }
66 
68 const CLID& DataObject::clID() const {
69  return CLID_DataObject;
70 }
71 
74  return CLID_DataObject;
75 }
76 
78 const std::string& DataObject::name() const {
79  return m_pRegistry ? m_pRegistry->name() : _sDataObjectCppNotRegistered;
80 }
81 
84  return StatusCode::SUCCESS;
85 }
86 
87 static DataObject* s_objPtr = nullptr;
88 static DataObject** s_currObj = &s_objPtr;
89 
90 static std::vector<DataObject**>& objectStack() {
92  return *s_current;
93 }
94 
96  return *s_currObj;
97 }
98 
100  static std::vector<DataObject**>& c = objectStack();
101  c.push_back(pobjAddr);
102  s_currObj = pobjAddr ? pobjAddr : &s_objPtr;
103 }
104 
106  static std::vector<DataObject**>& c = objectStack();
107  if (!c.empty()) {
108  s_currObj = c.back();
109  c.pop_back();
110  } else {
111  s_currObj = &s_objPtr;
112  }
113 }
virtual StatusCode update()
Provide empty placeholder for internal object reconfiguration callback.
Definition: DataObject.cpp:83
T empty(T...args)
static const CLID & classID()
Retrieve reference to class definition structure (static access)
Definition: DataObject.cpp:73
GAUDI_API void popCurrentDataObject()
GAUDI_API DataObject * getCurrentDataObject()
virtual const name_type & name() const =0
Name of the directory (or key)
STL class.
unsigned char m_version
Version number.
Definition: DataObject.h:35
T push_back(T...args)
virtual unsigned long addRef()
Add reference to object.
Definition: DataObject.cpp:63
virtual const CLID & clID() const
Retrieve reference to class definition structure.
Definition: DataObject.cpp:68
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
T pop_back(T...args)
T reset(T...args)
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
GAUDI_API void pushCurrentDataObject(DataObject **pobjAddr)
T move(T...args)
DataObject()
Standard Constructor.
Definition: DataObject.cpp:13
virtual unsigned long release()
release reference to object
Definition: DataObject.cpp:56
std::unique_ptr< LinkManager > m_pLinkMgr
Store of symbolic links.
Definition: DataObject.h:39
STL class.
STL class.
DataObject & operator=(const DataObject &rhs)
Assignment Operator.
Definition: DataObject.cpp:26
T back(T...args)
const std::string & name() const
Retreive DataObject name. It is the name when registered in the store.
Definition: DataObject.cpp:78
virtual ~DataObject()
Standard Destructor.
Definition: DataObject.cpp:47
IRegistry * m_pRegistry
Pointer to the Registry Object.
Definition: DataObject.h:37
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
unsigned long m_refCount
Reference count.
Definition: DataObject.h:33