| The Gaudi Framework v29r1 (5cd95fa2)

- 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/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 {
21 m_version = rhs.m_version;
22 m_pLinkMgr.reset( LinkManager::newInstance() );
23 return *this;
24 }
25
27 DataObject::DataObject( DataObject&& rhs )
28 : m_version{std::move( rhs.m_version )}, m_pLinkMgr{std::move( rhs.m_pLinkMgr )}
29 {
30 }
31
33 DataObject& DataObject::operator=( DataObject&& rhs )
34 {
35 m_version = std::move( rhs.m_version );
36 m_pLinkMgr = std::move( rhs.m_pLinkMgr );
37 return *this;
38 }
39
41 DataObject::~DataObject()
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
71 StatusCode DataObject::update() { return StatusCode::SUCCESS; }
72
73 static DataObject* s_objPtr = nullptr;
74 static DataObject** s_currObj = &s_objPtr;
75
76 static std::vector<DataObject**>& objectStack()
77 {
78 static std::unique_ptr<std::vector<DataObject**>> s_current{new std::vector<DataObject**>()};
79 return *s_current;
80 }
81
82 DataObject* Gaudi::getCurrentDataObject() { return *s_currObj; }
83
84 void Gaudi::pushCurrentDataObject( DataObject** pobjAddr )
85 {
86 static std::vector<DataObject**>& c = objectStack();
87 c.push_back( pobjAddr );
88 s_currObj = pobjAddr ? pobjAddr : &s_objPtr;
89 }
90
91 void Gaudi::popCurrentDataObject()
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 }
DataObject::update
virtual StatusCode update()
Provide empty placeholder for internal object reconfiguration callback.
Definition: DataObject.cpp:71
StatusCode::SUCCESS
Definition: StatusCode.h:31
std::vector::empty
T empty(T...args)
gaudirun.c
c
Definition: gaudirun.py:407
DataObject::classID
static const CLID & classID()
Retrieve reference to class definition structure (static access)
Definition: DataObject.cpp:65
LinkManager.h
Gaudi::popCurrentDataObject
GAUDI_API void popCurrentDataObject()
Definition: RootIOHandler.cpp:41
Gaudi::getCurrentDataObject
GAUDI_API DataObject * getCurrentDataObject()
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:59
DataObject::clID
virtual const CLID & clID() const
Retrieve reference to class definition structure.
Definition: DataObject.cpp:62
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
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:36
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:51
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:19
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:68
DataObject::~DataObject
virtual ~DataObject()
Standard Destructor.
Definition: DataObject.cpp:41
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:29
DataObject::m_refCount
unsigned long m_refCount
Reference count.
Definition: DataObject.h:33
DataObject.h