| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

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

- File List
- File Members

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
4 #include "GaudiKernel/StreamBuffer.h"
5 #include "GaudiKernel/LinkManager.h"
6 #include "GaudiKernel/DataObject.h"
7 #include "GaudiKernel/IInspector.h"
8 #include "GaudiKernel/IRegistry.h"
9 #include <vector>
10 #include <memory>
11
12 static std::string _sDataObjectCppNotRegistered("NotRegistered");
13
15 DataObject::DataObject()
16 : m_refCount(0),
17 m_version(0),
18 m_pRegistry(0)
19 {
20 m_pLinkMgr = LinkManager::newInstance();
21 }
22
24 DataObject::DataObject(const DataObject&)
25 : m_refCount(0),
26 m_version(0),
27 m_pRegistry(0)
28 {
29 m_pLinkMgr = LinkManager::newInstance();
30 }
31
33 DataObject::~DataObject() {
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
63 const CLID& DataObject::classID() {
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
78 StatusCode DataObject::update() {
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
93 DataObject* Gaudi::getCurrentDataObject() {
94 return *s_currObj;
95 }
96
97 void Gaudi::pushCurrentDataObject(DataObject** pobjAddr) {
98 static std::vector<DataObject**>& c = objectStack();
99 c.push_back(pobjAddr);
100 s_currObj = pobjAddr ? pobjAddr : &s_objPtr;
101 }
102
103
104 void Gaudi::popCurrentDataObject() {
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 }