The Gaudi Framework  master (37c0b60a)
SmartDataStorePtr< TYPE, LOADER > Class Template Reference

A small class used to access easily (and efficiently) data items residing in data stores. More...

#include </builds/gaudi/Gaudi/GaudiKernel/include/GaudiKernel/SmartDataStorePtr.h>

Inheritance diagram for SmartDataStorePtr< TYPE, LOADER >:
Collaboration diagram for SmartDataStorePtr< TYPE, LOADER >:

Public Member Functions

 SmartDataStorePtr (IDataProviderSvc *pService, IRegistry *pRegistry, std::string path)
 Standard constructor: Construct an SmartDataStorePtr instance which is able to connect to a DataObject instance which is identified by its directory entry. More...
 
 SmartDataStorePtr (const SmartDataObjectPtr &copy)
 Copy constructor: Construct a copy of a SmartDataStorePtr instance. More...
 
virtual ~SmartDataStorePtr ()=default
 Standard Destructor. More...
 
SmartDataStorePtroperator= (DataObject *pObj)
 Automatic conversion to data type. More...
 
SmartDataStorePtroperator= (const DataObject *pObj)
 Automatic conversion to data type. More...
 
SmartDataStorePtroperator= (const SmartDataObjectPtr &copy) override
 unhides assignment operator of base class More...
 
TYPE * ptr ()
 Automatic conversion to data type. More...
 
TYPE * operator-> ()
 Dereference operator: the heart of the smart pointer. More...
 
TYPE & operator* ()
 Dereference operator: the heart of the smart pointer. More...
 
 operator TYPE * ()
 Automatic conversion to data type. More...
 
 operator TYPE & ()
 Automatic conversion to data type. More...
 
 operator int ()
 operator int for statements like: if ( SmartDataStorePtr<XXX>(...) ) {} More...
 
bool operator! ()
 operator ! for statements like: if ( !SmartDataStorePtr<XXX>(...) ) {} More...
 
TYPE * accessTypeSafeData ()
 Internal type safe accessor to data. More...
 
- Public Member Functions inherited from SmartDataObjectPtr
 SmartDataObjectPtr (AccessFunction access, IDataProviderSvc *pService, IRegistry *pDir, std::string path)
 Standard constructor: Construct an SmartDataObjectPtr instance. More...
 
 SmartDataObjectPtr (const SmartDataObjectPtr &)=default
 Copy constructor: Construct an copy of a SmartDataStorePtr instance. More...
 
virtual ~SmartDataObjectPtr ()=default
 Standard Destructor. More...
 
 operator IRegistry * ()
 Automatic conversion to data directory. More...
 
const std::stringpath () const
 Path name. More...
 
IRegistrydirectory ()
 Access to data directory. More...
 
void setService (IDataProviderSvc *svc)
 Assign data service. More...
 
IDataProviderSvcservice ()
 Retrieve data service. More...
 
const StatusCodegetLastError () const
 Access to potential errors during data accesses. More...
 
DataObjectaccessData ()
 Static Object retrieval method: must call specific function. More...
 
DataObjectretrieveObject ()
 Object retrieve method. More...
 
DataObjectfindObject ()
 Object find method. More...
 
DataObjectupdateObject ()
 Object update method. More...
 

Protected Attributes

TYPE * m_pObject
 Pointer to data store object. More...
 
- Protected Attributes inherited from SmartDataObjectPtr
IDataProviderSvcm_dataProvider = nullptr
 Pointer to contained object. More...
 
IRegistrym_pRegistry = nullptr
 Pointer to the data registry containing the object. More...
 
StatusCode m_status = StatusCode::SUCCESS
 Keep track of the last error. More...
 
std::string m_path
 Path to object. More...
 
AccessFunction m_accessFunc = nullptr
 Data access function. More...
 

Additional Inherited Members

- Public Types inherited from SmartDataObjectPtr
using AccessFunction = DataObject *(*)(SmartDataObjectPtr *ptr)
 
- Static Public Member Functions inherited from SmartDataObjectPtr
static DataObjectretrieve (SmartDataObjectPtr *ptr)
 Static Object retrieval method. More...
 
static DataObjectfind (SmartDataObjectPtr *ptr)
 Static Object find method. More...
 
static DataObjectupdate (SmartDataObjectPtr *ptr)
 Static Object update method. More...
 
