The Gaudi Framework  v33r1 (b1225454)
TsDataSvc.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef GAUDIKERNEL_TSDATASVC_H
12 #define GAUDIKERNEL_TSDATASVC_H
13 
14 // Include files
19 #include "GaudiKernel/Service.h"
20 
21 // External libraries
22 #include "tbb/spin_mutex.h"
23 #include "tbb/tbb_stddef.h"
24 #if TBB_INTERFACE_VERSION_MAJOR < 12
25 # include "tbb/recursive_mutex.h"
26 #endif // TBB_INTERFACE_VERSION_MAJOR < 12
27 
28 // System libraries
29 #include <mutex>
30 
31 namespace {
32 #if TBB_INTERFACE_VERSION_MAJOR < 12
33  typedef tbb::recursive_mutex tsDataSvcMutex;
34 #else
35  typedef std::recursive_mutex tsDataSvcMutex;
36 #endif // TBB_INTERFACE_VERSION_MAJOR < 12
37 } // namespace
38 
39 // Forward declarations
40 // Incident service
41 class IIncidentSvc;
42 // Generic address
43 class IOpaqueAddress;
44 // Generic interface to data object class
45 class DataObject;
46 // Data store agent
47 class IDataStoreAgent;
48 
49 // Do not clutter global namespace for helpers...
50 namespace DataSvcHelpers {
51  // Map of objects where loading is inhibited
52  class InhibitMap;
53  // Generic registry entry
54  class RegistryEntry;
55 } // namespace DataSvcHelpers
56 
76 class GAUDI_API TsDataSvc : public extends<Service, IDataProviderSvc, IDataManagerSvc> {
77 
79  IConversionSvc* m_dataLoader = nullptr;
81  IIncidentSvc* m_incidentSvc = nullptr;
82 
83  Gaudi::Property<CLID> m_rootCLID{this, "RootCLID", 110 /*CLID_Event*/, "CLID of root entry"};
84  Gaudi::Property<std::string> m_rootName{this, "RootName", "/Event", "name of root entry"};
85  Gaudi::Property<bool> m_forceLeaves{this, "ForceLeaves", false, "force creation of default leaves on registerObject"};
86  Gaudi::Property<std::vector<std::string>> m_inhibitPathes{this, "InhibitPathes", {}, "inhibited leaves"};
87 
88  Gaudi::Property<bool> m_enableFaultHdlr{this, "EnableFaultHandler", false,
89  "enable incidents on data creation requests"};
90  Gaudi::Property<std::string> m_faultName{this, "DataFaultName", "DataFault", "Name of the data fault incident"};
91 
92  Gaudi::Property<bool> m_enableAccessHdlr{this, "EnableAccessHandler", false,
93  "enable incidents on data access requests"};
94  Gaudi::Property<std::string> m_accessName{this, "DataAccessName", "DataAccess", "Name of the data access incident"};
95 
100 
101 public:
103  CLID rootCLID() const override;
104 
106  const std::string& rootName() const override;
107 
109  StatusCode registerAddress( std::string_view fullPath, IOpaqueAddress* pAddress ) override;
110 
112 
114  StatusCode registerAddress( IRegistry* parentObj, std::string_view objectPath, IOpaqueAddress* pAddress ) override;
115 
118  StatusCode unregisterAddress( std::string_view fullPath ) override;
119 
121  StatusCode unregisterAddress( IRegistry* pParent, std::string_view objPath ) override;
122 
126  StatusCode objectLeaves( const DataObject* pObject, std::vector<IRegistry*>& refLeaves ) override;
130  StatusCode objectLeaves( const IRegistry* pRegistry, std::vector<IRegistry*>& refLeaves ) override;
131 
133  StatusCode objectParent( const DataObject* pObject, IRegistry*& refpParent ) override;
135  StatusCode objectParent( const IRegistry* pRegistry, IRegistry*& refpParent ) override;
136 
140  StatusCode clearSubTree( std::string_view sub_tree_path ) override;
141 
145  StatusCode clearSubTree( DataObject* pObject ) override;
146 
148  StatusCode clearStore() override;
149 
153  StatusCode traverseSubTree( std::string_view sub_tree_path, IDataStoreAgent* pAgent ) override;
154 
156  StatusCode traverseSubTree( DataObject* pObject, IDataStoreAgent* pAgent ) override;
157 
159  StatusCode traverseTree( IDataStoreAgent* pAgent ) override;
160 
163  StatusCode setRoot( std::string root_name, DataObject* pRootObj ) override;
164 
168  virtual StatusCode i_setRoot( std::string root_name, DataObject* pRootObj );
169  StatusCode i_setRoot( DataObject* pRootObj ) { return i_setRoot( m_rootName, pRootObj ); }
170 
173  StatusCode setRoot( std::string root_path, IOpaqueAddress* pRootAddr ) override;
174 
179  virtual StatusCode i_setRoot( std::string root_path, IOpaqueAddress* pRootAddr );
180  StatusCode i_setRoot( IOpaqueAddress* pRootAddr ) { return i_setRoot( m_rootName, pRootAddr ); }
181 
185  StatusCode setDataLoader( IConversionSvc* svc, IDataProviderSvc* dpsvc = nullptr ) override;
186 
188  StatusCode addPreLoadItem( const DataStoreItem& item ) override;
189 
191  StatusCode removePreLoadItem( const DataStoreItem& item ) override;
192 
194  StatusCode resetPreLoad() override;
195 
203  virtual StatusCode preLoad( int depth, int load_depth, DataObject* pObject );
204 
206  StatusCode preLoad() override;
207 
209 
211  StatusCode registerObject( std::string_view parentPath, std::string_view objPath, DataObject* pObject ) override;
212 
214  StatusCode registerObject( DataObject* parentObj, std::string_view objPath, DataObject* pObject ) override;
215 
217  StatusCode unregisterObject( std::string_view fullPath ) override;
218 
220  StatusCode unregisterObject( DataObject* pObject ) override;
221 
223  StatusCode unregisterObject( DataObject* pObject, std::string_view objectPath ) override;
224 
226 
228  StatusCode retrieveObject( IRegistry* pDirectory, std::string_view path, DataObject*& pObject ) override;
229 
231 
233  StatusCode findObject( std::string_view fullPath, DataObject*& pObject ) override;
234 
236  StatusCode findObject( IRegistry* pDirectory, std::string_view path, DataObject*& pObject ) override;
237 
239 
241  StatusCode linkObject( IRegistry* from, std::string_view objPath, DataObject* to ) override;
242 
244  StatusCode linkObject( std::string_view fullPath, DataObject* to ) override;
245 
247 
249  StatusCode unlinkObject( IRegistry* from, std::string_view objPath ) override;
250 
252  StatusCode unlinkObject( DataObject* fromObj, std::string_view objPath ) override;
253 
255  StatusCode unlinkObject( std::string_view fullPath ) override;
256 
258  StatusCode updateObject( IRegistry* pDirectory ) override;
259 
261  StatusCode updateObject( DataObject* toUpdate ) override;
262 
264  StatusCode initialize() override;
265 
267  StatusCode reinitialize() override;
268 
270  StatusCode finalize() override;
271 
273  using extends::extends;
274 
276  TsDataSvc( const TsDataSvc& ) = delete;
278  TsDataSvc& operator=( const TsDataSvc& ) = delete;
279 
280 protected:
282  bool checkRoot() { return 0 != m_root; }
283 
287  virtual IConversionSvc* getDataLoader( IRegistry* pReg );
288 
290  virtual DataObject* createDefaultObject() const;
291 
295  virtual StatusCode loadObject( IRegistry* pNode );
296 
300  virtual StatusCode loadObject( IConversionSvc* pLoader, IRegistry* pNode );
301 
303  StatusCode retrieveEntry( DataSvcHelpers::RegistryEntry* pNode, std::string_view path,
311  DataObject* handleDataFault( IRegistry* pReg, std::string_view path = {} );
312 
314  tsDataSvcMutex m_accessMutex;
315 };
316 #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:370
tsDataSvcMutex m_accessMutex
Mutex to protect access to the store.
Definition: TsDataSvc.h:314
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:27
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:61
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:32
unsigned int CLID
Class ID definition.
Definition: ClassID.h:18
Definition of an entry in the transient data store.
Definition: RegistryEntry.h:46
std::unique_ptr< DataSvcHelpers::RegistryEntry > m_root
Pointer to root entry.
Definition: TsDataSvc.h:99
StatusCode i_setRoot(IOpaqueAddress *pRootAddr)
Definition: TsDataSvc.h:180
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:20
std::vector< DataStoreItem > m_preLoads
Items to be pre-loaded.
Definition: TsDataSvc.h:97
Data service base class.
Definition: TsDataSvc.h:76
bool checkRoot()
Check if root path is valid.
Definition: TsDataSvc.h:282
Opaque address interface definition.
#define GAUDI_API
Definition: Kernel.h:81
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:40
The interface implemented by the IncidentSvc service.
Definition: IIncidentSvc.h:33
StatusCode i_setRoot(DataObject *pRootObj)
Definition: TsDataSvc.h:169