The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
SmartDataObjectPtr Class Reference

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

#include <GaudiKernel/SmartDataObjectPtr.h>

Inheritance diagram for SmartDataObjectPtr:
Collaboration diagram for SmartDataObjectPtr:

Classes

class  ObjectFinder
 Helper class to configure smart pointer functionality. More...
 
class  ObjectLoader
 Helper class to configure smart pointer functionality. More...
 

Public Types

using AccessFunction = DataObject* (*)( SmartDataObjectPtr* ptr )
 

Public Member Functions

 SmartDataObjectPtr (AccessFunction access, IDataProviderSvc *pService, IRegistry *pDir, std::string path)
 Standard constructor: Construct an SmartDataObjectPtr instance.
 
 SmartDataObjectPtr (const SmartDataObjectPtr &)=default
 Copy constructor: Construct an copy of a SmartDataStorePtr instance.
 
virtual ~SmartDataObjectPtr ()=default
 Standard Destructor.
 
virtual SmartDataObjectPtroperator= (const SmartDataObjectPtr &)=default
 Assignment operator.
 
 operator IRegistry * ()
 Automatic conversion to data directory.
 
const std::string & path () const
 Path name.
 
IRegistrydirectory ()
 Access to data directory.
 
void setService (IDataProviderSvc *svc)
 Assign data service.
 
IDataProviderSvcservice ()
 Retrieve data service.
 
const StatusCodegetLastError () const
 Access to potential errors during data accesses.
 
DataObjectaccessData ()
 Static Object retrieval method: must call specific function.
 
DataObjectretrieveObject ()
 Object retrieve method.
 
DataObjectfindObject ()
 Object find method.
 
DataObjectupdateObject ()
 Object update method.
 

Static Public Member Functions

static DataObjectretrieve (SmartDataObjectPtr *ptr)
 Static Object retrieval method.
 
static DataObjectfind (SmartDataObjectPtr *ptr)
 Static Object find method.
 
static DataObjectupdate (SmartDataObjectPtr *ptr)
 Static Object update method.
 

Protected Member Functions

StatusCode find (IRegistry *pDirectory, std::string_view path, DataObject *&refpObject)
 Find the specified object from the data store.
 
StatusCode find (std::string_view fullPath, DataObject *&refpObject)
 Find the specified object from the data store.
 
StatusCode retrieve (IRegistry *pDirectory, std::string_view path, DataObject *&refpObject)
 Retrieve the specified object from the data store.
 
StatusCode retrieve (std::string_view fullPath, DataObject *&refpObject)
 Retrieve the specified object from the data store.
 
StatusCode update (IRegistry *pDirectory)
 Update the specified object from the data store.
 
StatusCode update (std::string_view fullPath)
 Update the specified object from the data store.
 

Protected Attributes

IDataProviderSvcm_dataProvider = nullptr
 Pointer to contained object.
 
IRegistrym_pRegistry = nullptr
 Pointer to the data registry containing the object.
 
StatusCode m_status = StatusCode::SUCCESS
 Keep track of the last error.
 
std::string m_path
 Path to object.
 
AccessFunction m_accessFunc = nullptr
 Data access function.
 

Detailed Description

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

The class is meant as configurable base class for real Smart pointer instances. Here mainly the access of the data store is handled. It is important to keep as less functions as possible NON-VIRTUAL in particular those, which handle the data access - they might be called very often and hence the compiler must be able to inline them.

Author
M.Frank
Version
1.0

Definition at line 37 of file SmartDataObjectPtr.h.

Member Typedef Documentation

◆ AccessFunction

Constructor & Destructor Documentation

◆ SmartDataObjectPtr() [1/2]

SmartDataObjectPtr::SmartDataObjectPtr ( AccessFunction access,
IDataProviderSvc * pService,
IRegistry * pDir,
std::string path )
inline

Standard constructor: Construct an SmartDataObjectPtr instance.

Parameters
svcPointer to the data service interface used to interact with the store.
pDirPointer to data directory
pathpath to object relative to data directory

Definition at line 59 of file SmartDataObjectPtr.h.

60 : m_dataProvider( pService ), m_pRegistry( pDir ), m_path( std::move( path ) ), m_accessFunc( access ) {}
const std::string & path() const
Path name.
AccessFunction m_accessFunc
Data access function.
std::string m_path
Path to object.
IDataProviderSvc * m_dataProvider
Pointer to contained object.
IRegistry * m_pRegistry
Pointer to the data registry containing the object.

◆ SmartDataObjectPtr() [2/2]

SmartDataObjectPtr::SmartDataObjectPtr ( const SmartDataObjectPtr & )
default

Copy constructor: Construct an copy of a SmartDataStorePtr instance.

Parameters
copyCopy of Smart Pointer to object.

