The Gaudi Framework  v30r3 (a5ef0a68)
DataObject.cpp
Go to the documentation of this file.
1 // Experiment specific include files
7 #include <memory>
8 #include <vector>
9 
10 static std::string _sDataObjectCppNotRegistered( "NotRegistered" );
11 
14 
17 
20 {
21  m_version = rhs.m_version;
23  return *this;
24 }
25 
28  : m_version{std::move( rhs.m_version )}, m_pLinkMgr{std::move( rhs.m_pLinkMgr )}
29 {
30 }
31 
34 {
35  m_version = std::move( rhs.m_version );
36  m_pLinkMgr = std::move( rhs.m_pLinkMgr );
37  return *this;
38 }
39 
42 {
43  // Issue a warning if the object is being deleted and the reference
44  // count is non-zero.
45  if ( m_refCount > 0 ) {
46  // Insert warning here
47  }
48 }
49 
51 unsigned long DataObject::release()
52 {
53  unsigned long cnt = --m_refCount;
54  if ( 0 == cnt ) delete this;
55  return cnt;
56 }
57 
59 unsigned long DataObject::addRef() { return ++m_refCount; }
60 
62 const CLID& DataObject::clID() const { return CLID_DataObject; }
63 
65 const CLID& DataObject::classID() { return CLID_DataObject; }
66 
68 const std::string& DataObject::name() const { return m_pRegistry ? m_pRegistry->name() : _sDataObjectCppNotRegistered; }
69 
72 
73 static DataObject* s_objPtr = nullptr;
74 static DataObject** s_currObj = &s_objPtr;
75 
76 static std::vector<DataObject**>& objectStack()
77 {
79  return *s_current;
80 }
81 
82 DataObject* Gaudi::getCurrentDataObject() { return *s_currObj; }
83 
85 {
86  static std::vector<DataObject**>& c = objectStack();
87  c.push_back( pobjAddr );
88  s_currObj = pobjAddr ? pobjAddr : &s_objPtr;
89 }
90 
92 {
93  static std::vector<DataObject**>& c = objectStack();
94  if ( !c.empty() ) {
95  s_currObj = c.back();
96  c.pop_back();
97  } else {
98  s_currObj = &s_objPtr;
99  }
100 }
virtual StatusCode update()
Provide empty placeholder for internal object reconfiguration callback.
Definition: DataObject.cpp:71
T empty(T...args)
static const CLID & classID()
Retrieve reference to class definition structure (static access)
Definition: DataObject.cpp:65
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:36
T push_back(T...args)
virtual unsigned long addRef()
Add reference to object.
Definition: DataObject.cpp:59
virtual const CLID & clID() const
Retrieve reference to class definition structure.
Definition: DataObject.cpp:62
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
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)
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
DataObject()
Standard Constructor.
Definition: DataObject.cpp:13
virtual unsigned long release()
release reference to object
Definition: DataObject.cpp:51
std::unique_ptr< LinkManager > m_pLinkMgr
Store of symbolic links.
Definition: DataObject.h:40
STL class.
STL class.
DataObject & operator=(const DataObject &rhs)
Assignment Operator.
Definition: DataObject.cpp:19
T back(T...args)
const std::string & name() const
Retreive DataObject name. It is the name when registered in the store.
Definition: DataObject.cpp:68
virtual ~DataObject()
Standard Destructor.
Definition: DataObject.cpp:41
IRegistry * m_pRegistry
Pointer to the Registry Object.
Definition: DataObject.h:38
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:34