All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SmartDataObjectPtr.cpp
Go to the documentation of this file.
1 // $Header: /tmp/svngaudi/tmp.jEpFh25751/Gaudi/GaudiKernel/src/Lib/SmartDataObjectPtr.cpp,v 1.5 2003/06/25 15:59:40 mato Exp $
2 // ====================================================================
3 // SmartDataObjectPtr.cpp
4 // --------------------------------------------------------------------
5 //
6 // Package :
7 //
8 // Author : Markus Frank
9 //
10 // ====================================================================
11 #define GAUDIKERNEL_SMARTDATAOBJECTPTR_CPP 1
12 
13 // Framework include files
14 #include "GaudiKernel/DataObject.h"
17 
20 }
21 
24 }
25 
28  m_path = copy.m_path;
29  m_pRegistry = copy.m_pRegistry;
31  return *this;
32 }
33 
35 StatusCode SmartDataObjectPtr::retrieve(IRegistry* pRegistry, const std::string& path, DataObject*& refpObject) {
37  if ( 0 != m_dataProvider && 0 != pRegistry ) {
38  status = m_dataProvider->retrieveObject(pRegistry, path, refpObject);
39  }
40  return status;
41 }
42 
44 StatusCode SmartDataObjectPtr::retrieve(const std::string& fullPath, DataObject*& refpObject) {
46  if ( 0 != m_dataProvider ) {
47  status = m_dataProvider->retrieveObject(fullPath, refpObject);
48  }
49  return status;
50 }
51 
53 StatusCode SmartDataObjectPtr::find(IRegistry* pDirectory, const std::string& path, DataObject*& refpObject) {
55  if ( 0 != m_dataProvider && 0 != pDirectory ) {
56  status = m_dataProvider->findObject(pDirectory, path, refpObject);
57  }
58  return status;
59 }
60 
62 StatusCode SmartDataObjectPtr::find(const std::string& fullPath, DataObject*& refpObject) {
64  if ( 0 != m_dataProvider ) {
65  status = m_dataProvider->findObject(fullPath, refpObject);
66  }
67  return status;
68 }
69 
70 
74  if ( 0 != m_dataProvider && 0 != pRegistry ) {
75  status = m_dataProvider->updateObject(pRegistry);
76  }
77  return status;
78 }
79 
81 StatusCode SmartDataObjectPtr::update(const std::string& fullPath) {
83  if ( 0 != m_dataProvider ) {
84  status = m_dataProvider->updateObject(fullPath);
85  }
86  return status;
87 }
88 
95  DataObject* pObj = 0;
97  if ( m_status.isSuccess() ) {
98  m_pRegistry = pObj->registry();
99  m_path = "";
100  }
101  return pObj;
102 }
103 
110  DataObject* pObj = 0;
111  m_status = (0==m_pRegistry) ? find(m_path,pObj) : find(m_pRegistry,m_path,pObj);
112  if ( m_status.isSuccess() ) {
113  m_pRegistry = pObj->registry();
114  m_path = "";
115  }
116  return pObj;
117 }
118 
125  DataObject* pObj = accessData(); // Have to load AND update if not present.
126  if ( m_status.isSuccess() ) {
128  if ( !m_status.isSuccess() ) pObj = 0;
129  }
130  return pObj;
131 }
132 
146  if ( 0 != object_1.accessData() ) { // Test existence of the first object
147  if ( 0 != object_2.accessData() ) { // Test existence of the second object
148  return true; // Fine: Both objects exist
149  }
150  }
151  return false; // Tough luck: One is missing.
152 }
153 
171  if ( 0 != object_1.accessData() ) { // Test existence of the first object
172  return true;
173  }
174  if ( 0 != object_2.accessData() ) { // Test existence of the second object
175  return true;
176  }
177  return false; // Tough luck: Both are missing.
178 }
179 
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<...
virtual SmartDataObjectPtr & operator=(const SmartDataObjectPtr &copy)
Assignment operator.
DataObject * retrieveObject()
Object retrieve method.
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:69
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:30
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
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.
IDataProviderSvc * m_dataProvider
Pointer to contained object.
DataObject *(* AccessFunction)(SmartDataObjectPtr *ptr)
IRegistry * m_pRegistry
Pointer to the data registry containing the object.
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:31
DataObject * updateObject()
Object update method.
virtual StatusCode retrieveObject(IRegistry *pDirectory, const std::string &path, DataObject *&pObject)=0
Retrieve object identified by its directory entry.