- Protected Member Functions inherited from SmartDataObjectPtr
StatusCode find (IRegistry *pDirectory, std::string_view path, DataObject *&refpObject)
 Find the specified object from the data store. More...
 
StatusCode find (std::string_view fullPath, DataObject *&refpObject)
 Find the specified object from the data store. More...
 
StatusCode retrieve (IRegistry *pDirectory, std::string_view path, DataObject *&refpObject)
 Retrieve the specified object from the data store. More...
 
StatusCode retrieve (std::string_view fullPath, DataObject *&refpObject)
 Retrieve the specified object from the data store. More...
 
StatusCode update (IRegistry *pDirectory)
 Update the specified object from the data store. More...
 
StatusCode update (std::string_view fullPath)
 Update the specified object from the data store. More...
 

Detailed Description

template<class TYPE, class LOADER>
class SmartDataStorePtr< TYPE, LOADER >

A small class used to access easily (and efficiently) data items residing in data stores.

The class constructors take several arguments neccessary to be passed to the data services in order to automatically load objects in case they are not yet loaded. This is achieved through a smart pointer mechanism i.e. by overloading the operator->() at dereferencing time the object will be requested from the store.

The SmartDataStorePtr is meant to be "short living". It only makes sense to keep an object instance within e.g. the scope of one method. "long living" instances do not make sense and in the contrary would be harmful, because the information passed during construction would be invalid and returned object pointers would actually point to hyperspace.

The intrinsic functionality, whether the object will be retrieved or loaded from the data store is defined by the LOADER::.

Base Class: SmartDataObjectPtr

Author
M.Frank
Version
1.0

Definition at line 55 of file SmartDataStorePtr.h.

Constructor & Destructor Documentation

◆ SmartDataStorePtr() [1/2]

template<class TYPE , class LOADER >
SmartDataStorePtr< TYPE, LOADER >::SmartDataStorePtr ( IDataProviderSvc pService,
IRegistry pRegistry,
std::string  path 
)
inline

Standard constructor: Construct an SmartDataStorePtr instance which is able to connect to a DataObject instance which is identified by its directory entry.

FASTEST ACCESS TO THE DATA STORE ***

Parameters
pServicePointer to the data service interface which should be used to load the object.
pDirectoryPointer to the data directory entry.

Definition at line 65 of file SmartDataStorePtr.h.

66  : SmartDataObjectPtr( LOADER::access(), pService, pRegistry, std::move( path ) ), m_pObject( nullptr ) {}

◆ SmartDataStorePtr() [2/2]

template<class TYPE , class LOADER >
SmartDataStorePtr< TYPE, LOADER >::SmartDataStorePtr ( const SmartDataObjectPtr copy)
inline

Copy constructor: Construct a copy of a SmartDataStorePtr instance.

Parameters
copyCopy of Smart Pointer to object.

Definition at line 70 of file SmartDataStorePtr.h.

70 : SmartDataObjectPtr( copy ), m_pObject( nullptr ) {}

◆ ~SmartDataStorePtr()

template<class TYPE , class LOADER >
virtual SmartDataStorePtr< TYPE, LOADER >::~SmartDataStorePtr ( )
virtualdefault

Standard Destructor.

Member Function Documentation

◆ accessTypeSafeData()

template<class TYPE , class LOADER >
TYPE* SmartDataStorePtr< TYPE, LOADER >::accessTypeSafeData ( )
inline

Internal type safe accessor to data.

Definition at line 121 of file SmartDataStorePtr.h.

121  {
122  if ( 0 == m_pObject ) { m_pObject = dynamic_cast<TYPE*>( accessData() ); }
123  return m_pObject;
124  }

◆ operator int()

template<class TYPE , class LOADER >
SmartDataStorePtr< TYPE, LOADER >::operator int ( )
inline

operator int for statements like: if ( SmartDataStorePtr<XXX>(...) ) {}

Definition at line 115 of file SmartDataStorePtr.h.

115 { return 0 != accessTypeSafeData(); }

◆ operator TYPE &()

template<class TYPE , class LOADER >
SmartDataStorePtr< TYPE, LOADER >::operator TYPE & ( )
inline

Automatic conversion to data type.

Definition at line 109 of file SmartDataStorePtr.h.

109  {
110  TYPE* result = accessTypeSafeData();
111  return *result;
112  }

