All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DataObject.cpp
Go to the documentation of this file.
1 // $Id: DataObject.cpp,v 1.11 2008/11/13 15:30:27 marcocle Exp $
2 
3 // Experiment specific include files
9 #include <vector>
10 #include <memory>
11 
12 static std::string _sDataObjectCppNotRegistered("NotRegistered");
13 
16  : m_refCount(0),
17  m_version(0),
18  m_pRegistry(0)
19 {
21 }
22 
25  : m_refCount(0),
26  m_version(0),
27  m_pRegistry(0)
28 {
30 }
31 
34  // Issue a warning if the object is being deleted and the reference
35  // count is non-zero.
36  if ( m_refCount > 0 ) {
37  // Insert warning here
38  }
39  if ( m_pLinkMgr ) delete m_pLinkMgr;
40  m_pLinkMgr = 0;
41 }
42 
44 unsigned long DataObject::release() {
45  unsigned long cnt = --m_refCount;
46  if ( 0 == m_refCount ) {
47  delete this;
48  }
49  return cnt;
50 }
51 
53 unsigned long DataObject::addRef() {
54  return ++m_refCount;
55 }
56 
58 const CLID& DataObject::clID() const {
59  return CLID_DataObject;
60 }
61 
64  return CLID_DataObject;
65 }
66 
68 const std::string& DataObject::name() const {
69  if( m_pRegistry != 0) {
70  return m_pRegistry->name();
71  }
72  else {
73  return _sDataObjectCppNotRegistered;
74  }
75 }
76 
79  return StatusCode::SUCCESS;
80 }
81 
82 static DataObject* s_objPtr = 0;
83 static DataObject** s_currObj = &s_objPtr;
84 
85 static std::vector<DataObject**>& objectStack() {
86  static std::auto_ptr<std::vector<DataObject**> > s_current;
87  if ( 0 == s_current.get() ) {
88  s_current = std::auto_ptr<std::vector<DataObject**> >(new std::vector<DataObject**>());
89  }
90  return *(s_current.get());
91 }
92 
94  return *s_currObj;
95 }
96 
98  static std::vector<DataObject**>& c = objectStack();
99  c.push_back(pobjAddr);
100  s_currObj = pobjAddr ? pobjAddr : &s_objPtr;
101 }
102 
103 
105  static std::vector<DataObject**>& c = objectStack();
106  switch(c.size()) {
107  case 0:
108  s_currObj = c.back();
109  c.pop_back();
110  break;
111  default:
112  s_currObj = &s_objPtr;
113  break;
114  }
115 }
virtual StatusCode update()
Provide empty placeholder for internal object reconfiguration callback.
Definition: DataObject.cpp:78
static const CLID & classID()
Retrieve reference to class definition structure (static access)
Definition: DataObject.cpp:63
GAUDI_API void popCurrentDataObject()
GAUDI_API DataObject * getCurrentDataObject()
tuple c
Definition: gaudirun.py:341
virtual const name_type & name() const =0
Name of the directory (or key)
LinkManager * m_pLinkMgr
Store of symbolic links.
Definition: DataObject.h:40
virtual unsigned long addRef()
Add reference to object.
Definition: DataObject.cpp:53
virtual const CLID & clID() const
Retrieve reference to class definition structure.
Definition: DataObject.cpp:58
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
unsigned int CLID
Class ID definition.
Definition: ClassID.h:9
GAUDI_API void pushCurrentDataObject(DataObject **pobjAddr)
DataObject()
Standard Constructor.
Definition: DataObject.cpp:15
virtual unsigned long release()
release reference to object
Definition: DataObject.cpp:44
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:33
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:31
unsigned long m_refCount
Reference count.
Definition: DataObject.h:34