| The Gaudi Framework v30r0 (c919700c)

- 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/SmartDataObjectPtr.h"
14 #include "GaudiKernel/DataObject.h"
15 #include "GaudiKernel/IDataProviderSvc.h"
16
17 SmartDataObjectPtr::AccessFunction SmartDataObjectPtr::ObjectLoader::access() { return &SmartDataObjectPtr::retrieve; }
18
19 SmartDataObjectPtr::AccessFunction SmartDataObjectPtr::ObjectFinder::access() { return &SmartDataObjectPtr::find; }
20
22 SmartDataObjectPtr& SmartDataObjectPtr::operator=( const SmartDataObjectPtr& copy )
23 {
24 m_path = copy.m_path;
25 m_pRegistry = copy.m_pRegistry;
26 m_dataProvider = copy.m_dataProvider;
27 return *this;
28 }
29
31 StatusCode SmartDataObjectPtr::retrieve( IRegistry* pRegistry, const std::string& path, DataObject*& refpObject )
32 {
33 return ( m_dataProvider && pRegistry ) ? m_dataProvider->retrieveObject( pRegistry, path, refpObject )
34 : StatusCode::FAILURE;
35 }
36
38 StatusCode SmartDataObjectPtr::retrieve( const std::string& fullPath, DataObject*& refpObject )
39 {
40 return m_dataProvider ? m_dataProvider->retrieveObject( fullPath, refpObject ) : StatusCode::FAILURE;
41 }
42
44 StatusCode SmartDataObjectPtr::find( IRegistry* pDirectory, const std::string& path, DataObject*& refpObject )
45 {
46 return ( m_dataProvider && pDirectory ) ? m_dataProvider->findObject( pDirectory, path, refpObject )
47 : StatusCode::FAILURE;
48 ;
49 }
50
52 StatusCode SmartDataObjectPtr::find( const std::string& fullPath, DataObject*& refpObject )
53 {
54 return m_dataProvider ? m_dataProvider->findObject( fullPath, refpObject ) : StatusCode::FAILURE;
55 }
56
58 StatusCode SmartDataObjectPtr::update( IRegistry* pRegistry )
59 {
60 return ( m_dataProvider && pRegistry ) ? m_dataProvider->updateObject( pRegistry ) : StatusCode::FAILURE;
61 }
62
64 StatusCode SmartDataObjectPtr::update( const std::string& fullPath )
65 {
66 return ( m_dataProvider ) ? m_dataProvider->updateObject( fullPath ) : StatusCode::FAILURE;
67 }
68
74 DataObject* SmartDataObjectPtr::retrieveObject()
75 {
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 {
92 DataObject* pObj = nullptr;
93 m_status = ( m_pRegistry ? find( m_pRegistry, m_path, pObj ) : find( m_path, pObj ) );
94 if ( m_status.isSuccess() ) {
95 m_pRegistry = pObj->registry();
96 m_path.clear();
97 }
98 return pObj;
99 }
100
106 DataObject* SmartDataObjectPtr::updateObject()
107 {
108 DataObject* pObj = accessData(); // Have to load AND update if not present.
109 if ( m_status.isSuccess() ) {
110 m_status = ( !m_pRegistry ? update( m_path ) : update( m_pRegistry ) );
111 if ( !m_status.isSuccess() ) pObj = nullptr;
112 }
113 return pObj;
114 }
115
128 bool operator&&( SmartDataObjectPtr& object_1, SmartDataObjectPtr& object_2 )
129 {
130 return object_1.accessData() && object_2.accessData();
131 }
132
149 bool operator||( SmartDataObjectPtr& object_1, SmartDataObjectPtr& object_2 )
150 {
151 return object_1.accessData() || object_2.accessData();
152 }
SmartDataObjectPtr::find
static DataObject * find(SmartDataObjectPtr *ptr)
Static Object find method.
Definition: SmartDataObjectPtr.h:97
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:149
SmartDataObjectPtr::retrieveObject
DataObject * retrieveObject()
Object retrieve method.
Definition: SmartDataObjectPtr.cpp:74
IDataProviderSvc::findObject
virtual StatusCode findObject(IRegistry *pDirectory, boost::string_ref path, DataObject *&pObject)=0
Find object identified by its directory entry.
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:50
DataObject::registry
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:73
SmartDataObjectPtr::update
static DataObject * update(SmartDataObjectPtr *ptr)
Static Object update method.
Definition: SmartDataObjectPtr.h:100
SmartDataObjectPtr::retrieve
static DataObject * retrieve(SmartDataObjectPtr *ptr)
Static Object retrieval method.
Definition: SmartDataObjectPtr.h:94
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:128
IDataProviderSvc.h
SmartDataObjectPtr::ObjectFinder::access
static AccessFunction access()
Definition: SmartDataObjectPtr.cpp:19
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:171
SmartDataObjectPtr::accessData
DataObject * accessData()
Static Object retrieval method: must call specific function.
Definition: SmartDataObjectPtr.h:91
SmartDataObjectPtr::path
const std::string & path() const
Path name.
Definition: SmartDataObjectPtr.h:76
IRegistry
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
IDataProviderSvc::retrieveObject
virtual StatusCode retrieveObject(IRegistry *pDirectory, boost::string_ref path, DataObject *&pObject)=0
Retrieve object identified by its directory entry.
std::string::clear
T clear(T...args)
SmartDataObjectPtr::operator=
virtual SmartDataObjectPtr & operator=(const SmartDataObjectPtr &)
Assignment operator.
Definition: SmartDataObjectPtr.cpp:22
SmartDataObjectPtr::m_status
StatusCode m_status
Keep track of the last error.
Definition: SmartDataObjectPtr.h:169
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:165
SmartDataObjectPtr::ObjectLoader::access
static AccessFunction access()
Definition: SmartDataObjectPtr.cpp:17
SmartDataObjectPtr::AccessFunction
DataObject *(*)(SmartDataObjectPtr *ptr) AccessFunction
Definition: SmartDataObjectPtr.h:35
StatusCode::FAILURE
Definition: StatusCode.h:29
SmartDataObjectPtr::m_pRegistry
IRegistry * m_pRegistry
Pointer to the data registry containing the object.
Definition: SmartDataObjectPtr.h:167
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:106
DataObject.h
SmartDataObjectPtr.h