| The Gaudi Framework v32r1 (f65d50dc)

DataObject.cpp
Go to the documentation of this file.
1 // Experiment specific include files
2 #include "GaudiKernel/DataObject.h"
3 #include "GaudiKernel/IInspector.h"
4 #include "GaudiKernel/IRegistry.h"
5 #include "GaudiKernel/LinkManager.h"
6 #include "GaudiKernel/StreamBuffer.h"
7 #include <memory>
8 #include <vector>
9
10 static std::string _sDataObjectCppNotRegistered( "NotRegistered" );
11
13 DataObject::DataObject() : m_pLinkMgr{LinkManager::newInstance()} {}
14
16 DataObject::DataObject( const DataObject& rhs ) : m_version{rhs.m_version}, m_pLinkMgr{LinkManager::newInstance()} {}
17
19 DataObject& DataObject::operator=( const DataObject& rhs ) {
20 m_version = rhs.m_version;
21 m_pLinkMgr.reset( LinkManager::newInstance() );
22 return *this;
23 }
24
26 DataObject::DataObject( DataObject&& rhs )
27 : m_version{std::move( rhs.m_version )}, m_pLinkMgr{std::move( rhs.m_pLinkMgr )} {}
28
30 DataObject& DataObject::operator=( DataObject&& rhs ) {
31 m_version = std::move( rhs.m_version );
32 m_pLinkMgr = std::move( rhs.m_pLinkMgr );
33 return *this;
34 }
35
37 DataObject::~DataObject() {
38 // Issue a warning if the object is being deleted and the reference
39 // count is non-zero.
40 if ( m_refCount > 0 ) {
41 // Insert warning here
42 }
43 }
44
46 unsigned long DataObject::release() {
47 unsigned long cnt = --m_refCount;
48 if ( 0 == cnt ) delete this;
49 return cnt;
50 }
51
53 unsigned long DataObject::addRef() { return ++m_refCount; }
54
56 const CLID& DataObject::clID() const { return CLID_DataObject; }
57
59 const CLID& DataObject::classID() { return CLID_DataObject; }
60
62 const std::string& DataObject::name() const { return m_pRegistry ? m_pRegistry->name() : _sDataObjectCppNotRegistered; }
63
65 StatusCode DataObject::update() { return StatusCode::SUCCESS; }
66
67 static DataObject* s_objPtr = nullptr;
68 static DataObject** s_currObj = &s_objPtr;
69
70 static std::vector<DataObject**>& objectStack() {
71 static std::unique_ptr<std::vector<DataObject**>> s_current{new std::vector<DataObject**>()};
72 return *s_current;
73 }
74
75 DataObject* Gaudi::getCurrentDataObject() { return *s_currObj; }
76
77 void Gaudi::pushCurrentDataObject( DataObject** pobjAddr ) {
78 static std::vector<DataObject**>& c = objectStack();
79 c.push_back( pobjAddr );
80 s_currObj = pobjAddr ? pobjAddr : &s_objPtr;
81 }
82
83 void Gaudi::popCurrentDataObject() {
84 static std::vector<DataObject**>& c = objectStack();
85 if ( !c.empty() ) {
86 s_currObj = c.back();
87 c.pop_back();
88 } else {
89 s_currObj = &s_objPtr;
90 }
91 }
DataObject::update
virtual StatusCode update()
Provide empty placeholder for internal object reconfiguration callback.
Definition: DataObject.cpp:65
gaudirun.c
c
Definition: gaudirun.py:487
DataObject::classID
static const CLID & classID()
Retrieve reference to class definition structure (static access)
Definition: DataObject.cpp:59
LinkManager.h
Gaudi::popCurrentDataObject
GAUDI_API void popCurrentDataObject()
Definition: RootIOHandler.cpp:38
Gaudi::getCurrentDataObject
GAUDI_API DataObject * getCurrentDataObject()
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
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
DataObject::addRef
virtual unsigned long addRef()
Add reference to object.
Definition: DataObject.cpp:53
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
LinkManager::newInstance
static LinkManager * newInstance()
Static instantiation.
Definition: LinkManager.cpp:26
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::name
const std::string & name() const
Retreive DataObject name. It is the name when registered in the store.
Definition: DataObject.cpp:62
DataObject::release
virtual unsigned long release()
release reference to object
Definition: DataObject.cpp:46
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::clID
virtual const CLID & clID() const
Retrieve reference to class definition structure.
Definition: DataObject.cpp:56
DataObject::operator=
DataObject & operator=(const DataObject &rhs)
Assignment Operator.
Definition: DataObject.cpp:19
DataObject::~DataObject
virtual ~DataObject()
Standard Destructor.
Definition: DataObject.cpp:37
IInspector.h
DataObject::m_pRegistry
IRegistry * m_pRegistry
Pointer to the Registry Object.
Definition: DataObject.h:37
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