The Gaudi Framework  master (37c0b60a)
IDataProviderSvc.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_IDATAPROVIDERSVC_H
12 #define GAUDIKERNEL_IDATAPROVIDERSVC_H
13 
14 // Framework include files
15 #include <GaudiKernel/IInterface.h>
16 
17 // C/C++ include files
18 #include <string>
19 #include <string_view>
20 
21 // Forward declarations
22 class IOpaqueAddress;
23 class IRegistry;
24 #include <GaudiKernel/DataObject.h>
26 
53 class GAUDI_API IDataProviderSvc : virtual public IInterface {
54 
56  // /// i.e. int -> "/" + int
57  static inline std::string itemToPath( int item ) { return '/' + std::to_string( item ); }
58 
59 public:
62 
63  enum { SEPARATOR = '/' };
64 
72  StatusCode registerObject( std::string_view fullPath, DataObject* pObject ) {
73  return registerObject( nullptr, fullPath, pObject );
74  }
75 
84  virtual StatusCode registerObject( std::string_view parentPath, std::string_view objectPath,
85  DataObject* pObject ) = 0;
86 
95  StatusCode registerObject( std::string_view parentPath, int item, DataObject* pObject ) {
96  return registerObject( parentPath, itemToPath( item ), pObject );
97  }
98 
107  virtual StatusCode registerObject( DataObject* parentObj, std::string_view objectPath, DataObject* pObject ) = 0;
108 
117  StatusCode registerObject( DataObject* parentObj, int item, DataObject* pObject ) {
118  return registerObject( parentObj, itemToPath( item ), pObject );
119  }
120 
134  virtual StatusCode unregisterObject( std::string_view fullPath ) = 0;
135 
150  StatusCode unregisterObject( std::string_view parentPath, std::string_view objPath ) {
151  DataObject* pO = nullptr;
152  StatusCode status = findObject( parentPath, pO );
153  return status.isSuccess() ? unregisterObject( pO, objPath ) : status;
154  }
155 
170  StatusCode unregisterObject( std::string_view parentPath, int item ) {
171  return unregisterObject( parentPath, itemToPath( item ) );
172  }
173 
187  virtual StatusCode unregisterObject( DataObject* pObject ) = 0;
188 
203  virtual StatusCode unregisterObject( DataObject* pParent, std::string_view objPath ) = 0;
204 
219  StatusCode unregisterObject( DataObject* pParent, int item ) {
220  return unregisterObject( pParent, itemToPath( item ) );
221  }
222 
233  virtual StatusCode retrieveObject( IRegistry* pDirectory, std::string_view path, DataObject*& pObject ) = 0;
234 
243  StatusCode retrieveObject( std::string_view fullPath, DataObject*& pObject ) {
244  return retrieveObject( static_cast<IRegistry*>( nullptr ), fullPath, pObject );
245  }
246 
257  StatusCode retrieveObject( std::string_view parentPath, std::string_view objectPath, DataObject*& pObject ) {
258  DataObject* parent = nullptr;
259  StatusCode status = retrieveObject( parentPath, parent );
260  return status.isSuccess() ? retrieveObject( parent, objectPath, pObject ) : status;
261  }
262 
273  StatusCode retrieveObject( std::string_view parentPath, int item, DataObject*& pObject ) {
274  return retrieveObject( parentPath, itemToPath( item ), pObject );
275  }
276 
287  StatusCode retrieveObject( DataObject* parentObj, std::string_view objectPath, DataObject*& pObject ) {
288  return retrieveObject( parentObj ? parentObj->registry() : nullptr, objectPath, pObject );
289  }
290 
301  StatusCode retrieveObject( DataObject* parentObj, int item, DataObject*& pObject ) {
302  return retrieveObject( parentObj, itemToPath( item ), pObject );
303  }
304 
314  virtual StatusCode findObject( IRegistry* pDirectory, std::string_view path, DataObject*& pObject ) = 0;
315 
323  virtual StatusCode findObject( std::string_view fullPath, DataObject*& pObject ) = 0;
324 
334  StatusCode findObject( std::string_view parentPath, std::string_view objectPath, DataObject*& pObject ) {
335  DataObject* parent = nullptr;
336  StatusCode status = findObject( parentPath, parent );
337  return status.isSuccess() ? findObject( parent, objectPath, pObject ) : status;
338  }
339 
348  StatusCode findObject( std::string_view parentPath, int item, DataObject*& pObject ) {
349  return findObject( parentPath, itemToPath( item ), pObject );
350  }
351 
361  StatusCode findObject( DataObject* parentObj, std::string_view objectPath, DataObject*& pObject ) {
362  return findObject( parentObj ? parentObj->registry() : nullptr, objectPath, pObject );
363  }
364 
373  StatusCode findObject( DataObject* parentObj, int item, DataObject*& pObject ) {
374  return findObject( parentObj, itemToPath( item ), pObject );
375  }
376 
382  virtual StatusCode updateObject( IRegistry* pDirectory ) = 0;
383 
390  StatusCode updateObject( std::string_view fullPath ) {
391  DataObject* pO = nullptr;
392  StatusCode status = findObject( fullPath, pO );
393  return status.isSuccess() ? updateObject( pO ) : retrieveObject( fullPath, pO );
394  }
395 
402  virtual StatusCode updateObject( DataObject* toUpdate ) = 0;
403 
412  StatusCode updateObject( std::string_view parentPath, std::string_view updatePath ) {
413  DataObject* pParent = nullptr;
414  StatusCode status = findObject( parentPath, pParent );
415  return status.isSuccess() ? updateObject( pParent, updatePath ) : status;
416  }
417 
426  StatusCode updateObject( DataObject* pParent, std::string_view updatePath ) {
427  DataObject* pObject = nullptr;
428  StatusCode status = findObject( pParent, updatePath, pObject );
429  return status.isSuccess() ? updateObject( pObject ) : status;
430  }
431 
436  virtual StatusCode addPreLoadItem( const DataStoreItem& item ) = 0;
437 
444  return addPreLoadItem( DataStoreItem( std::move( itemPath ), 1 ) );
445  }
446 
451  virtual StatusCode removePreLoadItem( const DataStoreItem& item ) = 0;
452 
458  return removePreLoadItem( DataStoreItem( std::move( itemPath ), 1 ) );
459  }
460 
464  virtual StatusCode resetPreLoad() = 0;
465 
469  virtual StatusCode preLoad() = 0;
470 
479  virtual StatusCode linkObject( IRegistry* from, std::string_view objPath, DataObject* toObj ) = 0;
480 
489  StatusCode linkObject( std::string_view fromPath, std::string_view objPath, DataObject* toObj ) {
490  DataObject* pO = nullptr;
491  StatusCode status = retrieveObject( fromPath, pO );
492  return status.isSuccess() ? linkObject( pO->registry(), objPath, toObj ) : status;
493  }
494 
503  inline StatusCode linkObject( DataObject* fromObj, std::string_view objPath, DataObject* toObj );
504 
512  virtual StatusCode linkObject( std::string_view fullPath, DataObject* toObj ) = 0;
513 
522  virtual StatusCode unlinkObject( IRegistry* from, std::string_view objPath ) = 0;
523 
532  StatusCode unlinkObject( std::string_view fromPath, std::string_view objPath ) {
533  DataObject* pObject = nullptr;
534  StatusCode status = findObject( fromPath, pObject );
535  return status.isSuccess() ? unlinkObject( pObject->registry(), objPath ) : status;
536  }
537 
546  virtual StatusCode unlinkObject( DataObject* fromObj, std::string_view objPath ) = 0;
547 
555  virtual StatusCode unlinkObject( std::string_view fullPath ) = 0;
556 
558  enum class Status : StatusCode::code_t {
560  IDataProviderSvc_NO_ERROR = 1,
562  DOUBL_OBJ_PATH,
564  INVALID_OBJ_PATH,
566  INVALID_ROOT,
568  INVALID_OBJECT,
570  INVALID_PARENT,
572  OBJ_NOT_LOADED,
574  NO_DATA_LOADER,
576  INVALID_OBJ_ADDR,
578  DIR_NOT_EMPTY,
580  NO_MORE_LEVELS,
582  NO_ACCESS,
584  LAST
585  };
586 };
587 
589 
590 inline StatusCode IDataProviderSvc::linkObject( DataObject* fromObj, std::string_view objPath, DataObject* toObj ) {
591  if ( fromObj ) {
592  IRegistry* from_entry = fromObj->registry();
593  if ( from_entry ) return linkObject( from_entry, objPath, toObj );
594  }
595  return Status::INVALID_PARENT;
596 }
597 
598 #endif // GAUDIKERNEL_IDATAPROVIDERSVC_H
IDataProviderSvc::updateObject
StatusCode updateObject(DataObject *pParent, std::string_view updatePath)
Update object identified by its parent's pointer and the path relative to the parent.
Definition: IDataProviderSvc.h:426
IDataProviderSvc::registerObject
virtual StatusCode registerObject(DataObject *parentObj, std::string_view objectPath, DataObject *pObject)=0
Register object with the data store.
IDataProviderSvc::unregisterObject
StatusCode unregisterObject(std::string_view parentPath, int item)
Unregister object from the data store.
Definition: IDataProviderSvc.h:170
IDataProviderSvc::unregisterObject
virtual StatusCode unregisterObject(std::string_view fullPath)=0
Unregister object from the data store.
std::string
STL class.
DataStoreItem.h
IDataProviderSvc::removePreLoadItem
virtual StatusCode removePreLoadItem(const DataStoreItem &item)=0
Remove an item from the preload list.
IDataProviderSvc::unlinkObject
virtual StatusCode unlinkObject(IRegistry *from, std::string_view objPath)=0
Remove a link to another object.
std::move
T move(T... args)
AtlasMCRecoFullPrecedenceDump.path
path
Definition: AtlasMCRecoFullPrecedenceDump.py:49
IDataProviderSvc::linkObject
StatusCode linkObject(std::string_view fromPath, std::string_view objPath, DataObject *toObj)
Add a link to another object.
Definition: IDataProviderSvc.h:489
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:314
IDataProviderSvc::findObject
StatusCode findObject(DataObject *parentObj, int item, DataObject *&pObject)
Find object identified by its parent object and an integer identifier in the data store.
Definition: IDataProviderSvc.h:373
IDataProviderSvc::registerObject
virtual StatusCode registerObject(std::string_view parentPath, std::string_view objectPath, DataObject *pObject)=0
Register object with the data store.
IOpaqueAddress
Definition: IOpaqueAddress.h:33
IDataProviderSvc::retrieveObject
StatusCode retrieveObject(std::string_view parentPath, int item, DataObject *&pObject)
Retrieve object from data store.
Definition: IDataProviderSvc.h:273
IDataProviderSvc::unregisterObject
virtual StatusCode unregisterObject(DataObject *pParent, std::string_view objPath)=0
Unregister object from the data store.
IDataProviderSvc::retrieveObject
StatusCode retrieveObject(std::string_view fullPath, DataObject *&pObject)
Retrieve object identified by its full path from the data store.
Definition: IDataProviderSvc.h:243
IDataProviderSvc::unregisterObject
virtual StatusCode unregisterObject(DataObject *pObject)=0
Unregister object from the data store.
IDataProviderSvc::findObject
StatusCode findObject(DataObject *parentObj, std::string_view objectPath, DataObject *&pObject)
Find object identified by its parent object and the path to the object relative to the parent.
Definition: IDataProviderSvc.h:361
IRegistry
Definition: IRegistry.h:32
StatusCode::code_t
unsigned long code_t
type of StatusCode value
Definition: StatusCode.h:67
IDataProviderSvc::DeclareInterfaceID
DeclareInterfaceID(IDataProviderSvc, 4, 0)
InterfaceID.
IDataProviderSvc::itemToPath
static std::string itemToPath(int item)
Helper function to convert item numbers to path strings.
Definition: IDataProviderSvc.h:57
IDataProviderSvc::resetPreLoad
virtual StatusCode resetPreLoad()=0
Clear the preload list.
IDataProviderSvc::addPreLoadItem
virtual StatusCode addPreLoadItem(const DataStoreItem &item)=0
Add an item to the preload list.
IDataProviderSvc::findObject
StatusCode findObject(std::string_view parentPath, int item, DataObject *&pObject)
Find object identified by its parent object and an integer identifier in the data store.
Definition: IDataProviderSvc.h:348
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.
IDataProviderSvc::unlinkObject
virtual StatusCode unlinkObject(DataObject *fromObj, std::string_view objPath)=0
Remove a link to another object.
IDataProviderSvc::unregisterObject
StatusCode unregisterObject(DataObject *pParent, int item)
Unregister object from the data store.
Definition: IDataProviderSvc.h:219
StatusCode
Definition: StatusCode.h:65
IInterface.h
IDataProviderSvc::addPreLoadItem
StatusCode addPreLoadItem(std::string itemPath)
Add an item to the preload list.
Definition: IDataProviderSvc.h:443
IDataProviderSvc::registerObject
StatusCode registerObject(DataObject *parentObj, int item, DataObject *pObject)
Register object with the data store.
Definition: IDataProviderSvc.h:117
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.
std::to_string
T to_string(T... args)
IDataProviderSvc::unregisterObject
StatusCode unregisterObject(std::string_view parentPath, std::string_view objPath)
Unregister object from the data store.
Definition: IDataProviderSvc.h:150
IDataProviderSvc::preLoad
virtual StatusCode preLoad()=0
Load all preload items of the list.
IDataProviderSvc::retrieveObject
StatusCode retrieveObject(DataObject *parentObj, int item, DataObject *&pObject)
Retrieve object from data store.
Definition: IDataProviderSvc.h:301
IDataProviderSvc::updateObject
virtual StatusCode updateObject(DataObject *toUpdate)=0
Update object identified by its pointer.
IDataProviderSvc::registerObject
StatusCode registerObject(std::string_view parentPath, int item, DataObject *pObject)
Register object with the data store.
Definition: IDataProviderSvc.h:95
SEPARATOR
constexpr char SEPARATOR
Definition: RegistryEntry.cpp:50
STATUSCODE_ENUM_DECL
#define STATUSCODE_ENUM_DECL(ENUM)
Declare an enum to be used as StatusCode value.
Definition: StatusCode.h:286
DataObject.h
IDataProviderSvc::unlinkObject
virtual StatusCode unlinkObject(std::string_view fullPath)=0
Remove a link to another object.
std
STL namespace.
IInterface
Definition: IInterface.h:239
DataObject
Definition: DataObject.h:36
IDataProviderSvc::unlinkObject
StatusCode unlinkObject(std::string_view fromPath, std::string_view objPath)
Remove a link to another object.
Definition: IDataProviderSvc.h:532
IDataProviderSvc::updateObject
StatusCode updateObject(std::string_view parentPath, std::string_view updatePath)
Update object identified by its parent's path and the path relative to the parent.
Definition: IDataProviderSvc.h:412
IDataProviderSvc::updateObject
StatusCode updateObject(std::string_view fullPath)
Update object identified by its full path in the data store.
Definition: IDataProviderSvc.h:390
IDataProviderSvc
Definition: IDataProviderSvc.h:53
IDataProviderSvc::Status
Status
Status code definitions.
Definition: IDataProviderSvc.h:558
IDataProviderSvc::findObject
virtual StatusCode findObject(std::string_view fullPath, DataObject *&pObject)=0
Find object identified by its full path in the data store.
IDataProviderSvc::linkObject
virtual StatusCode linkObject(std::string_view fullPath, DataObject *toObj)=0
Add a link to another object.
DataObject::registry
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:78
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:81
IDataProviderSvc::retrieveObject
StatusCode retrieveObject(DataObject *parentObj, std::string_view objectPath, DataObject *&pObject)
Retrieve object from data store.
Definition: IDataProviderSvc.h:287
IDataProviderSvc::updateObject
virtual StatusCode updateObject(IRegistry *pDirectory)=0
Update object identified by its directory entry.
IDataProviderSvc::findObject
virtual StatusCode findObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject)=0
Find object identified by its directory entry.
IDataProviderSvc::findObject
StatusCode findObject(std::string_view parentPath, std::string_view objectPath, DataObject *&pObject)
Find object identified by its parent object and the path to the object relative to the parent.
Definition: IDataProviderSvc.h:334
IDataProviderSvc::retrieveObject
StatusCode retrieveObject(std::string_view parentPath, std::string_view objectPath, DataObject *&pObject)
Retrieve object from data store.
Definition: IDataProviderSvc.h:257
IDataProviderSvc::removePreLoadItem
StatusCode removePreLoadItem(std::string itemPath)
Remove an item from the preload list.
Definition: IDataProviderSvc.h:457