The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
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
16#include <string>
17#include <string_view>
18
19class IOpaqueAddress;
20class IRegistry;
21
48class GAUDI_API IDataProviderSvc : virtual public IInterface {
49
52 static inline std::string itemToPath( int item ) { return '/' + std::to_string( item ); }
53
54public:
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
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
581};
582
584
585inline 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 }
591}
#define GAUDI_API
Definition Kernel.h:49
#define STATUSCODE_ENUM_DECL(ENUM)
Declare an enum to be used as StatusCode value.
Definition StatusCode.h:286
A DataObject is the base class of any identifiable object on any data store.
Definition DataObject.h:37
IRegistry * registry() const
Get pointer to Registry.
Definition DataObject.h:79
Description of the DataStoreItem class.
StatusCode linkObject(IRegistry *from, std::string_view objPath, DataObject *to) override
Add a link to another object.
Definition DataSvc.cpp:683
Data provider interface definition.
StatusCode retrieveObject(std::string_view fullPath, DataObject *&pObject)
Retrieve object identified by its full path from the data store.
static std::string itemToPath(int item)
Helper function to convert item numbers to path strings i.e.
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.
virtual StatusCode retrieveObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject)=0
Retrieve object identified by its directory entry.
virtual StatusCode updateObject(DataObject *toUpdate)=0
Update object identified by its pointer.
virtual StatusCode registerObject(std::string_view parentPath, std::string_view objectPath, DataObject *pObject)=0
Register object with the data store.
StatusCode findObject(DataObject *parentObj, int item, DataObject *&pObject)
Find object identified by its parent object and an integer identifier in the data store.
virtual StatusCode unlinkObject(DataObject *fromObj, std::string_view objPath)=0
Remove a link to another object.
virtual StatusCode linkObject(std::string_view fullPath, DataObject *toObj)=0
Add a link to another object.
StatusCode retrieveObject(std::string_view parentPath, std::string_view objectPath, DataObject *&pObject)
Retrieve object from data store.
StatusCode unregisterObject(DataObject *pParent, int item)
Unregister object from the data store.
StatusCode registerObject(std::string_view parentPath, int item, DataObject *pObject)
Register object with the data store.
virtual StatusCode linkObject(IRegistry *from, std::string_view objPath, DataObject *toObj)=0
Add a link to another object.
StatusCode addPreLoadItem(std::string itemPath)
Add an item to the preload list.
StatusCode unregisterObject(std::string_view parentPath, int item)
Unregister object from the data store.
virtual StatusCode unregisterObject(std::string_view fullPath)=0
Unregister object from the data store.
virtual StatusCode findObject(std::string_view fullPath, DataObject *&pObject)=0
Find object identified by its full path in the data store.
virtual StatusCode updateObject(IRegistry *pDirectory)=0
Update object identified by its directory entry.
StatusCode updateObject(std::string_view fullPath)
Update object identified by its full path in the data store.
virtual StatusCode unregisterObject(DataObject *pParent, std::string_view objPath)=0
Unregister object from the data store.
StatusCode retrieveObject(DataObject *parentObj, std::string_view objectPath, DataObject *&pObject)
Retrieve object from data store.
virtual StatusCode unlinkObject(std::string_view fullPath)=0
Remove a link to another object.
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.
virtual StatusCode addPreLoadItem(const DataStoreItem &item)=0
Add an item to the preload list.
virtual StatusCode unlinkObject(IRegistry *from, std::string_view objPath)=0
Remove a link to another object.
StatusCode registerObject(DataObject *parentObj, int item, DataObject *pObject)
Register object with the data store.
virtual StatusCode removePreLoadItem(const DataStoreItem &item)=0
Remove an item from the preload list.
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.
virtual StatusCode resetPreLoad()=0
Clear the preload list.
StatusCode unregisterObject(std::string_view parentPath, std::string_view objPath)
Unregister object from the data store.
Status
Status code definitions.
@ NO_DATA_LOADER
No data loader available.
@ INVALID_OBJ_ADDR
Invalid object address.
@ INVALID_OBJECT
Object pointer is invalid.
@ NO_MORE_LEVELS
Automatic data loading had to stop: maximum depth.
@ INVALID_OBJ_PATH
Invalid path from root to object request failed.
@ INVALID_ROOT
Invalid root path object cannot be retrieved or stored.
@ INVALID_PARENT
Pointer to parent object is not valid.
@ DOUBL_OBJ_PATH
The path for this objects is already in use.
@ OBJ_NOT_LOADED
Sorry, the requested object is not loaded.
@ NO_ACCESS
Access to the requested leaf is inhibited.
@ DIR_NOT_EMPTY
Directory entry is NOT empty.
virtual StatusCode unregisterObject(DataObject *pObject)=0
Unregister object from the data store.
StatusCode removePreLoadItem(std::string itemPath)
Remove an item from the preload list.
virtual StatusCode findObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject)=0
Find object identified by its directory entry.
virtual StatusCode preLoad()=0
Load all preload items of the list.
StatusCode unlinkObject(std::string_view fromPath, std::string_view objPath)
Remove a link to another object.
DeclareInterfaceID(IDataProviderSvc, 4, 0)
InterfaceID.
virtual StatusCode registerObject(DataObject *parentObj, std::string_view objectPath, DataObject *pObject)=0
Register object with the data store.
StatusCode retrieveObject(DataObject *parentObj, int item, DataObject *&pObject)
Retrieve object from data store.
StatusCode retrieveObject(std::string_view parentPath, int item, DataObject *&pObject)
Retrieve object from data store.
StatusCode linkObject(std::string_view fromPath, std::string_view objPath, DataObject *toObj)
Add a link to another object.
StatusCode updateObject(DataObject *pParent, std::string_view updatePath)
Update object identified by its parent's pointer and the path relative to the parent.
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 registerObject(std::string_view fullPath, DataObject *pObject)
Register object with the data store.
Definition of the basic interface.
Definition IInterface.h:225
Opaque address interface definition.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition IRegistry.h:29
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
unsigned long code_t
type of StatusCode value
Definition StatusCode.h:66
bool isSuccess() const
Definition StatusCode.h:314
STL namespace.