The Gaudi Framework  master (37c0b60a)
TsDataSvc.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 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
20 #include <GaudiKernel/Service.h>
22 
23 // System libraries
24 #include <mutex>
25 
26 namespace {
27  typedef std::recursive_mutex tsDataSvcMutex;
28 } // namespace
29 
30 // Forward declarations
31 // Generic address
32 class IOpaqueAddress;
33 // Generic interface to data object class
34 class DataObject;
35 // Data store agent
36 class IDataStoreAgent;
37 
38 // Do not clutter global namespace for helpers...
39 namespace DataSvcHelpers {
40  // Map of objects where loading is inhibited
41  class InhibitMap;
42  // Generic registry entry
43  class RegistryEntry;
44 } // namespace DataSvcHelpers
45 
65 class GAUDI_API TsDataSvc : public extends<Service, IDataProviderSvc, IDataManagerSvc> {
66 
68  IConversionSvc* m_dataLoader = nullptr;
71 
72  Gaudi::Property<CLID> m_rootCLID{ this, "RootCLID", 110 /*CLID_Event*/, "CLID of root entry" };
73  Gaudi::Property<std::string> m_rootName{ this, "RootName", "/Event", "name of root entry" };
74  Gaudi::Property<bool> m_forceLeaves{ this, "ForceLeaves", false,
75  "force creation of default leaves on registerObject" };
76  Gaudi::Property<std::vector<std::string>> m_inhibitPathes{ this, "InhibitPathes", {}, "inhibited leaves" };
77 
78  Gaudi::Property<bool> m_enableFaultHdlr{ this, "EnableFaultHandler", false,
79  "enable incidents on data creation requests" };
80  Gaudi::Property<std::string> m_faultName{ this, "DataFaultName", "DataFault", "Name of the data fault incident" };
81 
82  Gaudi::Property<bool> m_enableAccessHdlr{ this, "EnableAccessHandler", false,
83  "enable incidents on data access requests" };
84  Gaudi::Property<std::string> m_accessName{ this, "DataAccessName", "DataAccess", "Name of the data access incident" };
85 
90 
91 public:
93  CLID rootCLID() const override;
94 
96  const std::string& rootName() const override;
97 
99  StatusCode registerAddress( std::string_view fullPath, IOpaqueAddress* pAddress ) override;
100 
102 
104  StatusCode registerAddress( IRegistry* parentObj, std::string_view objectPath, IOpaqueAddress* pAddress ) override;
105 
108  StatusCode unregisterAddress( std::string_view fullPath ) override;
109 
111  StatusCode unregisterAddress( IRegistry* pParent, std::string_view objPath ) override;
112 
116  StatusCode objectLeaves( const DataObject* pObject, std::vector<IRegistry*>& refLeaves ) override;
120  StatusCode objectLeaves( const IRegistry* pRegistry, std::vector<IRegistry*>& refLeaves ) override;
121 
123  StatusCode objectParent( const DataObject* pObject, IRegistry*& refpParent ) override;
125  StatusCode objectParent( const IRegistry* pRegistry, IRegistry*& refpParent ) override;
126 
130  StatusCode clearSubTree( std::string_view sub_tree_path ) override;
131 
135  StatusCode clearSubTree( DataObject* pObject ) override;
136 
138  StatusCode clearStore() override;
139 
143  StatusCode traverseSubTree( std::string_view sub_tree_path, IDataStoreAgent* pAgent ) override;
144 
146  StatusCode traverseSubTree( DataObject* pObject, IDataStoreAgent* pAgent ) override;
147 
149  StatusCode traverseTree( IDataStoreAgent* pAgent ) override;
150 
153  StatusCode setRoot( std::string root_name, DataObject* pRootObj ) override;
154 
158  virtual StatusCode i_setRoot( std::string root_name, DataObject* pRootObj );
159  StatusCode i_setRoot( DataObject* pRootObj ) { return i_setRoot( m_rootName, pRootObj ); }
160 
163  StatusCode setRoot( std::string root_path, IOpaqueAddress* pRootAddr ) override;
164 
169  virtual StatusCode i_setRoot( std::string root_path, IOpaqueAddress* pRootAddr );
170  StatusCode i_setRoot( IOpaqueAddress* pRootAddr ) { return i_setRoot( m_rootName, pRootAddr ); }
171 
175  StatusCode setDataLoader( IConversionSvc* svc, IDataProviderSvc* dpsvc = nullptr ) override;
176 
178  StatusCode addPreLoadItem( const DataStoreItem& item ) override;
179 
181  StatusCode removePreLoadItem( const DataStoreItem& item ) override;
182 
184  StatusCode resetPreLoad() override;
185 
193  virtual StatusCode preLoad( int depth, int load_depth, DataObject* pObject );
194 
196  StatusCode preLoad() override;
197 
199 
201  StatusCode registerObject( std::string_view parentPath, std::string_view objPath, DataObject* pObject ) override;
202 
204  StatusCode registerObject( DataObject* parentObj, std::string_view objPath, DataObject* pObject ) override;
205 
207  StatusCode unregisterObject( std::string_view fullPath ) override;
208 
210  StatusCode unregisterObject( DataObject* pObject ) override;
211 
213  StatusCode unregisterObject( DataObject* pObject, std::string_view objectPath ) override;
214 
216 
218  StatusCode retrieveObject( IRegistry* pDirectory, std::string_view path, DataObject*& pObject ) override;
219 
221 
223  StatusCode findObject( std::string_view fullPath, DataObject*& pObject ) override;
224 
226  StatusCode findObject( IRegistry* pDirectory, std::string_view path, DataObject*& pObject ) override;
227 
229 
231  StatusCode linkObject( IRegistry* from, std::string_view objPath, DataObject* to ) override;
232 
234  StatusCode linkObject( std::string_view fullPath, DataObject* to ) override;
235 
237 
239  StatusCode unlinkObject( IRegistry* from, std::string_view objPath ) override;
240 
242  StatusCode unlinkObject( DataObject* fromObj, std::string_view objPath ) override;
243 
245  StatusCode unlinkObject( std::string_view fullPath ) override;
246 
248  StatusCode updateObject( IRegistry* pDirectory ) override;
249 
251  StatusCode updateObject( DataObject* toUpdate ) override;
252 
254  StatusCode initialize() override;
255 
257  StatusCode reinitialize() override;
258 
260  StatusCode finalize() override;
261 
263  TsDataSvc( const std::string& name, ISvcLocator* svc );
264 
266  TsDataSvc( const TsDataSvc& ) = delete;
268  TsDataSvc& operator=( const TsDataSvc& ) = delete;
269 
270 protected:
272  bool checkRoot() { return 0 != m_root; }
273 
277  virtual IConversionSvc* getDataLoader( IRegistry* pReg );
278 
280  virtual DataObject* createDefaultObject() const;
281 
285  virtual StatusCode loadObject( IRegistry* pNode );
286 
290  virtual StatusCode loadObject( IConversionSvc* pLoader, IRegistry* pNode );
291 
293  StatusCode retrieveEntry( DataSvcHelpers::RegistryEntry* pNode, std::string_view path,
301  DataObject* handleDataFault( IRegistry* pReg, std::string_view path = {} );
302 
304  tsDataSvcMutex m_accessMutex;
305 };
306 #endif // GAUDIKERNEL_TSDATASVC_H
TsDataSvc::m_preLoads
std::vector< DataStoreItem > m_preLoads
Items to be pre-loaded.
Definition: TsDataSvc.h:87
TsDataSvc::m_root
std::unique_ptr< DataSvcHelpers::RegistryEntry > m_root
Pointer to root entry.
Definition: TsDataSvc.h:89
TsDataSvc::m_accessMutex
tsDataSvcMutex m_accessMutex
Mutex to protect access to the store.
Definition: TsDataSvc.h:304
std::string
STL class.
DataStoreItem.h
IDataProviderSvc::unlinkObject
virtual StatusCode unlinkObject(IRegistry *from, std::string_view objPath)=0
Remove a link to another object.
AtlasMCRecoFullPrecedenceDump.path
path
Definition: AtlasMCRecoFullPrecedenceDump.py:49
TsDataSvc::operator=
TsDataSvc & operator=(const TsDataSvc &)=delete
no assignment operator
ServiceHandle< IIncidentSvc >
IOpaqueAddress
Definition: IOpaqueAddress.h:33
std::vector< DataStoreItem >
ISvcLocator
Definition: ISvcLocator.h:46
TsDataSvc::checkRoot
bool checkRoot()
Check if root path is valid.
Definition: TsDataSvc.h:272
std::recursive_mutex
STL class.
IRegistry
Definition: IRegistry.h:32
TsDataSvc::TsDataSvc
TsDataSvc(const TsDataSvc &)=delete
no copy constructor
ServiceHandle.h
TsDataSvc::m_incidentSvc
ServiceHandle< IIncidentSvc > m_incidentSvc
Handle to incident service.
Definition: TsDataSvc.h:70
IDataProviderSvc.h
RegistryEntry.h
TsDataSvc::i_setRoot
StatusCode i_setRoot(IOpaqueAddress *pRootAddr)
Definition: TsDataSvc.h:170
IIncidentSvc.h
IDataProviderSvc::registerObject
StatusCode registerObject(std::string_view fullPath, DataObject *pObject)
Register object with the data store.
Definition: IDataProviderSvc.h:72
IDataProviderSvc::linkObject
virtual StatusCode linkObject(IRegistry *from, std::string_view objPath, DataObject *toObj)=0
Add a link to another object.
StatusCode
Definition: StatusCode.h:65
IDataManagerSvc::registerAddress
virtual StatusCode registerAddress(std::string_view fullPath, IOpaqueAddress *pAddress)=0
Register object address with the data store.
DataStoreItem
Definition: DataStoreItem.h:27
IDataProviderSvc::retrieveObject
virtual StatusCode retrieveObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject)=0
Retrieve object identified by its directory entry.
IDataManagerSvc::unregisterAddress
virtual StatusCode unregisterAddress(std::string_view fullPath)=0
Unregister object address from the data store.
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:18
extends
Base class used to extend a class implementing other interfaces.
Definition: extends.h:20
Service.h
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
DataSvcHelpers::RegistryEntry
Definition: RegistryEntry.h:46
DataObject
Definition: DataObject.h:36
IDataProviderSvc
Definition: IDataProviderSvc.h:53
TsDataSvc
Definition: TsDataSvc.h:65
std::unique_ptr< DataSvcHelpers::RegistryEntry >
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:81
Gaudi::Property< CLID >
IDataManagerSvc.h
DataSvcHelpers
Definition: DataSvc.h:37
IDataProviderSvc::findObject
virtual StatusCode findObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject)=0
Find object identified by its directory entry.
IDataStoreAgent
Definition: IDataStoreAgent.h:27
TsDataSvc::i_setRoot
StatusCode i_setRoot(DataObject *pRootObj)
Definition: TsDataSvc.h:159
IConversionSvc
Definition: IConversionSvc.h:47