| The Gaudi Framework v30r0 (c919700c)

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

- File List
- File Members

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 {
34 public:
35 using AccessFunction = DataObject* (*)( SmartDataObjectPtr* ptr );
37 class ObjectLoader
38 {
39 public:
40 static AccessFunction access();
41 };
42
44 class ObjectFinder
45 {
46 public:
47 static AccessFunction access();
48 };
49
50 public:
57 SmartDataObjectPtr( AccessFunction access, IDataProviderSvc* pService, IRegistry* pDir, std::string path )
58 : m_dataProvider( pService ), m_pRegistry( pDir ), m_path( std::move( path ) ), m_accessFunc( access )
59 {
60 }
64 SmartDataObjectPtr( const SmartDataObjectPtr& ) = default;
65
67 virtual ~SmartDataObjectPtr() = default;
68
70 virtual SmartDataObjectPtr& operator=( const SmartDataObjectPtr& );
71
73 operator IRegistry*() { return m_pRegistry; }
74
76 const std::string& path() const { return m_path; }
77
79 IRegistry* directory() { return m_pRegistry; }
80
82 void setService( IDataProviderSvc* svc ) { m_dataProvider = svc; }
83
85 IDataProviderSvc* service() { return m_dataProvider; }
86
88 const StatusCode& getLastError() const { return m_status; }
89
91 DataObject* accessData() { return m_accessFunc( this ); }
92
94 static DataObject* retrieve( SmartDataObjectPtr* ptr ) { return ptr->retrieveObject(); }
95
97 static DataObject* find( SmartDataObjectPtr* ptr ) { return ptr->findObject(); }
98
100 static DataObject* update( SmartDataObjectPtr* ptr ) { return ptr->updateObject(); }
101
107 DataObject* retrieveObject();
108
114 DataObject* findObject();
115
122 DataObject* updateObject();
123
124 protected:
130 StatusCode find( IRegistry* pDirectory, const std::string& path, DataObject*& refpObject );
131
137 StatusCode find( const std::string& fullPath, DataObject*& refpObject );
138
144 StatusCode retrieve( IRegistry* pDirectory, const std::string& path, DataObject*& refpObject );
150 StatusCode retrieve( const std::string& fullPath, DataObject*& refpObject );
151
156 StatusCode update( IRegistry* pDirectory );
161 StatusCode update( const std::string& fullPath );
162
163 protected:
165 mutable IDataProviderSvc* m_dataProvider = nullptr;
167 mutable IRegistry* m_pRegistry = nullptr;
169 mutable StatusCode m_status = {StatusCode::SUCCESS, true};
171 std::string m_path;
173 AccessFunction m_accessFunc;
174 };
175 #endif // GAUDIKERNEL_SMARTDATAOBJECTPTR_H
StatusCode::SUCCESS
Definition: StatusCode.h:29
SmartDataObjectPtr::find
static DataObject * find(SmartDataObjectPtr *ptr)
Static Object find method.
Definition: SmartDataObjectPtr.h:97
Kernel.h
GaudiPython.HistoUtils.path
path
Definition: HistoUtils.py:895
SmartDataObjectPtr::retrieveObject
DataObject * retrieveObject()
Object retrieve method.
Definition: SmartDataObjectPtr.cpp:74
std
STL namespace.
IDataProviderSvc
Data provider interface definition.
Definition: IDataProviderSvc.h:46
SmartDataObjectPtr::SmartDataObjectPtr
SmartDataObjectPtr(AccessFunction access, IDataProviderSvc *pService, IRegistry *pDir, std::string path)
Standard constructor: Construct an SmartDataObjectPtr instance.
Definition: SmartDataObjectPtr.h:57
SmartDataObjectPtr::setService
void setService(IDataProviderSvc *svc)
Assign data service.
Definition: SmartDataObjectPtr.h:82
SmartDataObjectPtr::service
IDataProviderSvc * service()
Retrieve data service.
Definition: SmartDataObjectPtr.h:85
SmartDataObjectPtr::update
static DataObject * update(SmartDataObjectPtr *ptr)
Static Object update method.
Definition: SmartDataObjectPtr.h:100
operator=
PropertyMgr & operator=(const PropertyMgr &)=delete
SmartDataObjectPtr::retrieve
static DataObject * retrieve(SmartDataObjectPtr *ptr)
Static Object retrieval method.
Definition: SmartDataObjectPtr.h:94
std::string
STL class.
SmartDataObjectPtr::ObjectLoader
Helper class to configure smart pointer functionality.
Definition: SmartDataObjectPtr.h:37
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
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
Objects::access
bool access(const ContainedObject *from, ContainedObject **to)
Definition: KeyedObject.cpp:55
SmartDataObjectPtr::m_accessFunc
AccessFunction m_accessFunc
Data access function.
Definition: SmartDataObjectPtr.h:173
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:44
SmartDataObjectPtr::findObject
DataObject * findObject()
Object find method.
Definition: SmartDataObjectPtr.cpp:90
SmartDataObjectPtr::getLastError
const StatusCode & getLastError() const
Access to potential errors during data accesses.
Definition: SmartDataObjectPtr.h:88
SmartDataObjectPtr::directory
IRegistry * directory()
Access to data directory.
Definition: SmartDataObjectPtr.h:79
SmartDataObjectPtr::AccessFunction
DataObject *(*)(SmartDataObjectPtr *ptr) AccessFunction
Definition: SmartDataObjectPtr.h:35
StatusCode.h
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:110
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:123
SmartDataObjectPtr::updateObject
DataObject * updateObject()
Object update method.
Definition: SmartDataObjectPtr.cpp:106