| The Gaudi Framework v27r1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

DataObject.cpp
Go to the documentation of this file.
1 // Experiment specific include files
2 #include "GaudiKernel/StreamBuffer.h"
3 #include "GaudiKernel/LinkManager.h"
4 #include "GaudiKernel/DataObject.h"
5 #include "GaudiKernel/IInspector.h"
6 #include "GaudiKernel/IRegistry.h"
7 #include <vector>
8 #include <memory>
9
10 static std::string _sDataObjectCppNotRegistered("NotRegistered");
11
13 DataObject::DataObject()
14 : m_pLinkMgr{LinkManager::newInstance()}
15 {
16 }
17
19 DataObject::DataObject(const DataObject& rhs)
20 : m_version{rhs.m_version},
21 m_pLinkMgr{LinkManager::newInstance()}
22 {
23 }
24
26 DataObject& DataObject::operator=(const DataObject& rhs) {
27 m_version = rhs.m_version;
28 m_pLinkMgr.reset(LinkManager::newInstance());
29 return *this;
30 }
31
33 DataObject::DataObject(DataObject&& rhs)
34 : m_version{std::move(rhs.m_version)},
35 m_pLinkMgr{std::move(rhs.m_pLinkMgr)}
36 {
37 }
38
40 DataObject& DataObject::operator=(DataObject&& rhs) {
41 m_version = std::move(rhs.m_version);
42 m_pLinkMgr = std::move(rhs.m_pLinkMgr);
43 return *this;
44 }
45
47 DataObject::~DataObject() {
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
73 const CLID& DataObject::classID() {
74 return CLID_DataObject;
75 }
76
78 const std::string& DataObject::name() const {
79 return m_pRegistry ? m_pRegistry->name() : _sDataObjectCppNotRegistered;
80 }
81
83 StatusCode DataObject::update() {
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() {
91 static std::unique_ptr<std::vector<DataObject**>> s_current{new std::vector<DataObject**>()};
92 return *s_current;
93 }
94
95 DataObject* Gaudi::getCurrentDataObject() {
96 return *s_currObj;
97 }
98
99 void Gaudi::pushCurrentDataObject(DataObject** pobjAddr) {
100 static std::vector<DataObject**>& c = objectStack();
101 c.push_back(pobjAddr);
102 s_currObj = pobjAddr ? pobjAddr : &s_objPtr;
103 }
104
105 void Gaudi::popCurrentDataObject() {
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 }
DataObject::update
virtual StatusCode update()
Provide empty placeholder for internal object reconfiguration callback.
Definition: DataObject.cpp:83
std::vector::empty
T empty(T...args)
DataObject::classID
static const CLID & classID()
Retrieve reference to class definition structure (static access)
Definition: DataObject.cpp:73
LinkManager.h
Gaudi::popCurrentDataObject
GAUDI_API void popCurrentDataObject()
Definition: RootIOHandler.cpp:38
Gaudi::getCurrentDataObject
GAUDI_API DataObject * getCurrentDataObject()
gaudirun.c
tuple c
Definition: gaudirun.py:391
IRegistry::name
virtual const name_type & name() const =0
Name of the directory (or key)
StreamBuffer.h
std::string
STL class.
DataObject::m_version
unsigned char m_version
Version number.
Definition: DataObject.h:35
std::vector::push_back
T push_back(T...args)
DataObject::addRef
virtual unsigned long addRef()
Add reference to object.
Definition: DataObject.cpp:63
DataObject::clID
virtual const CLID & clID() const
Retrieve reference to class definition structure.
Definition: DataObject.cpp:68
StatusCode::SUCCESS
Definition: StatusCode.h:30
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
std::vector::pop_back
T pop_back(T...args)
LinkManager::newInstance
static LinkManager * newInstance()
Static instantiation.
Definition: LinkManager.cpp:28
IRegistry.h
std::unique_ptr::reset
T reset(T...args)
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
Gaudi::pushCurrentDataObject
GAUDI_API void pushCurrentDataObject(DataObject **pobjAddr)
Definition: RootIOHandler.cpp:34
std::move
T move(T...args)
DataObject::DataObject
DataObject()
Standard Constructor.
Definition: DataObject.cpp:13
DataObject::release
virtual unsigned long release()
release reference to object
Definition: DataObject.cpp:56
DataObject::m_pLinkMgr
std::unique_ptr< LinkManager > m_pLinkMgr
Store of symbolic links.
Definition: DataObject.h:39
std::vector
STL class.
std::unique_ptr
STL class.
DataObject::operator=
DataObject & operator=(const DataObject &rhs)
Assignment Operator.
Definition: DataObject.cpp:26
std::vector::back
T back(T...args)
DataObject::name
const std::string & name() const
Retreive DataObject name. It is the name when registered in the store.
Definition: DataObject.cpp:78
DataObject::~DataObject
virtual ~DataObject()
Standard Destructor.
Definition: DataObject.cpp:47
IInspector.h
DataObject::m_pRegistry
IRegistry * m_pRegistry
Pointer to the Registry Object.
Definition: DataObject.h:37
s_current
thread_local Partition * s_current(0)
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
DataObject::m_refCount
unsigned long m_refCount
Reference count.
Definition: DataObject.h:33
DataObject.h