The Gaudi Framework  master (37c0b60a)
DataSvc.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_DATASVC_H
12 #define GAUDIKERNEL_DATASVC_H
13 
14 // Include files
21 #include <GaudiKernel/Service.h>
22 #include <GaudiKernel/SmartIF.h>
23 
24 #include <string_view>
25 
26 // Forward declarations
27 // Incident service
28 class IIncidentSvc;
29 // Generic address
30 class IOpaqueAddress;
31 // Generic interface to data object class
32 class DataObject;
33 // Data store agent
34 class IDataStoreAgent;
35 
36 // Do not clutter global namespace for helpers...
37 namespace DataSvcHelpers {
38  // Map of objects where loading is inhibited
39  class InhibitMap;
40 } // namespace DataSvcHelpers
41 
52 class GAUDI_API DataSvc : public extends<Service, IDataProviderSvc, IDataManagerSvc> {
53 
55  SmartIF<IConversionSvc> m_dataLoader = nullptr;
56 
57 protected:
59  SmartIF<IIncidentSvc> m_incidentSvc = nullptr;
60 
61  Gaudi::Property<CLID> m_rootCLID{ this, "RootCLID", 110 /*CLID_Event*/, "CLID of root entry" };
62  Gaudi::Property<std::string> m_rootName{ this, "RootName", "/Event", "name of root entry" };
63 
64 private:
65  Gaudi::Property<bool> m_forceLeaves{ this, "ForceLeaves", false,
66  "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 
79 
80 protected:
83 
84 public:
86  CLID rootCLID() const override;
87 
89  const std::string& rootName() const override;
90 
92  StatusCode registerAddress( std::string_view fullPath, IOpaqueAddress* pAddress ) override;
93 
95 
97  StatusCode registerAddress( IRegistry* parentObj, std::string_view objectPath, IOpaqueAddress* pAddress ) override;
98 
100 
102  StatusCode unregisterAddress( std::string_view fullPath ) override;
103 
105  StatusCode unregisterAddress( IRegistry* pParent, std::string_view objPath ) override;
106 
110  StatusCode objectLeaves( const DataObject* pObject, std::vector<IRegistry*>& refLeaves ) override;
114  StatusCode objectLeaves( const IRegistry* pRegistry, std::vector<IRegistry*>& refLeaves ) override;
115 
117  StatusCode objectParent( const DataObject* pObject, IRegistry*& refpParent ) override;
119  StatusCode objectParent( const IRegistry* pRegistry, IRegistry*& refpParent ) override;
120 
124  StatusCode clearSubTree( std::string_view sub_tree_path ) override;
125 
129  StatusCode clearSubTree( DataObject* pObject ) override;
130 
132  StatusCode clearStore() override;
133 
137  StatusCode traverseSubTree( std::string_view sub_tree_path, IDataStoreAgent* pAgent ) override;
138 
140  StatusCode traverseSubTree( DataObject* pObject, IDataStoreAgent* pAgent ) override;
141 
143  StatusCode traverseTree( IDataStoreAgent* pAgent ) override;
144 
147  StatusCode setRoot( std::string root_name, DataObject* pRootObj ) override;
148 
152  virtual StatusCode i_setRoot( std::string root_name, DataObject* pRootObj );
153 
156  StatusCode setRoot( std::string root_path, IOpaqueAddress* pRootAddr ) override;
157 
162  virtual StatusCode i_setRoot( std::string root_path, IOpaqueAddress* pRootAddr );
163 
167  StatusCode setDataLoader( IConversionSvc* svc, IDataProviderSvc* dpsvc = nullptr ) override;
168 
170  StatusCode addPreLoadItem( const DataStoreItem& item ) override;
171 
173  StatusCode removePreLoadItem( const DataStoreItem& item ) override;
174 
176  StatusCode resetPreLoad() override;
177 
185  virtual StatusCode preLoad( int depth, int load_depth, DataObject* pObject );
186 
188  StatusCode preLoad() override;
189 
191 
193  StatusCode registerObject( std::string_view parentPath, std::string_view objPath, DataObject* pObject ) override;
194 
196  StatusCode registerObject( DataObject* parentObj, std::string_view objPath, DataObject* pObject ) override;
197 
199  StatusCode unregisterObject( std::string_view fullPath ) override;
200 
202  StatusCode unregisterObject( DataObject* pObject ) override;
203 
205  StatusCode unregisterObject( DataObject* pObject, std::string_view objectPath ) override;
206 
208 
210  StatusCode retrieveObject( IRegistry* pDirectory, std::string_view path, DataObject*& pObject ) override;
211 
213 
215  StatusCode findObject( std::string_view fullPath, DataObject*& pObject ) override;
216 
218  StatusCode findObject( IRegistry* pDirectory, std::string_view path, DataObject*& pObject ) override;
219 
221 
223  StatusCode linkObject( IRegistry* from, std::string_view objPath, DataObject* to ) override;
224 
226  StatusCode linkObject( std::string_view fullPath, DataObject* to ) override;
227 
229 
231  StatusCode unlinkObject( IRegistry* from, std::string_view objPath ) override;
232 
234  StatusCode unlinkObject( DataObject* fromObj, std::string_view objPath ) override;
235 
237  StatusCode unlinkObject( std::string_view fullPath ) override;
238 
240  StatusCode updateObject( IRegistry* pDirectory ) override;
241 
243  StatusCode updateObject( DataObject* toUpdate ) override;
244 
246  StatusCode initialize() override;
247 
249  StatusCode reinitialize() override;
250 
252  StatusCode finalize() override;
253 
255  using extends::extends;
256 
258  DataSvc( const DataSvc& ) = delete;
260  DataSvc& operator=( const DataSvc& ) = delete;
261 
262 protected:
264  bool checkRoot() { return 0 != m_root; }
265 
269  virtual IConversionSvc* getDataLoader( IRegistry* pReg );
270 
272  virtual DataObject* createDefaultObject() const;
273 
277  virtual StatusCode loadObject( IRegistry* pNode );
278 
282  virtual StatusCode loadObject( IConversionSvc* pLoader, IRegistry* pNode );
283 
285  StatusCode retrieveEntry( DataSvcHelpers::RegistryEntry* pNode, std::string_view path,
293  DataObject* handleDataFault( IRegistry* pReg, std::string_view path = "" );
294 
295 private:
296  StatusCode i_retrieveEntry( DataSvcHelpers::RegistryEntry* parentObj, std::string_view path,
298  DataObject* i_handleDataFault( IRegistry* pReg, std::string_view path = std::string_view{} );
299 };
300 #endif // GAUDIKERNEL_DATASVC_H
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
DataSvc::DataSvc
DataSvc(const DataSvc &)=delete
copy constructor disabled
IOpaqueAddress
Definition: IOpaqueAddress.h:33
std::vector< DataStoreItem >
IRegistry
Definition: IRegistry.h:32
IDataProviderSvc.h
RegistryEntry.h
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.
SmartIF.h
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.
SmartIF< IConversionSvc >
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
DataSvc::m_root
std::unique_ptr< DataSvcHelpers::RegistryEntry > m_root
Pointer to root entry.
Definition: DataSvc.h:82
DataSvc::checkRoot
bool checkRoot()
Check if root path is valid.
Definition: DataSvc.h:264
DataSvc
Definition: DataSvc.h:52
DataSvcHelpers::RegistryEntry
Definition: RegistryEntry.h:46
DataObject
Definition: DataObject.h:36
DataSvc::operator=
DataSvc & operator=(const DataSvc &)=delete
Fake assignment operator (never implemented).
IDataProviderSvc
Definition: IDataProviderSvc.h:53
IConversionSvc.h
IIncidentSvc
Definition: IIncidentSvc.h:33
std::unique_ptr< DataSvcHelpers::RegistryEntry >
DataSvc::m_preLoads
std::vector< DataStoreItem > m_preLoads
Items to be pre-loaded.
Definition: DataSvc.h:78
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
IConversionSvc
Definition: IConversionSvc.h:47