◆ ~SmartDataObjectPtr()

virtual SmartDataObjectPtr::~SmartDataObjectPtr ( )
virtualdefault

Standard Destructor.

Member Function Documentation

◆ accessData()

DataObject * SmartDataObjectPtr::accessData ( )
inline

Static Object retrieval method: must call specific function.

Definition at line 91 of file SmartDataObjectPtr.h.

91{ return m_accessFunc( this ); }

◆ directory()

IRegistry * SmartDataObjectPtr::directory ( )
inline

Access to data directory.

Definition at line 79 of file SmartDataObjectPtr.h.

79{ return m_pRegistry; }

◆ find() [1/3]

StatusCode SmartDataObjectPtr::find ( IRegistry * pDirectory,
std::string_view path,
DataObject *& refpObject )
protected

Find the specified object from the data store.

Retrieve the object from the data store.

Parameters
pDirectoryPointer to the directory entry holding the object.
refpObjectReference to the pointer finally holding the object
Returns
StatusCode indicating success or failure.

Definition at line 31 of file SmartDataObjectPtr.cpp.

31 {
32 return ( m_dataProvider && pDirectory ) ? m_dataProvider->findObject( pDirectory, path, refpObject )
34 ;
35}
constexpr static const auto FAILURE
Definition StatusCode.h:100

◆ find() [2/3]

static DataObject * SmartDataObjectPtr::find ( SmartDataObjectPtr * ptr)
inlinestatic

Static Object find method.

Definition at line 97 of file SmartDataObjectPtr.h.

97{ return ptr->findObject(); }
DataObject * findObject()
Object find method.

◆ find() [3/3]

StatusCode SmartDataObjectPtr::find ( std::string_view fullPath,
DataObject *& refpObject )
protected

Find the specified object from the data store.

Retrieve the object from the data store.

Parameters
fullPathString containing the full path necessary to locate the object.
refpObjectReference to the pointer finally holding the object
Returns
StatusCode indicating success or failure.

Definition at line 38 of file SmartDataObjectPtr.cpp.

38 {
39 return m_dataProvider ? m_dataProvider->findObject( fullPath, refpObject ) : StatusCode::FAILURE;
40}

◆ findObject()

DataObject * SmartDataObjectPtr::findObject ( )

Object find method.

If the object is not known to the local object, it is requested from the data service either using the full path if there is no directory information present.

Definition at line 72 of file SmartDataObjectPtr.cpp.

72 {
73 DataObject* pObj = nullptr;
74 m_status = ( m_pRegistry ? find( m_pRegistry, m_path, pObj ) : find( m_path, pObj ) );
75 if ( m_status.isSuccess() ) {
76 m_pRegistry = pObj->registry();
77 m_path.clear();
78 }
79 return pObj;
80}
static DataObject * find(SmartDataObjectPtr *ptr)
Static Object find method.
StatusCode m_status
Keep track of the last error.

◆ getLastError()

const StatusCode & SmartDataObjectPtr::getLastError ( ) const
inline

Access to potential errors during data accesses.

Definition at line 88 of file SmartDataObjectPtr.h.

88{ return m_status; }

◆ operator IRegistry *()

SmartDataObjectPtr::operator IRegistry * ( )
inline

Automatic conversion to data directory.

Definition at line 73 of file SmartDataObjectPtr.h.

73{ return m_pRegistry; }

◆ operator=()

virtual SmartDataObjectPtr & SmartDataObjectPtr::operator= ( const SmartDataObjectPtr & )
virtualdefault

◆ path()

const std::string & SmartDataObjectPtr::path ( ) const
inline

Path name.

Definition at line 76 of file SmartDataObjectPtr.h.

76{ return m_path; }

◆ retrieve() [1/3]

StatusCode SmartDataObjectPtr::retrieve ( IRegistry * pDirectory,
std::string_view path,
DataObject *& refpObject )
protected

Retrieve the specified object from the data store.

Retrieve the object from the data store.

Parameters
pDirectoryPointer to the directory entry holding the object.
refpObjectReference to the pointer finally holding the object
Returns
StatusCode indicating success or failure.

Definition at line 20 of file SmartDataObjectPtr.cpp.

20 {
21 return ( m_dataProvider && pRegistry ) ? m_dataProvider->retrieveObject( pRegistry, path, refpObject )
23}

◆ retrieve() [2/3]

static DataObject * SmartDataObjectPtr::retrieve ( SmartDataObjectPtr * ptr)
inlinestatic

Static Object retrieval method.

Definition at line 94 of file SmartDataObjectPtr.h.

94{ return ptr->retrieveObject(); }
DataObject * retrieveObject()
Object retrieve method.

◆ retrieve() [3/3]

StatusCode SmartDataObjectPtr::retrieve ( std::string_view fullPath,
DataObject *& refpObject )
protected

