The Gaudi Framework  v30r4 (9b837755)
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 "boost/utility/string_ref.hpp"
9 #include <string>
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 {
45 
47  // /// i.e. int -> "/" + int
48  static inline std::string itemToPath( int item ) { return '/' + std::to_string( item ); }
49 public:
52 
53  enum { SEPARATOR = '/' };
54 
62  StatusCode registerObject( boost::string_ref fullPath, DataObject* pObject )
63  {
64  return registerObject( nullptr, fullPath, pObject );
65  }
66 
75  virtual StatusCode registerObject( boost::string_ref parentPath, boost::string_ref objectPath,
76  DataObject* pObject ) = 0;
77 
86  StatusCode registerObject( boost::string_ref parentPath, int item, DataObject* pObject )
87  {
88  return registerObject( parentPath, itemToPath( item ), pObject );
89  }
90 
99  virtual StatusCode registerObject( DataObject* parentObj, boost::string_ref objectPath, DataObject* pObject ) = 0;
100 
109  StatusCode registerObject( DataObject* parentObj, int item, DataObject* pObject )
110  {
111  return registerObject( parentObj, itemToPath( item ), pObject );
112  }
113 
127  virtual StatusCode unregisterObject( boost::string_ref fullPath ) = 0;
128 
143  StatusCode unregisterObject( boost::string_ref parentPath, boost::string_ref objPath )
144  {
145  DataObject* pO = nullptr;
146  StatusCode status = findObject( parentPath, pO );
147  return status.isSuccess() ? unregisterObject( pO, objPath ) : status;
148  }
149 
164  StatusCode unregisterObject( boost::string_ref parentPath, int item )
165  {
166  return unregisterObject( parentPath, itemToPath( item ) );
167  }
168 
182  virtual StatusCode unregisterObject( DataObject* pObject ) = 0;
183 
198  virtual StatusCode unregisterObject( DataObject* pParent, boost::string_ref objPath ) = 0;
199 
214  StatusCode unregisterObject( DataObject* pParent, int item )
215  {
216  return unregisterObject( pParent, itemToPath( item ) );
217  }
218 
229  virtual StatusCode retrieveObject( IRegistry* pDirectory, boost::string_ref path, DataObject*& pObject ) = 0;
230 
239  StatusCode retrieveObject( boost::string_ref fullPath, DataObject*& pObject )
240  {
241  return retrieveObject( static_cast<IRegistry*>( nullptr ), fullPath, pObject );
242  }
243 
254  StatusCode retrieveObject( boost::string_ref parentPath, boost::string_ref objectPath, DataObject*& pObject )
255  {
256  DataObject* parent = nullptr;
257  StatusCode status = retrieveObject( parentPath, parent );
258  return status.isSuccess() ? retrieveObject( parent, objectPath, pObject ) : status;
259  }
260 
271  StatusCode retrieveObject( boost::string_ref parentPath, int item, DataObject*& pObject )
272  {
273  return retrieveObject( parentPath, itemToPath( item ), pObject );
274  }
275 
286  StatusCode retrieveObject( DataObject* parentObj, boost::string_ref objectPath, DataObject*& pObject )
287  {
288  return retrieveObject( parentObj ? parentObj->registry() : nullptr, objectPath, pObject );
289  }
290 
301  StatusCode retrieveObject( DataObject* parentObj, int item, DataObject*& pObject )
302  {
303  return retrieveObject( parentObj, itemToPath( item ), pObject );
304  }
305 
315  virtual StatusCode findObject( IRegistry* pDirectory, boost::string_ref path, DataObject*& pObject ) = 0;
316 
324  virtual StatusCode findObject( boost::string_ref fullPath, DataObject*& pObject ) = 0;
325 
335  StatusCode findObject( boost::string_ref parentPath, boost::string_ref objectPath, DataObject*& pObject )
336  {
337  DataObject* parent = nullptr;
338  StatusCode status = findObject( parentPath, parent );
339  return status.isSuccess() ? findObject( parent, objectPath, pObject ) : status;
340  }
341 
350  StatusCode findObject( boost::string_ref parentPath, int item, DataObject*& pObject )
351  {
352  return findObject( parentPath, itemToPath( item ), pObject );
353  }
354 
364  StatusCode findObject( DataObject* parentObj, boost::string_ref objectPath, DataObject*& pObject )
365  {
366  return findObject( parentObj ? parentObj->registry() : nullptr, objectPath, pObject );
367  }
368 
377  StatusCode findObject( DataObject* parentObj, int item, DataObject*& pObject )
378  {
379  return findObject( parentObj, itemToPath( item ), pObject );
380  }
381 
387  virtual StatusCode updateObject( IRegistry* pDirectory ) = 0;
388 
395  StatusCode updateObject( boost::string_ref fullPath )
396  {
397  DataObject* pO = nullptr;
398  StatusCode status = findObject( fullPath, pO );
399  return status.isSuccess() ? updateObject( pO ) : retrieveObject( fullPath, pO );
400  }
401 
408  virtual StatusCode updateObject( DataObject* toUpdate ) = 0;
409 
418  StatusCode updateObject( boost::string_ref parentPath, boost::string_ref updatePath )
419  {
420  DataObject* pParent = nullptr;
421  StatusCode status = findObject( parentPath, pParent );
422  return status.isSuccess() ? updateObject( pParent, updatePath ) : status;
423  }
424 
433  StatusCode updateObject( DataObject* pParent, boost::string_ref updatePath )
434  {
435  DataObject* pObject = nullptr;
436  StatusCode status = findObject( pParent, updatePath, pObject );
437  return status.isSuccess() ? updateObject( pObject ) : status;
438  }
439 
444  virtual StatusCode addPreLoadItem( const DataStoreItem& item ) = 0;
445 
452  {
453  return addPreLoadItem( DataStoreItem( std::move( itemPath ), 1 ) );
454  }
455 
460  virtual StatusCode removePreLoadItem( const DataStoreItem& item ) = 0;
461 
467  {
468  return removePreLoadItem( DataStoreItem( std::move( itemPath ), 1 ) );
469  }
470 
474  virtual StatusCode resetPreLoad() = 0;
475 
479  virtual StatusCode preLoad() = 0;
480 
489  virtual StatusCode linkObject( IRegistry* from, boost::string_ref objPath, DataObject* toObj ) = 0;
490 
499  StatusCode linkObject( boost::string_ref fromPath, boost::string_ref objPath, DataObject* toObj )
500  {
501  DataObject* pO = nullptr;
502  StatusCode status = retrieveObject( fromPath, pO );
503  return status.isSuccess() ? linkObject( pO->registry(), objPath, toObj ) : status;
504  }
505 
514  inline StatusCode linkObject( DataObject* fromObj, boost::string_ref objPath, DataObject* toObj );
515 
523  virtual StatusCode linkObject( boost::string_ref fullPath, DataObject* toObj ) = 0;
524 
533  virtual StatusCode unlinkObject( IRegistry* from, boost::string_ref objPath ) = 0;
534 
543  StatusCode unlinkObject( boost::string_ref fromPath, boost::string_ref objPath )
544  {
545  DataObject* pObject = nullptr;
546  StatusCode status = findObject( fromPath, pObject );
547  return status.isSuccess() ? unlinkObject( pObject->registry(), objPath ) : status;
548  }
549 
558  virtual StatusCode unlinkObject( DataObject* fromObj, boost::string_ref objPath ) = 0;
559 
567  virtual StatusCode unlinkObject( boost::string_ref fullPath ) = 0;
568 
570  enum class Status : StatusCode::code_t {
572  IDataProviderSvc_NO_ERROR = 1,
574  DOUBL_OBJ_PATH,
576  INVALID_OBJ_PATH,
578  INVALID_ROOT,
580  INVALID_OBJECT,
582  INVALID_PARENT,
584  OBJ_NOT_LOADED,
586  NO_DATA_LOADER,
588  INVALID_OBJ_ADDR,
590  DIR_NOT_EMPTY,
592  NO_MORE_LEVELS,
594  NO_ACCESS,
596  LAST
597  };
598 };
599 
601 
602 inline StatusCode IDataProviderSvc::linkObject( DataObject* fromObj, boost::string_ref objPath, DataObject* toObj )
603 {
604  if ( fromObj ) {
605  IRegistry* from_entry = fromObj->registry();
606  if ( from_entry ) return linkObject( from_entry, objPath, toObj );
607  }
608  return Status::INVALID_PARENT;
609 }
610 
611 #endif // GAUDIKERNEL_IDATAPROVIDERSVC_H
StatusCode findObject(boost::string_ref parentPath, boost::string_ref objectPath, DataObject *&pObject)
Find object identified by its parent object and the path to the object relative to the parent...
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.
bool isSuccess() const
Definition: StatusCode.h:287
StatusCode unlinkObject(boost::string_ref fromPath, boost::string_ref objPath)
Remove a link to another object.
T to_string(T...args)
#define STATUSCODE_ENUM_DECL(ENUM)
Declare an enum to be used as StatusCode value.
Definition: StatusCode.h:258
StatusCode retrieveObject(boost::string_ref parentPath, boost::string_ref objectPath, DataObject *&pObject)
Retrieve object from data store.
Status
Status code definitions.
StatusCode retrieveObject(DataObject *parentObj, boost::string_ref objectPath, DataObject *&pObject)
Retrieve object from data store.
Data provider interface definition.
Description of the DataStoreItem class.
Definition: DataStoreItem.h:17
StatusCode updateObject(DataObject *pParent, boost::string_ref updatePath)
Update object identified by its parent&#39;s pointer and the path relative to the parent.
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:73
StatusCode findObject(DataObject *parentObj, boost::string_ref objectPath, DataObject *&pObject)
Find object identified by its parent object and the path to the object relative to the parent...
StatusCode linkObject(boost::string_ref fromPath, boost::string_ref objPath, DataObject *toObj)
Add a link to another object.
STL class.
StatusCode findObject(boost::string_ref parentPath, int item, DataObject *&pObject)
Find object identified by its parent object and an integer identifier in the data store...
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
#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 updateObject(boost::string_ref fullPath)
Update object identified by its full path in the data store.
Definition of the basic interface.
Definition: IInterface.h:277
StatusCode addPreLoadItem(std::string itemPath)
Add an item to the preload list.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
T move(T...args)
StatusCode retrieveObject(boost::string_ref fullPath, DataObject *&pObject)
Retrieve object identified by its full path from the data store.
StatusCode retrieveObject(DataObject *parentObj, int item, DataObject *&pObject)
Retrieve object from data store.
StatusCode registerObject(boost::string_ref fullPath, DataObject *pObject)
Register object with the data store.
StatusCode updateObject(boost::string_ref parentPath, boost::string_ref updatePath)
Update object identified by its parent&#39;s path and the path relative to the parent.
StatusCode unregisterObject(DataObject *pParent, int item)
Unregister object from the data store.
StatusCode unregisterObject(boost::string_ref parentPath, boost::string_ref objPath)
Unregister object from the data store.
Opaque address interface definition.
StatusCode retrieveObject(boost::string_ref parentPath, int item, DataObject *&pObject)
Retrieve object from data store.
#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 unregisterObject(boost::string_ref parentPath, int item)
Unregister object from the data store.
StatusCode removePreLoadItem(std::string itemPath)
Remove an item from the preload list.
unsigned long code_t
type of StatusCode value
Definition: StatusCode.h:54
StatusCode registerObject(boost::string_ref parentPath, int item, DataObject *pObject)
Register object with the data store.