| The Gaudi Framework v28r2-patches (bc4ad17a)

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

- File List
- File Members

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
17 SmartDataObjectPtr::AccessFunction SmartDataObjectPtr::ObjectLoader::access() {
18 return &SmartDataObjectPtr::retrieve;
19 }
20
21 SmartDataObjectPtr::AccessFunction SmartDataObjectPtr::ObjectFinder::access() {
22 return &SmartDataObjectPtr::find;
23 }
24
26 SmartDataObjectPtr& SmartDataObjectPtr::operator=(const SmartDataObjectPtr& copy) {
27 m_path = copy.m_path;
28 m_pRegistry = copy.m_pRegistry;
29 m_dataProvider = copy.m_dataProvider;
30 return *this;
31 }
32
34 StatusCode SmartDataObjectPtr::retrieve(IRegistry* pRegistry, const std::string& path, DataObject*& refpObject) {
35 return ( m_dataProvider && pRegistry ) ? m_dataProvider->retrieveObject(pRegistry, path, refpObject)
36 : StatusCode::FAILURE;
37 }
38
40 StatusCode SmartDataObjectPtr::retrieve(const std::string& fullPath, DataObject*& refpObject) {
41 return m_dataProvider ? m_dataProvider->retrieveObject(fullPath, refpObject)
42 : StatusCode::FAILURE;
43 }
44
46 StatusCode SmartDataObjectPtr::find(IRegistry* pDirectory, const std::string& path, DataObject*& refpObject) {
47 return ( m_dataProvider && pDirectory ) ? m_dataProvider->findObject(pDirectory, path, refpObject)
48 : StatusCode::FAILURE;;
49 }
50
52 StatusCode SmartDataObjectPtr::find(const std::string& fullPath, DataObject*& refpObject) {
53 return m_dataProvider ? m_dataProvider->findObject(fullPath, refpObject)
54 : StatusCode::FAILURE;
55 }
56
57
59 StatusCode SmartDataObjectPtr::update(IRegistry* pRegistry) {
60 return ( m_dataProvider && pRegistry ) ? m_dataProvider->updateObject(pRegistry)
61 : StatusCode::FAILURE;
62 }
63
65 StatusCode SmartDataObjectPtr::update(const std::string& fullPath) {
66 return ( m_dataProvider ) ? m_dataProvider->updateObject(fullPath)
67 : StatusCode::FAILURE;
68 }
69
75 DataObject* SmartDataObjectPtr::retrieveObject() {
76 DataObject* pObj = nullptr;
77 m_status = (!m_pRegistry ? retrieve(m_path,pObj) : retrieve(m_pRegistry,m_path,pObj) );
78 if ( m_status.isSuccess() ) {
79 m_pRegistry = pObj->registry();
80 m_path.clear();
81 }
82 return pObj;
83 }
84
90 DataObject* SmartDataObjectPtr::findObject() {
91 DataObject* pObj = nullptr;
92 m_status = ( m_pRegistry ? find(m_pRegistry,m_path,pObj) : find(m_path,pObj) );
93 if ( m_status.isSuccess() ) {
94 m_pRegistry = pObj->registry();
95 m_path.clear();
96 }
97 return pObj;
98 }
99
105 DataObject* SmartDataObjectPtr::updateObject() {
106 DataObject* pObj = accessData(); // Have to load AND update if not present.
107 if ( m_status.isSuccess() ) {
108 m_status = (!m_pRegistry ? update(m_path) : update(m_pRegistry) );
109 if ( !m_status.isSuccess() ) pObj = nullptr;
110 }
111 return pObj;
112 }
113
126 bool operator&& (SmartDataObjectPtr& object_1, SmartDataObjectPtr& object_2) {
127 return object_1.accessData() && object_2.accessData();
128 }
129
146 bool operator|| (SmartDataObjectPtr& object_1, SmartDataObjectPtr& object_2) {
147 return object_1.accessData() || object_2.accessData();
148 }
149
SmartDataObjectPtr::find
static DataObject * find(SmartDataObjectPtr *ptr)
Static Object find method.
Definition: SmartDataObjectPtr.h:113
operator||
bool operator||(SmartDataObjectPtr &object_1, SmartDataObjectPtr &object_2)
Helper to test Smart data objects efficiently This construct allows statements like: SmartEvtDataPtr<...
Definition: SmartDataObjectPtr.cpp:146
StatusCode::FAILURE
Definition: StatusCode.h:29
SmartDataObjectPtr::retrieveObject
DataObject * retrieveObject()
Object retrieve method.
Definition: SmartDataObjectPtr.cpp:75
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
SmartDataObjectPtr::AccessFunction
DataObject *(*)(SmartDataObjectPtr *ptr) AccessFunction
Definition: SmartDataObjectPtr.h:34
DataObject::registry
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:74
SmartDataObjectPtr::update
static DataObject * update(SmartDataObjectPtr *ptr)
Static Object update method.
Definition: SmartDataObjectPtr.h:118
SmartDataObjectPtr::retrieve
static DataObject * retrieve(SmartDataObjectPtr *ptr)
Static Object retrieval method.
Definition: SmartDataObjectPtr.h:108
std::string
STL class.
operator&&
bool operator&&(SmartDataObjectPtr &object_1, SmartDataObjectPtr &object_2)
Helper to test Smart data objects efficiently This construct allows statements like: SmartEvtDataPtr<...
Definition: SmartDataObjectPtr.cpp:126
IDataProviderSvc.h
SmartDataObjectPtr::ObjectFinder::access
static AccessFunction access()
Definition: SmartDataObjectPtr.cpp:21
IDataProviderSvc::findObject
virtual StatusCode findObject(IRegistry *pDirectory, const std::string &path, DataObject *&pObject)=0
Find object identified by its directory entry.
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
IDataProviderSvc::updateObject
virtual StatusCode updateObject(IRegistry *pDirectory)=0
Update object identified by its directory entry.
SmartDataObjectPtr::m_path
std::string m_path
Path to object.
Definition: SmartDataObjectPtr.h:192
SmartDataObjectPtr::accessData
DataObject * accessData()
Static Object retrieval method: must call specific function.
Definition: SmartDataObjectPtr.h:103
SmartDataObjectPtr::path
const std::string & path() const
Path name.
Definition: SmartDataObjectPtr.h:78
IRegistry
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
std::string::clear
T clear(T...args)
SmartDataObjectPtr::operator=
virtual SmartDataObjectPtr & operator=(const SmartDataObjectPtr &)
Assignment operator.
Definition: SmartDataObjectPtr.cpp:26
SmartDataObjectPtr::m_status
StatusCode m_status
Keep track of the last error.
Definition: SmartDataObjectPtr.h:190
SmartDataObjectPtr
A small class used to access easily (and efficiently) data items residing in data stores...
Definition: SmartDataObjectPtr.h:32
SmartDataObjectPtr::findObject
DataObject * findObject()
Object find method.
Definition: SmartDataObjectPtr.cpp:90
SmartDataObjectPtr::m_dataProvider
IDataProviderSvc * m_dataProvider
Pointer to contained object.
Definition: SmartDataObjectPtr.h:186
SmartDataObjectPtr::ObjectLoader::access
static AccessFunction access()
Definition: SmartDataObjectPtr.cpp:17
SmartDataObjectPtr::m_pRegistry
IRegistry * m_pRegistry
Pointer to the data registry containing the object.
Definition: SmartDataObjectPtr.h:188
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
SmartDataObjectPtr::updateObject
DataObject * updateObject()
Object update method.
Definition: SmartDataObjectPtr.cpp:105
DataObject.h
IDataProviderSvc::retrieveObject
virtual StatusCode retrieveObject(IRegistry *pDirectory, const std::string &path, DataObject *&pObject)=0
Retrieve object identified by its directory entry.
SmartDataObjectPtr.h