◆ operator TYPE *()

template<class TYPE , class LOADER >
SmartDataStorePtr< TYPE, LOADER >::operator TYPE * ( )
inline

Automatic conversion to data type.

Definition at line 106 of file SmartDataStorePtr.h.

106 { return accessTypeSafeData(); }

◆ operator!()

template<class TYPE , class LOADER >
bool SmartDataStorePtr< TYPE, LOADER >::operator! ( )
inline

operator ! for statements like: if ( !SmartDataStorePtr<XXX>(...) ) {}

Definition at line 118 of file SmartDataStorePtr.h.

118 { return 0 == accessTypeSafeData(); }

◆ operator*()

template<class TYPE , class LOADER >
TYPE& SmartDataStorePtr< TYPE, LOADER >::operator* ( )
inline

Dereference operator: the heart of the smart pointer.

Definition at line 100 of file SmartDataStorePtr.h.

100  {
101  TYPE* result = accessTypeSafeData();
102  return *result;
103  }

◆ operator->()

template<class TYPE , class LOADER >
TYPE* SmartDataStorePtr< TYPE, LOADER >::operator-> ( )
inline

Dereference operator: the heart of the smart pointer.

Definition at line 97 of file SmartDataStorePtr.h.

97 { return accessTypeSafeData(); }

◆ operator=() [1/3]

template<class TYPE , class LOADER >
SmartDataStorePtr& SmartDataStorePtr< TYPE, LOADER >::operator= ( const DataObject pObj)
inline

Automatic conversion to data type.

Definition at line 82 of file SmartDataStorePtr.h.

82  {
83  m_pObject = dynamic_cast<TYPE*>( const_cast<DataObject*>( pObj ) );
84  return *this;
85  }

◆ operator=() [2/3]

template<class TYPE , class LOADER >
SmartDataStorePtr& SmartDataStorePtr< TYPE, LOADER >::operator= ( const SmartDataObjectPtr copy)
inlineoverridevirtual

unhides assignment operator of base class

Reimplemented from SmartDataObjectPtr.

Definition at line 88 of file SmartDataStorePtr.h.

88  {
89  this->m_pObject = dynamic_cast<TYPE*>( const_cast<SmartDataObjectPtr*>( &copy ) );
90  return *this;
91  }

◆ operator=() [3/3]

template<class TYPE , class LOADER >
SmartDataStorePtr& SmartDataStorePtr< TYPE, LOADER >::operator= ( DataObject pObj)
inline

Automatic conversion to data type.

Definition at line 76 of file SmartDataStorePtr.h.

76  {
77  m_pObject = dynamic_cast<TYPE*>( pObj );
78  return *this;
79  }

◆ ptr()

template<class TYPE , class LOADER >
TYPE* SmartDataStorePtr< TYPE, LOADER >::ptr ( )
inline

Automatic conversion to data type.

Definition at line 94 of file SmartDataStorePtr.h.

94 { return accessTypeSafeData(); }

Member Data Documentation

◆ m_pObject

template<class TYPE , class LOADER >
TYPE* SmartDataStorePtr< TYPE, LOADER >::m_pObject
mutableprotected

Pointer to data store object.

Definition at line 128 of file SmartDataStorePtr.h.


The documentation for this class was generated from the following file:
std::move
T move(T... args)
SmartDataStorePtr::accessTypeSafeData
TYPE * accessTypeSafeData()
Internal type safe accessor to data.
Definition: SmartDataStorePtr.h:121
SmartDataObjectPtr
Definition: SmartDataObjectPtr.h:42
std::copy
T copy(T... args)
SmartDataStorePtr::m_pObject
TYPE * m_pObject
Pointer to data store object.
Definition: SmartDataStorePtr.h:128
DataObject
Definition: DataObject.h:36
SmartDataObjectPtr::path
const std::string & path() const
Path name.
Definition: SmartDataObjectPtr.h:81
SmartDataObjectPtr::SmartDataObjectPtr
SmartDataObjectPtr(AccessFunction access, IDataProviderSvc *pService, IRegistry *pDir, std::string path)
Standard constructor: Construct an SmartDataObjectPtr instance.
Definition: SmartDataObjectPtr.h:64
SmartDataObjectPtr::accessData
DataObject * accessData()
Static Object retrieval method: must call specific function.
Definition: SmartDataObjectPtr.h:96