Retrieve the specified object from the data store.

Retrieve the object from the data store.

Parameters
fullPathString containing the full path necessary to locate the object.
refpObjectReference to the pointer finally holding the object
Returns
StatusCode indicating success or failure.

Definition at line 26 of file SmartDataObjectPtr.cpp.

26 {
27 return m_dataProvider ? m_dataProvider->retrieveObject( fullPath, refpObject ) : StatusCode::FAILURE;
28}

◆ retrieveObject()

DataObject * SmartDataObjectPtr::retrieveObject ( )

Object retrieve method.

Object retrieval method.

If the object is not known to the local object, it is requested from the data service either using the full path if there is no directory information present.

Definition at line 57 of file SmartDataObjectPtr.cpp.

57 {
58 DataObject* pObj = nullptr;
59 m_status = ( !m_pRegistry ? retrieve( m_path, pObj ) : retrieve( m_pRegistry, m_path, pObj ) );
60 if ( m_status.isSuccess() ) {
61 m_pRegistry = pObj->registry();
62 m_path.clear();
63 }
64 return pObj;
65}
static DataObject * retrieve(SmartDataObjectPtr *ptr)
Static Object retrieval method.

◆ service()

IDataProviderSvc * SmartDataObjectPtr::service ( )
inline

Retrieve data service.

Definition at line 85 of file SmartDataObjectPtr.h.

85{ return m_dataProvider; }

◆ setService()

void SmartDataObjectPtr::setService ( IDataProviderSvc * svc)
inline

Assign data service.

Definition at line 82 of file SmartDataObjectPtr.h.

82{ m_dataProvider = svc; }

◆ update() [1/3]

StatusCode SmartDataObjectPtr::update ( IRegistry * pDirectory)
protected

Update the specified object from the data store.

update the object from the data store.

Parameters
pDirectoryPointer to the directory entry holding the object.
Returns
StatusCode indicating success or failure.

Definition at line 43 of file SmartDataObjectPtr.cpp.

43 {
44 return ( m_dataProvider && pRegistry ) ? m_dataProvider->updateObject( pRegistry ) : StatusCode::FAILURE;
45}

◆ update() [2/3]

static DataObject * SmartDataObjectPtr::update ( SmartDataObjectPtr * ptr)
inlinestatic

Static Object update method.

Definition at line 100 of file SmartDataObjectPtr.h.

100{ return ptr->updateObject(); }
DataObject * updateObject()
Object update method.

◆ update() [3/3]

StatusCode SmartDataObjectPtr::update ( std::string_view fullPath)
protected

Update the specified object from the data store.

update the object from the data store.

Parameters
fullPathString containing the full path necessary to locate the object.
Returns
StatusCode indicating success or failure.

Definition at line 48 of file SmartDataObjectPtr.cpp.

48 {
49 return ( m_dataProvider ) ? m_dataProvider->updateObject( fullPath ) : StatusCode::FAILURE;
50}

◆ updateObject()

DataObject * SmartDataObjectPtr::updateObject ( )

Object update method.

If the object is not known to the local object, it is requested from the data service either using the full path if there is no directory information present. Needs to be virtual to to implicit object access.

If the object is not known to the local object, it is requested from the data service either using the full path if there is no directory information present.

Definition at line 87 of file SmartDataObjectPtr.cpp.

87 {
88 DataObject* pObj = accessData(); // Have to load AND update if not present.
89 if ( m_status.isSuccess() ) {
91 if ( !m_status.isSuccess() ) pObj = nullptr;
92 }
93 return pObj;
94}
DataObject * accessData()
Static Object retrieval method: must call specific function.
static DataObject * update(SmartDataObjectPtr *ptr)
Static Object update method.

Member Data Documentation

◆ m_accessFunc

AccessFunction SmartDataObjectPtr::m_accessFunc = nullptr
protected

Data access function.

Definition at line 173 of file SmartDataObjectPtr.h.

◆ m_dataProvider

IDataProviderSvc* SmartDataObjectPtr::m_dataProvider = nullptr
mutableprotected

Pointer to contained object.

Definition at line 165 of file SmartDataObjectPtr.h.

◆ m_path

std::string SmartDataObjectPtr::m_path
protected

Path to object.

Definition at line 171 of file SmartDataObjectPtr.h.

◆ m_pRegistry

IRegistry* SmartDataObjectPtr::m_pRegistry = nullptr
mutableprotected

Pointer to the data registry containing the object.

Definition at line 167 of file SmartDataObjectPtr.h.

◆ m_status

StatusCode SmartDataObjectPtr::m_status = StatusCode::SUCCESS
mutableprotected

Keep track of the last error.

Definition at line 169 of file SmartDataObjectPtr.h.


The documentation for this class was generated from the following files: