The Gaudi Framework  v32r2 (46d42edc)
IDataProviderSvc.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_IDATAPROVIDERSVC_H
2 #define GAUDIKERNEL_IDATAPROVIDERSVC_H
3 
4 // Framework include files
6 
7 // C/C++ include files
8 #include <string>
9 #include <string_view>
10 
11 // Forward declarations
12 class IOpaqueAddress;
13 class IRegistry;
14 #include "GaudiKernel/DataObject.h"
16 
43 class GAUDI_API IDataProviderSvc : virtual public IInterface {
44 
46  // /// i.e. int -> "/" + int
47  static inline std::string itemToPath( int item ) { return '/' + std::to_string( item ); }
48 
49 public:
52 
53  enum { SEPARATOR = '/' };
54 
62  StatusCode registerObject( std::string_view fullPath, DataObject* pObject ) {
63  return registerObject( nullptr, fullPath, pObject );
64  }
65 
74  virtual StatusCode registerObject( std::string_view parentPath, std::string_view objectPath,
75  DataObject* pObject ) = 0;
76 
85  StatusCode registerObject( std::string_view parentPath, int item, DataObject* pObject ) {
86  return registerObject( parentPath, itemToPath( item ), pObject );
87  }
88 
97  virtual StatusCode registerObject( DataObject* parentObj, std::string_view objectPath, DataObject* pObject ) = 0;
98 
107  StatusCode registerObject( DataObject* parentObj, int item, DataObject* pObject ) {
108  return registerObject( parentObj, itemToPath( item ), pObject );
109  }
110 
124  virtual StatusCode unregisterObject( std::string_view fullPath ) = 0;
125 
140  StatusCode unregisterObject( std::string_view parentPath, std::string_view objPath ) {
141  DataObject* pO = nullptr;
142  StatusCode status = findObject( parentPath, pO );
143  return status.isSuccess() ? unregisterObject( pO, objPath ) : status;
144  }
145 
160  StatusCode unregisterObject( std::string_view parentPath, int item ) {
161  return unregisterObject( parentPath, itemToPath( item ) );
162  }
163 
177  virtual StatusCode unregisterObject( DataObject* pObject ) = 0;
178 
193  virtual StatusCode unregisterObject( DataObject* pParent, std::string_view objPath ) = 0;
194 
209  StatusCode unregisterObject( DataObject* pParent, int item ) {
210  return unregisterObject( pParent, itemToPath( item ) );
211  }
212 
223  virtual StatusCode retrieveObject( IRegistry* pDirectory, std::string_view path, DataObject*& pObject ) = 0;
224 
233  StatusCode retrieveObject( std::string_view fullPath, DataObject*& pObject ) {
234  return retrieveObject( static_cast<IRegistry*>( nullptr ), fullPath, pObject );
235  }
236 
247  StatusCode retrieveObject( std::string_view parentPath, std::string_view objectPath, DataObject*& pObject ) {
248  DataObject* parent = nullptr;
249  StatusCode status = retrieveObject( parentPath, parent );
250  return status.isSuccess() ? retrieveObject( parent, objectPath, pObject ) : status;
251  }
252 
263  StatusCode retrieveObject( std::string_view parentPath, int item, DataObject*& pObject ) {
264  return retrieveObject( parentPath, itemToPath( item ), pObject );
265  }
266 
277  StatusCode retrieveObject( DataObject* parentObj, std::string_view objectPath, DataObject*& pObject ) {
278  return retrieveObject( parentObj ? parentObj->registry() : nullptr, objectPath, pObject );
279  }
280 
291  StatusCode retrieveObject( DataObject* parentObj, int item, DataObject*& pObject ) {
292  return retrieveObject( parentObj, itemToPath( item ), pObject );
293  }
294 
304  virtual StatusCode findObject( IRegistry* pDirectory, std::string_view path, DataObject*& pObject ) = 0;
305 
313  virtual StatusCode findObject( std::string_view fullPath, DataObject*& pObject ) = 0;
314 
324  StatusCode findObject( std::string_view parentPath, std::string_view objectPath, DataObject*& pObject ) {
325  DataObject* parent = nullptr;
326  StatusCode status = findObject( parentPath, parent );
327  return status.isSuccess() ? findObject( parent, objectPath, pObject ) : status;
328  }
329 
338  StatusCode findObject( std::string_view parentPath, int item, DataObject*& pObject ) {
339  return findObject( parentPath, itemToPath( item ), pObject );
340  }
341 
351  StatusCode findObject( DataObject* parentObj, std::string_view objectPath, DataObject*& pObject ) {
352  return findObject( parentObj ? parentObj->registry() : nullptr, objectPath, pObject );
353  }
354 
363  StatusCode findObject( DataObject* parentObj, int item, DataObject*& pObject ) {
364  return findObject( parentObj, itemToPath( item ), pObject );
365  }
366 
372  virtual StatusCode updateObject( IRegistry* pDirectory ) = 0;
373 
380  StatusCode updateObject( std::string_view fullPath ) {
381  DataObject* pO = nullptr;
382  StatusCode status = findObject( fullPath, pO );
383  return status.isSuccess() ? updateObject( pO ) : retrieveObject( fullPath, pO );
384  }
385 
392  virtual StatusCode updateObject( DataObject* toUpdate ) = 0;
393 
402  StatusCode updateObject( std::string_view parentPath, std::string_view updatePath ) {
403  DataObject* pParent = nullptr;
404  StatusCode status = findObject( parentPath, pParent );
405  return status.isSuccess() ? updateObject( pParent, updatePath ) : status;
406  }
407 
416  StatusCode updateObject( DataObject* pParent, std::string_view updatePath ) {
417  DataObject* pObject = nullptr;
418  StatusCode status = findObject( pParent, updatePath, pObject );
419  return status.isSuccess() ? updateObject( pObject ) : status;
420  }
421 
426  virtual StatusCode addPreLoadItem( const DataStoreItem& item ) = 0;
427 
434  return addPreLoadItem( DataStoreItem( std::move( itemPath ), 1 ) );
435  }
436 
441  virtual StatusCode removePreLoadItem( const DataStoreItem& item ) = 0;
442 
448  return removePreLoadItem( DataStoreItem( std::move( itemPath ), 1 ) );
449  }
450 
454  virtual StatusCode resetPreLoad() = 0;
455 
459  virtual StatusCode preLoad() = 0;
460 
469  virtual StatusCode linkObject( IRegistry* from, std::string_view objPath, DataObject* toObj ) = 0;
470 
479  StatusCode linkObject( std::string_view fromPath, std::string_view objPath, DataObject* toObj ) {
480  DataObject* pO = nullptr;
481  StatusCode status = retrieveObject( fromPath, pO );
482  return status.isSuccess() ? linkObject( pO->registry(), objPath, toObj ) : status;
483  }
484 
493  inline StatusCode linkObject( DataObject* fromObj, std::string_view objPath, DataObject* toObj );
494 
502  virtual StatusCode linkObject( std::string_view fullPath, DataObject* toObj ) = 0;
503 
512  virtual StatusCode unlinkObject( IRegistry* from, std::string_view objPath ) = 0;
513 
522  StatusCode unlinkObject( std::string_view fromPath, std::string_view objPath ) {
523  DataObject* pObject = nullptr;
524  StatusCode status = findObject( fromPath, pObject );
525  return status.isSuccess() ? unlinkObject( pObject->registry(), objPath ) : status;
526  }
527 
536  virtual StatusCode unlinkObject( DataObject* fromObj, std::string_view objPath ) = 0;
537 
545  virtual StatusCode unlinkObject( std::string_view fullPath ) = 0;
546 
548  enum class Status : StatusCode::code_t {
550  IDataProviderSvc_NO_ERROR = 1,
552  DOUBL_OBJ_PATH,
554  INVALID_OBJ_PATH,
556  INVALID_ROOT,
558  INVALID_OBJECT,
560  INVALID_PARENT,
562  OBJ_NOT_LOADED,
564  NO_DATA_LOADER,
566  INVALID_OBJ_ADDR,
568  DIR_NOT_EMPTY,
570  NO_MORE_LEVELS,
572  NO_ACCESS,
574  LAST
575  };
576 };
577 
579 
580 inline StatusCode IDataProviderSvc::linkObject( DataObject* fromObj, std::string_view objPath, DataObject* toObj ) {
581  if ( fromObj ) {
582  IRegistry* from_entry = fromObj->registry();
583  if ( from_entry ) return linkObject( from_entry, objPath, toObj );
584  }
585  return Status::INVALID_PARENT;
586 }
587 
588 #endif // GAUDIKERNEL_IDATAPROVIDERSVC_H
StatusCode retrieveObject(std::string_view parentPath, int item, DataObject *&pObject)
Retrieve object from data store.
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:72
StatusCode findObject(DataObject *parentObj, int item, DataObject *&pObject)
Find object identified by its parent object and an integer identifier in the data store.
constexpr char SEPARATOR
StatusCode registerObject(DataObject *parentObj, int item, DataObject *pObject)
Register object with the data store.
static std::string itemToPath(int item)
Helper function to convert item numbers to path strings.
StatusCode updateObject(DataObject *pParent, std::string_view updatePath)
Update object identified by its parent's pointer and the path relative to the parent.
T to_string(T... args)
STL namespace.
StatusCode unlinkObject(std::string_view fromPath, std::string_view objPath)
Remove a link to another object.
Status
Status code definitions.
Data provider interface definition.
StatusCode registerObject(std::string_view parentPath, int item, DataObject *pObject)
Register object with the data store.
Description of the DataStoreItem class.
Definition: DataStoreItem.h:17
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.
STL class.
#define STATUSCODE_ENUM_DECL(ENUM)
Declare an enum to be used as StatusCode value.
Definition: StatusCode.h:239
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
Definition of the basic interface.
Definition: IInterface.h:244
StatusCode addPreLoadItem(std::string itemPath)
Add an item to the preload list.
StatusCode retrieveObject(std::string_view parentPath, std::string_view objectPath, DataObject *&pObject)
Retrieve object from data store.
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.
StatusCode updateObject(std::string_view fullPath)
Update object identified by its full path in the data store.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
StatusCode linkObject(std::string_view fromPath, std::string_view objPath, DataObject *toObj)
Add a link to another object.
StatusCode unregisterObject(std::string_view parentPath, int item)
Unregister object from the data store.
bool isSuccess() const
Definition: StatusCode.h:267
T move(T... args)
StatusCode unregisterObject(std::string_view parentPath, std::string_view objPath)
Unregister object from the data store.
StatusCode retrieveObject(DataObject *parentObj, int item, DataObject *&pObject)
Retrieve object from data store.
#define DeclareInterfaceID(iface, major, minor)
Macro to declare the interface ID when using the new mechanism of extending and implementing interfac...
Definition: IInterface.h:13
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.
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.
StatusCode retrieveObject(DataObject *parentObj, std::string_view objectPath, DataObject *&pObject)
Retrieve object from data store.
StatusCode registerObject(std::string_view fullPath, DataObject *pObject)
Register object with the data store.
StatusCode retrieveObject(std::string_view fullPath, DataObject *&pObject)
Retrieve object identified by its full path from the data store.
StatusCode unregisterObject(DataObject *pParent, int item)
Unregister object from the data store.
Opaque address interface definition.
#define GAUDI_API
Definition: Kernel.h:71
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
StatusCode removePreLoadItem(std::string itemPath)
Remove an item from the preload list.
unsigned long code_t
type of StatusCode value
Definition: StatusCode.h:52