SmartDataObjectPtr.cpp
Go to the documentation of this file.
1 // ====================================================================
2 // SmartDataObjectPtr.cpp
3 // --------------------------------------------------------------------
4 //
5 // Package :
6 //
7 // Author : Markus Frank
8 //
9 // ====================================================================
10 #define GAUDIKERNEL_SMARTDATAOBJECTPTR_CPP 1
11 
12 // Framework include files
13 #include "GaudiKernel/DataObject.h"
14 #include "GaudiKernel/IDataProviderSvc.h"
15 #include "GaudiKernel/SmartDataObjectPtr.h"
16 
19 }
20 
23 }
24 
27  m_path = copy.m_path;
28  m_pRegistry = copy.m_pRegistry;
30  return *this;
31 }
32 
34 StatusCode SmartDataObjectPtr::retrieve(IRegistry* pRegistry, const std::string& path, DataObject*& refpObject) {
36  if ( 0 != m_dataProvider && 0 != pRegistry ) {
37  status = m_dataProvider->retrieveObject(pRegistry, path, refpObject);
38  }
39  return status;
40 }
41 
43 StatusCode SmartDataObjectPtr::retrieve(const std::string& fullPath, DataObject*& refpObject) {
45  if ( 0 != m_dataProvider ) {
46  status = m_dataProvider->retrieveObject(fullPath, refpObject);
47  }
48  return status;
49 }
50 
52 StatusCode SmartDataObjectPtr::find(IRegistry* pDirectory, const std::string& path, DataObject*& refpObject) {
54  if ( 0 != m_dataProvider && 0 != pDirectory ) {
55  status = m_dataProvider->findObject(pDirectory, path, refpObject);
56  }
57  return status;
58 }
59 
61 StatusCode SmartDataObjectPtr::find(const std::string& fullPath, DataObject*& refpObject) {
63  if ( 0 != m_dataProvider ) {
64  status = m_dataProvider->findObject(fullPath, refpObject);
65  }
66  return status;
67 }
68 
69 
73  if ( 0 != m_dataProvider && 0 != pRegistry ) {
74  status = m_dataProvider->updateObject(pRegistry);
75  }
76  return status;
77 }
78 
80 StatusCode SmartDataObjectPtr::update(const std::string& fullPath) {
82  if ( 0 != m_dataProvider ) {
83  status = m_dataProvider->updateObject(fullPath);
84  }
85  return status;
86 }
87 
94  DataObject* pObj = 0;
96  if ( m_status.isSuccess() ) {
97  m_pRegistry = pObj->registry();
98  m_path = "";
99  }
100  return pObj;
101 }
102 
109  DataObject* pObj = 0;
110  m_status = (0==m_pRegistry) ? find(m_path,pObj) : find(m_pRegistry,m_path,pObj);
111  if ( m_status.isSuccess() ) {
112  m_pRegistry = pObj->registry();
113  m_path = "";
114  }
115  return pObj;
116 }
117 
124  DataObject* pObj = accessData(); // Have to load AND update if not present.
125  if ( m_status.isSuccess() ) {
127  if ( !m_status.isSuccess() ) pObj = 0;
128  }
129  return pObj;
130 }
131 
145  if ( 0 != object_1.accessData() ) { // Test existence of the first object
146  if ( 0 != object_2.accessData() ) { // Test existence of the second object
147  return true; // Fine: Both objects exist
148  }
149  }
150  return false; // Tough luck: One is missing.
151 }
152 
170  if ( 0 != object_1.accessData() ) { // Test existence of the first object
171  return true;
172  }
173  if ( 0 != object_2.accessData() ) { // Test existence of the second object
174  return true;
175  }
176  return false; // Tough luck: Both are missing.
177 }
178 
static DataObject * find(SmartDataObjectPtr *ptr)
Static Object find method.
bool operator||(SmartDataObjectPtr &object_1, SmartDataObjectPtr &object_2)
Helper to test Smart data objects efficiently This construct allows statements like: SmartEvtDataPtr<...
DataObject * retrieveObject()
Object retrieve method.
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
DataObject *(*)(SmartDataObjectPtr *ptr) AccessFunction
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:74
static DataObject * update(SmartDataObjectPtr *ptr)
Static Object update method.
static DataObject * retrieve(SmartDataObjectPtr *ptr)
Static Object retrieval method.
bool operator&&(SmartDataObjectPtr &object_1, SmartDataObjectPtr &object_2)
Helper to test Smart data objects efficiently This construct allows statements like: SmartEvtDataPtr<...
virtual StatusCode findObject(IRegistry *pDirectory, const std::string &path, DataObject *&pObject)=0
Find object identified by its directory entry.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
virtual StatusCode updateObject(IRegistry *pDirectory)=0
Update object identified by its directory entry.
std::string m_path
Path to object.
DataObject * accessData()
Static Object retrieval method: must call specific function.
const std::string & path() const
Path name.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
virtual SmartDataObjectPtr & operator=(const SmartDataObjectPtr &)
Assignment operator.
StatusCode m_status
Keep track of the last error.
A small class used to access easily (and efficiently) data items residing in data stores...
DataObject * findObject()
Object find method.
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
IRegistry * m_pRegistry
Pointer to the data registry containing the object.
DataObject * updateObject()
Object update method.
virtual StatusCode retrieveObject(IRegistry *pDirectory, const std::string &path, DataObject *&pObject)=0
Retrieve object identified by its directory entry.
IDataProviderSvc * m_dataProvider
Pointer to contained object.