| The Gaudi Framework v32r1 (f65d50dc)

IDataProviderSvc.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_IDATAPROVIDERSVC_H
2 #define GAUDIKERNEL_IDATAPROVIDERSVC_H
3
4 // Framework include files
5 #include "GaudiKernel/IInterface.h"
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"
15 #include "GaudiKernel/DataStoreItem.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:
51 DeclareInterfaceID( IDataProviderSvc, 4, 0 );
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
433 StatusCode addPreLoadItem( std::string itemPath ) {
434 return addPreLoadItem( DataStoreItem( std::move( itemPath ), 1 ) );
435 }
436
441 virtual StatusCode removePreLoadItem( const DataStoreItem& item ) = 0;
442
447 StatusCode removePreLoadItem( std::string itemPath ) {
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
578 STATUSCODE_ENUM_DECL( IDataProviderSvc::Status )
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
IDataProviderSvc::retrieveObject
StatusCode retrieveObject(std::string_view parentPath, int item, DataObject *&pObject)
Retrieve object from data store.
Definition: IDataProviderSvc.h:263
DataObject::registry
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:72
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:363
GaudiPython.HistoUtils.path
path
Definition: HistoUtils.py:932
SEPARATOR
constexpr char SEPARATOR
Definition: RegistryEntry.cpp:40
IDataProviderSvc::registerObject
StatusCode registerObject(DataObject *parentObj, int item, DataObject *pObject)
Register object with the data store.
Definition: IDataProviderSvc.h:107
IDataProviderSvc::itemToPath
static std::string itemToPath(int item)
Helper function to convert item numbers to path strings.
Definition: IDataProviderSvc.h:47
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:416
std::to_string
T to_string(T... args)
std
STL namespace.
IDataProviderSvc::unlinkObject
StatusCode unlinkObject(std::string_view fromPath, std::string_view objPath)
Remove a link to another object.
Definition: IDataProviderSvc.h:522
IDataProviderSvc::Status
Status
Status code definitions.
Definition: IDataProviderSvc.h:548
IDataProviderSvc
Data provider interface definition.
Definition: IDataProviderSvc.h:43
IDataProviderSvc::registerObject
StatusCode registerObject(std::string_view parentPath, int item, DataObject *pObject)
Register object with the data store.
Definition: IDataProviderSvc.h:85
DataStoreItem
Description of the DataStoreItem class.
Definition: DataStoreItem.h:17
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:402
std::string
STL class.
DataStoreItem.h
STATUSCODE_ENUM_DECL
#define STATUSCODE_ENUM_DECL(ENUM)
Declare an enum to be used as StatusCode value.
Definition: StatusCode.h:239
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
IInterface
Definition of the basic interface.
Definition: IInterface.h:244
IDataProviderSvc::addPreLoadItem
StatusCode addPreLoadItem(std::string itemPath)
Add an item to the preload list.
Definition: IDataProviderSvc.h:433
IDataProviderSvc::retrieveObject
StatusCode retrieveObject(std::string_view parentPath, std::string_view objectPath, DataObject *&pObject)
Retrieve object from data store.
Definition: IDataProviderSvc.h:247
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:351
IDataProviderSvc::updateObject
StatusCode updateObject(std::string_view fullPath)
Update object identified by its full path in the data store.
Definition: IDataProviderSvc.h:380
IRegistry
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
IDataProviderSvc::linkObject
StatusCode linkObject(std::string_view fromPath, std::string_view objPath, DataObject *toObj)
Add a link to another object.
Definition: IDataProviderSvc.h:479
IDataProviderSvc::unregisterObject
StatusCode unregisterObject(std::string_view parentPath, int item)
Unregister object from the data store.
Definition: IDataProviderSvc.h:160
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:267
std::move
T move(T... args)
IDataProviderSvc::unregisterObject
StatusCode unregisterObject(std::string_view parentPath, std::string_view objPath)
Unregister object from the data store.
Definition: IDataProviderSvc.h:140
IDataProviderSvc::retrieveObject
StatusCode retrieveObject(DataObject *parentObj, int item, DataObject *&pObject)
Retrieve object from data store.
Definition: IDataProviderSvc.h:291
DeclareInterfaceID
#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
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:338
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:324
IDataProviderSvc::retrieveObject
StatusCode retrieveObject(DataObject *parentObj, std::string_view objectPath, DataObject *&pObject)
Retrieve object from data store.
Definition: IDataProviderSvc.h:277
IDataProviderSvc::registerObject
StatusCode registerObject(std::string_view fullPath, DataObject *pObject)
Register object with the data store.
Definition: IDataProviderSvc.h:62
IDataProviderSvc::retrieveObject
StatusCode retrieveObject(std::string_view fullPath, DataObject *&pObject)
Retrieve object identified by its full path from the data store.
Definition: IDataProviderSvc.h:233
IDataProviderSvc::unregisterObject
StatusCode unregisterObject(DataObject *pParent, int item)
Unregister object from the data store.
Definition: IDataProviderSvc.h:209
IOpaqueAddress
Opaque address interface definition.
Definition: IOpaqueAddress.h:23
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:71
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
IInterface.h
IDataProviderSvc::removePreLoadItem
StatusCode removePreLoadItem(std::string itemPath)
Remove an item from the preload list.
Definition: IDataProviderSvc.h:447
DataObject.h
StatusCode::code_t
unsigned long code_t
type of StatusCode value
Definition: StatusCode.h:52