| The Gaudi Framework v28r2p1 (f1a77ff4)

- 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 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),
56 m_pRegistry(pDir),
57 m_path(std::move(path)),
58 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*() {
74 return m_pRegistry;
75 }
76
78 const std::string& path() const {
79 return m_path;
80 }
81
83 IRegistry* directory() {
84 return m_pRegistry;
85 }
86
88 void setService( IDataProviderSvc* svc ) {
89 m_dataProvider = svc;
90 }
91
93 IDataProviderSvc* service() {
94 return m_dataProvider;
95 }
96
98 const StatusCode& getLastError() const {
99 return m_status;
100 }
101
103 DataObject* accessData() {
104 return m_accessFunc(this);
105 }
106
108 static DataObject* retrieve(SmartDataObjectPtr* ptr) {
109 return ptr->retrieveObject();
110 }
111
113 static DataObject* find(SmartDataObjectPtr* ptr) {
114 return ptr->findObject();
115 }
116
118 static DataObject* update(SmartDataObjectPtr* ptr) {
119 return ptr->updateObject();
120 }
121
127 DataObject* retrieveObject();
128
134 DataObject* findObject();
135
142 DataObject* updateObject();
143
144 protected:
145
151 StatusCode find(IRegistry* pDirectory, const std::string& path, DataObject*& refpObject);
152
158 StatusCode find(const std::string& fullPath, DataObject*& refpObject);
159
165 StatusCode retrieve(IRegistry* pDirectory, const std::string& path, DataObject*& refpObject);
171 StatusCode retrieve(const std::string& fullPath, DataObject*& refpObject);
172
177 StatusCode update(IRegistry* pDirectory);
182 StatusCode update(const std::string& fullPath);
183
184 protected:
186 mutable IDataProviderSvc* m_dataProvider = nullptr;
188 mutable IRegistry* m_pRegistry = nullptr;
190 mutable StatusCode m_status = { StatusCode::SUCCESS, true } ;
192 std::string m_path;
194 AccessFunction m_accessFunc;
195
196 };
197 #endif // GAUDIKERNEL_SMARTDATAOBJECTPTR_H
StatusCode::SUCCESS
Definition: StatusCode.h:30
SmartDataObjectPtr::find
static DataObject * find(SmartDataObjectPtr *ptr)
Static Object find method.
Definition: SmartDataObjectPtr.h:113
Kernel.h
GaudiPython.HistoUtils.path
path
Definition: HistoUtils.py:772
SmartDataObjectPtr::retrieveObject
DataObject * retrieveObject()
Object retrieve method.
Definition: SmartDataObjectPtr.cpp:75
std
STL namespace.
SmartDataObjectPtr::AccessFunction
DataObject *(*)(SmartDataObjectPtr *ptr) AccessFunction
Definition: SmartDataObjectPtr.h:34
IDataProviderSvc
Data provider interface definition.
Definition: IDataProviderSvc.h:45
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:88
SmartDataObjectPtr::service
IDataProviderSvc * service()
Retrieve data service.
Definition: SmartDataObjectPtr.h:93
SmartDataObjectPtr::update
static DataObject * update(SmartDataObjectPtr *ptr)
Static Object update method.
Definition: SmartDataObjectPtr.h:118
operator=
PropertyMgr & operator=(const PropertyMgr &)=delete
SmartDataObjectPtr::retrieve
static DataObject * retrieve(SmartDataObjectPtr *ptr)
Static Object retrieval method.
Definition: SmartDataObjectPtr.h:108
std::string
STL class.
SmartDataObjectPtr::ObjectLoader
Helper class to configure smart pointer functionality.
Definition: SmartDataObjectPtr.h:36
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: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
Objects::access
bool access(const ContainedObject *from, ContainedObject **to)
Definition: KeyedObject.cpp:53
SmartDataObjectPtr::m_accessFunc
AccessFunction m_accessFunc
Data access function.
Definition: SmartDataObjectPtr.h:194
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:90
SmartDataObjectPtr::getLastError
const StatusCode & getLastError() const
Access to potential errors during data accesses.
Definition: SmartDataObjectPtr.h:98
SmartDataObjectPtr::directory
IRegistry * directory()
Access to data directory.
Definition: SmartDataObjectPtr.h:83
StatusCode.h
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:107
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:94
SmartDataObjectPtr::updateObject
DataObject * updateObject()
Object update method.
Definition: SmartDataObjectPtr.cpp:105