The Gaudi Framework  master (37c0b60a)
SmartDataObjectPtr Class Reference

#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. More...
 
 SmartDataObjectPtr (const SmartDataObjectPtr &)=default
 Copy constructor: Construct an copy of a SmartDataStorePtr instance. More...
 
virtual ~SmartDataObjectPtr ()=default
 Standard Destructor. More...
 
virtual SmartDataObjectPtroperator= (const SmartDataObjectPtr &)=default
 Assignment operator. 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...
 

Static Public Member Functions

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

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...
 

Protected Attributes

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...
 

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 42 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 64 of file SmartDataObjectPtr.h.

65  : m_dataProvider( pService ), m_pRegistry( pDir ), m_path( std::move( path ) ), m_accessFunc( access ) {}

◆ 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 96 of file SmartDataObjectPtr.h.

96 { return m_accessFunc( this ); }

◆ directory()

IRegistry* SmartDataObjectPtr::directory ( )
inline

Access to data directory.

Definition at line 84 of file SmartDataObjectPtr.h.

84 { 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 43 of file SmartDataObjectPtr.cpp.

43  {
44  return ( m_dataProvider && pDirectory ) ? m_dataProvider->findObject( pDirectory, path, refpObject )
46  ;
47 }

◆ find() [2/3]

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

Static Object find method.

Definition at line 102 of file SmartDataObjectPtr.h.

102 { return ptr->findObject(); }

◆ 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 50 of file SmartDataObjectPtr.cpp.

50  {
51  return m_dataProvider ? m_dataProvider->findObject( fullPath, refpObject ) : StatusCode::FAILURE;
52 }

◆ 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 84 of file SmartDataObjectPtr.cpp.

84  {
85  DataObject* pObj = nullptr;
86  m_status = ( m_pRegistry ? find( m_pRegistry, m_path, pObj ) : find( m_path, pObj ) );
87  if ( m_status.isSuccess() ) {
88  m_pRegistry = pObj->registry();
89  m_path.clear();
90  }
91  return pObj;
92 }

◆ getLastError()

const StatusCode& SmartDataObjectPtr::getLastError ( ) const
inline

Access to potential errors during data accesses.

Definition at line 93 of file SmartDataObjectPtr.h.

93 { return m_status; }

◆ operator IRegistry *()

SmartDataObjectPtr::operator IRegistry * ( )
inline

Automatic conversion to data directory.

Definition at line 78 of file SmartDataObjectPtr.h.

78 { return m_pRegistry; }

◆ operator=()

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

◆ path()

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

Path name.

Definition at line 81 of file SmartDataObjectPtr.h.

81 { 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 32 of file SmartDataObjectPtr.cpp.

32  {
33  return ( m_dataProvider && pRegistry ) ? m_dataProvider->retrieveObject( pRegistry, path, refpObject )
35 }

◆ retrieve() [2/3]

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

Static Object retrieval method.

Definition at line 99 of file SmartDataObjectPtr.h.

99 { return ptr->retrieveObject(); }

◆ 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 38 of file SmartDataObjectPtr.cpp.

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

◆ 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 69 of file SmartDataObjectPtr.cpp.

69  {
70  DataObject* pObj = nullptr;
71  m_status = ( !m_pRegistry ? retrieve( m_path, pObj ) : retrieve( m_pRegistry, m_path, pObj ) );
72  if ( m_status.isSuccess() ) {
73  m_pRegistry = pObj->registry();
74  m_path.clear();
75  }
76  return pObj;
77 }

◆ service()

IDataProviderSvc* SmartDataObjectPtr::service ( )
inline

Retrieve data service.

Definition at line 90 of file SmartDataObjectPtr.h.

90 { return m_dataProvider; }

◆ setService()

void SmartDataObjectPtr::setService ( IDataProviderSvc svc)
inline

Assign data service.

Definition at line 87 of file SmartDataObjectPtr.h.

87 { 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 55 of file SmartDataObjectPtr.cpp.

55  {
56  return ( m_dataProvider && pRegistry ) ? m_dataProvider->updateObject( pRegistry ) : StatusCode::FAILURE;
57 }

◆ update() [2/3]

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

Static Object update method.

Definition at line 105 of file SmartDataObjectPtr.h.

105 { return ptr->updateObject(); }

◆ 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 60 of file SmartDataObjectPtr.cpp.

60  {
62 }

◆ 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 99 of file SmartDataObjectPtr.cpp.

99  {
100  DataObject* pObj = accessData(); // Have to load AND update if not present.
101  if ( m_status.isSuccess() ) {
103  if ( !m_status.isSuccess() ) pObj = nullptr;
104  }
105  return pObj;
106 }

Member Data Documentation

◆ m_accessFunc

AccessFunction SmartDataObjectPtr::m_accessFunc = nullptr
protected

Data access function.

Definition at line 178 of file SmartDataObjectPtr.h.

◆ m_dataProvider

IDataProviderSvc* SmartDataObjectPtr::m_dataProvider = nullptr
mutableprotected

Pointer to contained object.

Definition at line 170 of file SmartDataObjectPtr.h.

◆ m_path

std::string SmartDataObjectPtr::m_path
protected

Path to object.

Definition at line 176 of file SmartDataObjectPtr.h.

◆ m_pRegistry

IRegistry* SmartDataObjectPtr::m_pRegistry = nullptr
mutableprotected

Pointer to the data registry containing the object.

Definition at line 172 of file SmartDataObjectPtr.h.

◆ m_status

StatusCode SmartDataObjectPtr::m_status = StatusCode::SUCCESS
mutableprotected

Keep track of the last error.

Definition at line 174 of file SmartDataObjectPtr.h.


The documentation for this class was generated from the following files:
SmartDataObjectPtr::m_accessFunc
AccessFunction m_accessFunc
Data access function.
Definition: SmartDataObjectPtr.h:178
SmartDataObjectPtr::retrieve
static DataObject * retrieve(SmartDataObjectPtr *ptr)
Static Object retrieval method.
Definition: SmartDataObjectPtr.h:99
SmartDataObjectPtr::m_dataProvider
IDataProviderSvc * m_dataProvider
Pointer to contained object.
Definition: SmartDataObjectPtr.h:170
std::move
T move(T... args)
SmartDataObjectPtr::m_status
StatusCode m_status
Keep track of the last error.
Definition: SmartDataObjectPtr.h:174
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:314
SmartDataObjectPtr::findObject
DataObject * findObject()
Object find method.
Definition: SmartDataObjectPtr.cpp:84
std::string::clear
T clear(T... args)
SmartDataObjectPtr::find
static DataObject * find(SmartDataObjectPtr *ptr)
Static Object find method.
Definition: SmartDataObjectPtr.h:102
SmartDataObjectPtr::m_pRegistry
IRegistry * m_pRegistry
Pointer to the data registry containing the object.
Definition: SmartDataObjectPtr.h:172
IDataProviderSvc::retrieveObject
virtual StatusCode retrieveObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject)=0
Retrieve object identified by its directory entry.
SmartDataObjectPtr::updateObject
DataObject * updateObject()
Object update method.
Definition: SmartDataObjectPtr.cpp:99
SmartDataObjectPtr::retrieveObject
DataObject * retrieveObject()
Object retrieve method.
Definition: SmartDataObjectPtr.cpp:69
SmartDataObjectPtr::update
static DataObject * update(SmartDataObjectPtr *ptr)
Static Object update method.
Definition: SmartDataObjectPtr.h:105
DataObject
Definition: DataObject.h:36
SmartDataObjectPtr::m_path
std::string m_path
Path to object.
Definition: SmartDataObjectPtr.h:176
SmartDataObjectPtr::path
const std::string & path() const
Path name.
Definition: SmartDataObjectPtr.h:81
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
DataObject::registry
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:78
IDataProviderSvc::updateObject
virtual StatusCode updateObject(IRegistry *pDirectory)=0
Update object identified by its directory entry.
IDataProviderSvc::findObject
virtual StatusCode findObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject)=0
Find object identified by its directory entry.
SmartDataObjectPtr::accessData
DataObject * accessData()
Static Object retrieval method: must call specific function.
Definition: SmartDataObjectPtr.h:96