The Gaudi Framework  v32r2 (46d42edc)
TsDataSvc.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_TSDATASVC_H
2 #define GAUDIKERNEL_TSDATASVC_H
3 
4 // Include files
9 #include "GaudiKernel/Service.h"
10 
11 // External libraries
12 #include "tbb/recursive_mutex.h"
13 #include "tbb/spin_mutex.h"
14 
15 namespace {
16  typedef tbb::recursive_mutex tsDataSvcMutex;
17  // typedef tbb::spin_mutex tsDataSvcMutex;
18 } // namespace
19 
20 // Forward declarations
21 // Incident service
22 class IIncidentSvc;
23 // Generic address
24 class IOpaqueAddress;
25 // Generic interface to data object class
26 class DataObject;
27 // Data store agent
28 class IDataStoreAgent;
29 
30 // Do not clutter global namespace for helpers...
31 namespace DataSvcHelpers {
32  // Map of objects where loading is inhibited
33  class InhibitMap;
34  // Generic registry entry
35  class RegistryEntry;
36 } // namespace DataSvcHelpers
37 
57 class GAUDI_API TsDataSvc : public extends<Service, IDataProviderSvc, IDataManagerSvc> {
58 
60  IConversionSvc* m_dataLoader = nullptr;
62  IIncidentSvc* m_incidentSvc = nullptr;
63 
64  Gaudi::Property<CLID> m_rootCLID{this, "RootCLID", 110 /*CLID_Event*/, "CLID of root entry"};
65  Gaudi::Property<std::string> m_rootName{this, "RootName", "/Event", "name of root entry"};
66  Gaudi::Property<bool> m_forceLeaves{this, "ForceLeaves", false, "force creation of default leaves on registerObject"};
67  Gaudi::Property<std::vector<std::string>> m_inhibitPathes{this, "InhibitPathes", {}, "inhibited leaves"};
68 
69  Gaudi::Property<bool> m_enableFaultHdlr{this, "EnableFaultHandler", false,
70  "enable incidents on data creation requests"};
71  Gaudi::Property<std::string> m_faultName{this, "DataFaultName", "DataFault", "Name of the data fault incident"};
72 
73  Gaudi::Property<bool> m_enableAccessHdlr{this, "EnableAccessHandler", false,
74  "enable incidents on data access requests"};
75  Gaudi::Property<std::string> m_accessName{this, "DataAccessName", "DataAccess", "Name of the data access incident"};
76 
81 
82 public:
84  CLID rootCLID() const override;
85 
87  const std::string& rootName() const override;
88 
90  StatusCode registerAddress( std::string_view fullPath, IOpaqueAddress* pAddress ) override;
91 
93 
95  StatusCode registerAddress( IRegistry* parentObj, std::string_view objectPath, IOpaqueAddress* pAddress ) override;
96 
99  StatusCode unregisterAddress( std::string_view fullPath ) override;
100 
102  StatusCode unregisterAddress( IRegistry* pParent, std::string_view objPath ) override;
103 
107  StatusCode objectLeaves( const DataObject* pObject, std::vector<IRegistry*>& refLeaves ) override;
111  StatusCode objectLeaves( const IRegistry* pRegistry, std::vector<IRegistry*>& refLeaves ) override;
112 
114  StatusCode objectParent( const DataObject* pObject, IRegistry*& refpParent ) override;
116  StatusCode objectParent( const IRegistry* pRegistry, IRegistry*& refpParent ) override;
117 
121  StatusCode clearSubTree( std::string_view sub_tree_path ) override;
122 
126  StatusCode clearSubTree( DataObject* pObject ) override;
127 
129  StatusCode clearStore() override;
130 
134  StatusCode traverseSubTree( std::string_view sub_tree_path, IDataStoreAgent* pAgent ) override;
135 
137  StatusCode traverseSubTree( DataObject* pObject, IDataStoreAgent* pAgent ) override;
138 
140  StatusCode traverseTree( IDataStoreAgent* pAgent ) override;
141 
144  StatusCode setRoot( std::string root_name, DataObject* pRootObj ) override;
145 
149  virtual StatusCode i_setRoot( std::string root_name, DataObject* pRootObj );
150  StatusCode i_setRoot( DataObject* pRootObj ) { return i_setRoot( m_rootName, pRootObj ); }
151 
154  StatusCode setRoot( std::string root_path, IOpaqueAddress* pRootAddr ) override;
155 
160  virtual StatusCode i_setRoot( std::string root_path, IOpaqueAddress* pRootAddr );
161  StatusCode i_setRoot( IOpaqueAddress* pRootAddr ) { return i_setRoot( m_rootName, pRootAddr ); }
162 
166  StatusCode setDataLoader( IConversionSvc* svc, IDataProviderSvc* dpsvc = nullptr ) override;
167 
169  StatusCode addPreLoadItem( const DataStoreItem& item ) override;
170 
172  StatusCode removePreLoadItem( const DataStoreItem& item ) override;
173 
175  StatusCode resetPreLoad() override;
176 
184  virtual StatusCode preLoad( int depth, int load_depth, DataObject* pObject );
185 
187  StatusCode preLoad() override;
188 
190 
192  StatusCode registerObject( std::string_view parentPath, std::string_view objPath, DataObject* pObject ) override;
193 
195  StatusCode registerObject( DataObject* parentObj, std::string_view objPath, DataObject* pObject ) override;
196 
198  StatusCode unregisterObject( std::string_view fullPath ) override;
199 
201  StatusCode unregisterObject( DataObject* pObject ) override;
202 
204  StatusCode unregisterObject( DataObject* pObject, std::string_view objectPath ) override;
205 
207 
209  StatusCode retrieveObject( IRegistry* pDirectory, std::string_view path, DataObject*& pObject ) override;
210 
212 
214  StatusCode findObject( std::string_view fullPath, DataObject*& pObject ) override;
215 
217  StatusCode findObject( IRegistry* pDirectory, std::string_view path, DataObject*& pObject ) override;
218 
220 
222  StatusCode linkObject( IRegistry* from, std::string_view objPath, DataObject* to ) override;
223 
225  StatusCode linkObject( std::string_view fullPath, DataObject* to ) override;
226 
228 
230  StatusCode unlinkObject( IRegistry* from, std::string_view objPath ) override;
231 
233  StatusCode unlinkObject( DataObject* fromObj, std::string_view objPath ) override;
234 
236  StatusCode unlinkObject( std::string_view fullPath ) override;
237 
239  StatusCode updateObject( IRegistry* pDirectory ) override;
240 
242  StatusCode updateObject( DataObject* toUpdate ) override;
243 
245  StatusCode initialize() override;
246 
248  StatusCode reinitialize() override;
249 
251  StatusCode finalize() override;
252 
254  using extends::extends;
255 
257  TsDataSvc( const TsDataSvc& ) = delete;
259  TsDataSvc& operator=( const TsDataSvc& ) = delete;
260 
261 protected:
263  bool checkRoot() { return 0 != m_root; }
264 
268  virtual IConversionSvc* getDataLoader( IRegistry* pReg );
269 
271  virtual DataObject* createDefaultObject() const;
272 
276  virtual StatusCode loadObject( IRegistry* pNode );
277 
281  virtual StatusCode loadObject( IConversionSvc* pLoader, IRegistry* pNode );
282 
284  StatusCode retrieveEntry( DataSvcHelpers::RegistryEntry* pNode, std::string_view path,
292  DataObject* handleDataFault( IRegistry* pReg, std::string_view path = {} );
293 
295  tsDataSvcMutex m_accessMutex;
296 };
297 #endif // GAUDIKERNEL_TSDATASVC_H
virtual StatusCode registerAddress(std::string_view fullPath, IOpaqueAddress *pAddress)=0
Register object address with the data store.
virtual StatusCode linkObject(IRegistry *from, std::string_view objPath, DataObject *toObj)=0
Add a link to another object.
Implementation of property with value of concrete type.
Definition: Property.h:352
tsDataSvcMutex m_accessMutex
Mutex to protect access to the store.
Definition: TsDataSvc.h:295
virtual StatusCode unregisterAddress(std::string_view fullPath)=0
Unregister object address from the data store.
Data provider interface definition.
Description of the DataStoreItem class.
Definition: DataStoreItem.h:17
virtual StatusCode findObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject)=0
Find object identified by its directory entry.
virtual StatusCode unlinkObject(IRegistry *from, std::string_view objPath)=0
Remove a link to another object.
STL class.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
Definition of an entry in the transient data store.
Definition: RegistryEntry.h:36
std::unique_ptr< DataSvcHelpers::RegistryEntry > m_root
Pointer to root entry.
Definition: TsDataSvc.h:80
StatusCode i_setRoot(IOpaqueAddress *pRootAddr)
Definition: TsDataSvc.h:161
virtual StatusCode retrieveObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject)=0
Retrieve object identified by its directory entry.
Generic data agent interface.
StatusCode registerObject(std::string_view fullPath, DataObject *pObject)
Register object with the data store.
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
std::vector< DataStoreItem > m_preLoads
Items to be pre-loaded.
Definition: TsDataSvc.h:78
Data service base class.
Definition: TsDataSvc.h:57
bool checkRoot()
Check if root path is valid.
Definition: TsDataSvc.h:263
Opaque address interface definition.
#define GAUDI_API
Definition: Kernel.h:71
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
The interface implemented by the IncidentSvc service.
Definition: IIncidentSvc.h:23
StatusCode i_setRoot(DataObject *pRootObj)
Definition: TsDataSvc.h:150