| The Gaudi Framework v32r1 (f65d50dc)

SmartDataObjectPtr.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_SMARTDATAOBJECTPTR_H
2 #define GAUDIKERNEL_SMARTDATAOBJECTPTR_H 1
3
4 // STL include files
5 #include <string>
6
7 // Framework include files
8 #include "GaudiKernel/Kernel.h"
9 #include "GaudiKernel/StatusCode.h"
10
11 // Forward declarations
12 class SmartDataObjectPtr;
13 class IDataProviderSvc;
14 class IRegistry;
15 class DataObject;
16
32 class GAUDI_API SmartDataObjectPtr {
33 public:
34 using AccessFunction = DataObject* (*)( SmartDataObjectPtr* ptr );
36 class ObjectLoader {
37 public:
38 static AccessFunction access();
39 };
40
42 class ObjectFinder {
43 public:
44 static AccessFunction access();
45 };
46
47 public:
54 SmartDataObjectPtr( AccessFunction access, IDataProviderSvc* pService, IRegistry* pDir, std::string path )
55 : m_dataProvider( pService ), m_pRegistry( pDir ), m_path( std::move( path ) ), m_accessFunc( access ) {}
59 SmartDataObjectPtr( const SmartDataObjectPtr& ) = default;
60
62 virtual ~SmartDataObjectPtr() = default;
63
65 virtual SmartDataObjectPtr& operator=( const SmartDataObjectPtr& );
66
68 operator IRegistry*() { return m_pRegistry; }
69
71 const std::string& path() const { return m_path; }
72
74 IRegistry* directory() { return m_pRegistry; }
75
77 void setService( IDataProviderSvc* svc ) { m_dataProvider = svc; }
78
80 IDataProviderSvc* service() { return m_dataProvider; }
81
83 const StatusCode& getLastError() const { return m_status; }
84
86 DataObject* accessData() { return m_accessFunc( this ); }
87
89 static DataObject* retrieve( SmartDataObjectPtr* ptr ) { return ptr->retrieveObject(); }
90
92 static DataObject* find( SmartDataObjectPtr* ptr ) { return ptr->findObject(); }
93
95 static DataObject* update( SmartDataObjectPtr* ptr ) { return ptr->updateObject(); }
96
102 DataObject* retrieveObject();
103
109 DataObject* findObject();
110
117 DataObject* updateObject();
118
119 protected:
125 StatusCode find( IRegistry* pDirectory, const std::string& path, DataObject*& refpObject );
126
132 StatusCode find( const std::string& fullPath, DataObject*& refpObject );
133
139 StatusCode retrieve( IRegistry* pDirectory, const std::string& path, DataObject*& refpObject );
145 StatusCode retrieve( const std::string& fullPath, DataObject*& refpObject );
146
151 StatusCode update( IRegistry* pDirectory );
156 StatusCode update( const std::string& fullPath );
157
158 protected:
160 mutable IDataProviderSvc* m_dataProvider = nullptr;
162 mutable IRegistry* m_pRegistry = nullptr;
164 mutable StatusCode m_status = {StatusCode::SUCCESS, true};
166 std::string m_path;
168 AccessFunction m_accessFunc;
169 };
170 #endif // GAUDIKERNEL_SMARTDATAOBJECTPTR_H
SmartDataObjectPtr::find
static DataObject * find(SmartDataObjectPtr *ptr)
Static Object find method.
Definition: SmartDataObjectPtr.h:92
Kernel.h
GaudiPython.HistoUtils.path
path
Definition: HistoUtils.py:932
SmartDataObjectPtr::retrieveObject
DataObject * retrieveObject()
Object retrieve method.
Definition: SmartDataObjectPtr.cpp:67
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
std
STL namespace.
IDataProviderSvc
Data provider interface definition.
Definition: IDataProviderSvc.h:43
SmartDataObjectPtr::SmartDataObjectPtr
SmartDataObjectPtr(AccessFunction access, IDataProviderSvc *pService, IRegistry *pDir, std::string path)
Standard constructor: Construct an SmartDataObjectPtr instance.
Definition: SmartDataObjectPtr.h:54
SmartDataObjectPtr::setService
void setService(IDataProviderSvc *svc)
Assign data service.
Definition: SmartDataObjectPtr.h:77
SmartDataObjectPtr::service
IDataProviderSvc * service()
Retrieve data service.
Definition: SmartDataObjectPtr.h:80
SmartDataObjectPtr::update
static DataObject * update(SmartDataObjectPtr *ptr)
Static Object update method.
Definition: SmartDataObjectPtr.h:95
SmartDataObjectPtr::retrieve
static DataObject * retrieve(SmartDataObjectPtr *ptr)
Static Object retrieval method.
Definition: SmartDataObjectPtr.h:89
std::string
STL class.
SmartDataObjectPtr::ObjectLoader
Helper class to configure smart pointer functionality.
Definition: SmartDataObjectPtr.h:36
SmartDataObjectPtr::path
const std::string & path() const
Path name.
Definition: SmartDataObjectPtr.h:71
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
SmartDataObjectPtr::getLastError
const StatusCode & getLastError() const
Access to potential errors during data accesses.
Definition: SmartDataObjectPtr.h:83
SmartDataObjectPtr::m_path
std::string m_path
Path to object.
Definition: SmartDataObjectPtr.h:166
SmartDataObjectPtr::accessData
DataObject * accessData()
Static Object retrieval method: must call specific function.
Definition: SmartDataObjectPtr.h:86
IRegistry
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
SmartDataObjectPtr::m_accessFunc
AccessFunction m_accessFunc
Data access function.
Definition: SmartDataObjectPtr.h:168
SmartDataObjectPtr
A small class used to access easily (and efficiently) data items residing in data stores.
Definition: SmartDataObjectPtr.h:32
SmartDataObjectPtr::ObjectFinder
Helper class to configure smart pointer functionality.
Definition: SmartDataObjectPtr.h:42
SmartDataObjectPtr::findObject
DataObject * findObject()
Object find method.
Definition: SmartDataObjectPtr.cpp:82
SmartDataObjectPtr::directory
IRegistry * directory()
Access to data directory.
Definition: SmartDataObjectPtr.h:74
SmartDataObjectPtr::AccessFunction
DataObject *(*)(SmartDataObjectPtr *ptr) AccessFunction
Definition: SmartDataObjectPtr.h:34
StatusCode.h
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:71
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
GaudiPython.Pythonizations.update
update
Definition: Pythonizations.py:119
SmartDataObjectPtr::updateObject
DataObject * updateObject()
Object update method.
Definition: SmartDataObjectPtr.cpp:97