The Gaudi Framework  master (01b473db)
IDataProviderSvc.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2025 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 #pragma once
12 
13 #include <GaudiKernel/DataObject.h>
15 #include <GaudiKernel/IInterface.h>
16 #include <string>
17 #include <string_view>
18 
19 class IOpaqueAddress;
20 class IRegistry;
21 
48 class GAUDI_API IDataProviderSvc : virtual public IInterface {
49 
52  static inline std::string itemToPath( int item ) { return '/' + std::to_string( item ); }
53 
54 public:
57 
58  enum { SEPARATOR = '/' };
59 
67  StatusCode registerObject( std::string_view fullPath, DataObject* pObject ) {
68  return registerObject( nullptr, fullPath, pObject );
69  }
70 
79  virtual StatusCode registerObject( std::string_view parentPath, std::string_view objectPath,
80  DataObject* pObject ) = 0;
81 
90  StatusCode registerObject( std::string_view parentPath, int item, DataObject* pObject ) {
91  return registerObject( parentPath, itemToPath( item ), pObject );
92  }
93 
102  virtual StatusCode registerObject( DataObject* parentObj, std::string_view objectPath, DataObject* pObject ) = 0;
103 
112  StatusCode registerObject( DataObject* parentObj, int item, DataObject* pObject ) {
113  return registerObject( parentObj, itemToPath( item ), pObject );
114  }
115 
129  virtual StatusCode unregisterObject( std::string_view fullPath ) = 0;
130 
145  StatusCode unregisterObject( std::string_view parentPath, std::string_view objPath ) {
146  DataObject* pO = nullptr;
147  StatusCode status = findObject( parentPath, pO );
148  return status.isSuccess() ? unregisterObject( pO, objPath ) : status;
149  }
150 
165  StatusCode unregisterObject( std::string_view parentPath, int item ) {
166  return unregisterObject( parentPath, itemToPath( item ) );
167  }
168 
182  virtual StatusCode unregisterObject( DataObject* pObject ) = 0;
183 
198  virtual StatusCode unregisterObject( DataObject* pParent, std::string_view objPath ) = 0;
199 
214  StatusCode unregisterObject( DataObject* pParent, int item ) {
215  return unregisterObject( pParent, itemToPath( item ) );
216  }
217 
228  virtual StatusCode retrieveObject( IRegistry* pDirectory, std::string_view path, DataObject*& pObject ) = 0;
229 
238  StatusCode retrieveObject( std::string_view fullPath, DataObject*& pObject ) {
239  return retrieveObject( static_cast<IRegistry*>( nullptr ), fullPath, pObject );
240  }
241 
252  StatusCode retrieveObject( std::string_view parentPath, std::string_view objectPath, DataObject*& pObject ) {
253  DataObject* parent = nullptr;
254  StatusCode status = retrieveObject( parentPath, parent );
255  return status.isSuccess() ? retrieveObject( parent, objectPath, pObject ) : status;
256  }
257 
268  StatusCode retrieveObject( std::string_view parentPath, int item, DataObject*& pObject ) {
269  return retrieveObject( parentPath, itemToPath( item ), pObject );
270  }
271 
282  StatusCode retrieveObject( DataObject* parentObj, std::string_view objectPath, DataObject*& pObject ) {
283  return retrieveObject( parentObj ? parentObj->registry() : nullptr, objectPath, pObject );
284  }
285 
296  StatusCode retrieveObject( DataObject* parentObj, int item, DataObject*& pObject ) {
297  return retrieveObject( parentObj, itemToPath( item ), pObject );
298  }
299 
309  virtual StatusCode findObject( IRegistry* pDirectory, std::string_view path, DataObject*& pObject ) = 0;
310 
318  virtual StatusCode findObject( std::string_view fullPath, DataObject*& pObject ) = 0;
319 
329  StatusCode findObject( std::string_view parentPath, std::string_view objectPath, DataObject*& pObject ) {
330  DataObject* parent = nullptr;
331  StatusCode status = findObject( parentPath, parent );
332  return status.isSuccess() ? findObject( parent, objectPath, pObject ) : status;
333  }
334 
343  StatusCode findObject( std::string_view parentPath, int item, DataObject*& pObject ) {
344  return findObject( parentPath, itemToPath( item ), pObject );
345  }
346 
356  StatusCode findObject( DataObject* parentObj, std::string_view objectPath, DataObject*& pObject ) {
357  return findObject( parentObj ? parentObj->registry() : nullptr, objectPath, pObject );
358  }
359 
368  StatusCode findObject( DataObject* parentObj, int item, DataObject*& pObject ) {
369  return findObject( parentObj, itemToPath( item ), pObject );
370  }
371 
377  virtual StatusCode updateObject( IRegistry* pDirectory ) = 0;
378 
385  StatusCode updateObject( std::string_view fullPath ) {
386  DataObject* pO = nullptr;
387  StatusCode status = findObject( fullPath, pO );
388  return status.isSuccess() ? updateObject( pO ) : retrieveObject( fullPath, pO );
389  }
390 
397  virtual StatusCode updateObject( DataObject* toUpdate ) = 0;
398 
407  StatusCode updateObject( std::string_view parentPath, std::string_view updatePath ) {
408  DataObject* pParent = nullptr;
409  StatusCode status = findObject( parentPath, pParent );
410  return status.isSuccess() ? updateObject( pParent, updatePath ) : status;
411  }
412 
421  StatusCode updateObject( DataObject* pParent, std::string_view updatePath ) {
422  DataObject* pObject = nullptr;
423  StatusCode status = findObject( pParent, updatePath, pObject );
424  return status.isSuccess() ? updateObject( pObject ) : status;
425  }
426 
431  virtual StatusCode addPreLoadItem( const DataStoreItem& item ) = 0;
432 
438  StatusCode addPreLoadItem( std::string itemPath ) {
439  return addPreLoadItem( DataStoreItem( std::move( itemPath ), 1 ) );
440  }
441 
446  virtual StatusCode removePreLoadItem( const DataStoreItem& item ) = 0;
447 
452  StatusCode removePreLoadItem( std::string itemPath ) {
453  return removePreLoadItem( DataStoreItem( std::move( itemPath ), 1 ) );
454  }
455 
459  virtual StatusCode resetPreLoad() = 0;
460 
464  virtual StatusCode preLoad() = 0;
465 
474  virtual StatusCode linkObject( IRegistry* from, std::string_view objPath, DataObject* toObj ) = 0;
475 
484  StatusCode linkObject( std::string_view fromPath, std::string_view objPath, DataObject* toObj ) {
485  DataObject* pO = nullptr;
486  StatusCode status = retrieveObject( fromPath, pO );
487  return status.isSuccess() ? linkObject( pO->registry(), objPath, toObj ) : status;
488  }
489 
498  inline StatusCode linkObject( DataObject* fromObj, std::string_view objPath, DataObject* toObj );
499 
507  virtual StatusCode linkObject( std::string_view fullPath, DataObject* toObj ) = 0;
508 
517  virtual StatusCode unlinkObject( IRegistry* from, std::string_view objPath ) = 0;
518 
527  StatusCode unlinkObject( std::string_view fromPath, std::string_view objPath ) {
528  DataObject* pObject = nullptr;
529  StatusCode status = findObject( fromPath, pObject );
530  return status.isSuccess() ? unlinkObject( pObject->registry(), objPath ) : status;
531  }
532 
541  virtual StatusCode unlinkObject( DataObject* fromObj, std::string_view objPath ) = 0;
542 
550  virtual StatusCode unlinkObject( std::string_view fullPath ) = 0;
551 
553  enum class Status : StatusCode::code_t {
555  IDataProviderSvc_NO_ERROR = 1,
557  DOUBL_OBJ_PATH,
559  INVALID_OBJ_PATH,
561  INVALID_ROOT,
563  INVALID_OBJECT,
565  INVALID_PARENT,
567  OBJ_NOT_LOADED,
569  NO_DATA_LOADER,
571  INVALID_OBJ_ADDR,
573  DIR_NOT_EMPTY,
575  NO_MORE_LEVELS,
577  NO_ACCESS,
579  LAST
580  };
581 };
582 
584 
585 inline StatusCode IDataProviderSvc::linkObject( DataObject* fromObj, std::string_view objPath, DataObject* toObj ) {
586  if ( fromObj ) {
587  IRegistry* from_entry = fromObj->registry();
588  if ( from_entry ) return linkObject( from_entry, objPath, toObj );
589  }
590  return Status::INVALID_PARENT;
591 }
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:421
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:165
IDataProviderSvc::unregisterObject
virtual StatusCode unregisterObject(std::string_view fullPath)=0
Unregister object from the data store.
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.
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:484
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:314
GaudiPartProp.decorators.std
std
Definition: decorators.py:32
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:368
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:28
IDataProviderSvc::retrieveObject
StatusCode retrieveObject(std::string_view parentPath, int item, DataObject *&pObject)
Retrieve object from data store.
Definition: IDataProviderSvc.h:268
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:238
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:356
IRegistry
Definition: IRegistry.h:29
StatusCode::code_t
unsigned long code_t
type of StatusCode value
Definition: StatusCode.h:66
IDataProviderSvc::DeclareInterfaceID
DeclareInterfaceID(IDataProviderSvc, 4, 0)
InterfaceID.
IDataProviderSvc::itemToPath
static std::string itemToPath(int item)
Helper function to convert item numbers to path strings i.e.
Definition: IDataProviderSvc.h:52
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:343
IDataProviderSvc::registerObject
StatusCode registerObject(std::string_view fullPath, DataObject *pObject)
Register object with the data store.
Definition: IDataProviderSvc.h:67
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:214
StatusCode
Definition: StatusCode.h:64
IInterface.h
IDataProviderSvc::addPreLoadItem
StatusCode addPreLoadItem(std::string itemPath)
Add an item to the preload list.
Definition: IDataProviderSvc.h:438
IDataProviderSvc::registerObject
StatusCode registerObject(DataObject *parentObj, int item, DataObject *pObject)
Register object with the data store.
Definition: IDataProviderSvc.h:112
DataStoreItem
Definition: DataStoreItem.h:25
IDataProviderSvc::retrieveObject
virtual StatusCode retrieveObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject)=0
Retrieve object identified by its directory entry.
IDataProviderSvc::unregisterObject
StatusCode unregisterObject(std::string_view parentPath, std::string_view objPath)
Unregister object from the data store.
Definition: IDataProviderSvc.h:145
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:296
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:90
SEPARATOR
constexpr char SEPARATOR
Definition: RegistryEntry.cpp:25
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.
IInterface
Definition: IInterface.h:225
DataObject
Definition: DataObject.h:37
IDataProviderSvc::unlinkObject
StatusCode unlinkObject(std::string_view fromPath, std::string_view objPath)
Remove a link to another object.
Definition: IDataProviderSvc.h:527
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:407
IDataProviderSvc::updateObject
StatusCode updateObject(std::string_view fullPath)
Update object identified by its full path in the data store.
Definition: IDataProviderSvc.h:385
IDataProviderSvc
Definition: IDataProviderSvc.h:48
IDataProviderSvc::Status
Status
Status code definitions.
Definition: IDataProviderSvc.h:553
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:79
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:49
IDataProviderSvc::retrieveObject
StatusCode retrieveObject(DataObject *parentObj, std::string_view objectPath, DataObject *&pObject)
Retrieve object from data store.
Definition: IDataProviderSvc.h:282
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:329
IDataProviderSvc::retrieveObject
StatusCode retrieveObject(std::string_view parentPath, std::string_view objectPath, DataObject *&pObject)
Retrieve object from data store.
Definition: IDataProviderSvc.h:252
IDataProviderSvc::removePreLoadItem
StatusCode removePreLoadItem(std::string itemPath)
Remove an item from the preload list.
Definition: IDataProviderSvc.h:452