| The Gaudi Framework v28r2p1 (f1a77ff4)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
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:
[legend]
Collaboration diagram for SmartDataObjectPtr:
[legend]

## 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 SmartDataObjectPtr & | operator= (const SmartDataObjectPtr &)
| Assignment operator. More...
| operator IRegistry * ()
| Automatic conversion to data directory. More...
const std::string & | path () const
| Path name. More...
IRegistry * | directory ()
| Access to data directory. More...
void | setService (IDataProviderSvc *svc)
| Assign data service. More...
IDataProviderSvc * | service ()
| Retrieve data service. More...
const StatusCode & | getLastError () const
| Access to potential errors during data accesses. More...
DataObject * | accessData ()
| Static Object retrieval method: must call specific function. More...
DataObject * | retrieveObject ()
| Object retrieve method. More...
DataObject * | findObject ()
| Object find method. More...
DataObject * | updateObject ()
| Object update method. More...

## Static Public Member Functions
static DataObject * | retrieve (SmartDataObjectPtr *ptr)
| Static Object retrieval method. More...
static DataObject * | find (SmartDataObjectPtr *ptr)
| Static Object find method. More...
static DataObject * | update (SmartDataObjectPtr *ptr)
| Static Object update method. More...

## Protected Member Functions
StatusCode | find (IRegistry *pDirectory, const std::string &path, DataObject *&refpObject)
| Find the specified object from the data store. More...
StatusCode | find (const std::string &fullPath, DataObject *&refpObject)
| Find the specified object from the data store. More...
StatusCode | retrieve (IRegistry *pDirectory, const std::string &path, DataObject *&refpObject)
| Retrieve the specified object from the data store. More...
StatusCode | retrieve (const std::string &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 (const std::string &fullPath)
| Update the specified object from the data store. More...

## Protected Attributes
IDataProviderSvc * | m_dataProvider = nullptr
| Pointer to contained object. More...
IRegistry * | m_pRegistry = nullptr
| Pointer to the data registry containing the object. More...
StatusCode | m_status = { StatusCode::SUCCESS, true }
| Keep track of the last error. More...
std::string | m_path
| Path to object. More...
AccessFunction | m_accessFunc
| 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 32 of file SmartDataObjectPtr.h.

## Member Typedef Documentation

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

Definition at line 34 of file SmartDataObjectPtr.h.

## Constructor & Destructor Documentation

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

Standard constructor: Construct an SmartDataObjectPtr instance.

Parameters

  svc | Pointer to the data service interface used to interact with the store.
  pDir | Pointer to data directory
  path | path to object relative to data directory

Definition at line 54 of file SmartDataObjectPtr.h.

55 : m_dataProvider(pService),
56 m_pRegistry(pDir),
57 m_path(std::move(path)),
58 m_accessFunc(access)
59 {
60 }
SmartDataObjectPtr::m_path
std::string m_path
Path to object.
Definition: SmartDataObjectPtr.h:192
Objects::access
bool access(const ContainedObject *from, ContainedObject **to)
Definition: KeyedObject.cpp:53
std::move
T move(T...args)
SmartDataObjectPtr::m_accessFunc
AccessFunction m_accessFunc
Data access function.
Definition: SmartDataObjectPtr.h:194
SmartDataObjectPtr::m_dataProvider
IDataProviderSvc * m_dataProvider
Pointer to contained object.
Definition: SmartDataObjectPtr.h:186
SmartDataObjectPtr::m_pRegistry
IRegistry * m_pRegistry
Pointer to the data registry containing the object.
Definition: SmartDataObjectPtr.h:188

SmartDataObjectPtr::SmartDataObjectPtr | ( | const SmartDataObjectPtr & |  | ) |
| default

Copy constructor: Construct an copy of a SmartDataStorePtr instance.

Parameters

  copy | Copy of Smart Pointer to object.

virtual SmartDataObjectPtr::~SmartDataObjectPtr | ( |  | ) |
| virtual default

Standard Destructor.

## Member Function Documentation

DataObject* SmartDataObjectPtr::accessData | ( |  | ) |
| inline

Static Object retrieval method: must call specific function.

Definition at line 103 of file SmartDataObjectPtr.h.

103 {
104 return m_accessFunc(this);
105 }
SmartDataObjectPtr::m_accessFunc
AccessFunction m_accessFunc
Data access function.
Definition: SmartDataObjectPtr.h:194

IRegistry* SmartDataObjectPtr::directory | ( |  | ) |
| inline

Access to data directory.

Definition at line 83 of file SmartDataObjectPtr.h.

83 {
84 return m_pRegistry;
85 }
SmartDataObjectPtr::m_pRegistry
IRegistry * m_pRegistry
Pointer to the data registry containing the object.
Definition: SmartDataObjectPtr.h:188

static DataObject* SmartDataObjectPtr::find | ( | SmartDataObjectPtr * | ptr | ) |
| inline static

Static Object find method.

Definition at line 113 of file SmartDataObjectPtr.h.

113 {
114 return ptr->findObject();
115 }
SmartDataObjectPtr::findObject
DataObject * findObject()
Object find method.
Definition: SmartDataObjectPtr.cpp:90

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

Find the specified object from the data store.

Retrieve the object from the data store.

Parameters

  pDirectory | Pointer to the directory entry holding the object.
  refpObject | Reference to the pointer finally holding the object

Returns
  StatusCode indicating success or failure.

Definition at line 46 of file SmartDataObjectPtr.cpp.

46 {
47 return ( m_dataProvider && pDirectory ) ? m_dataProvider->findObject(pDirectory, path, refpObject)
48 : StatusCode::FAILURE;;
49 }
StatusCode::FAILURE
Definition: StatusCode.h:29
IDataProviderSvc::findObject
virtual StatusCode findObject(IRegistry *pDirectory, const std::string &path, DataObject *&pObject)=0
Find object identified by its directory entry.
SmartDataObjectPtr::m_dataProvider
IDataProviderSvc * m_dataProvider
Pointer to contained object.
Definition: SmartDataObjectPtr.h:186

StatusCode SmartDataObjectPtr::find | ( | const std::string & | fullPath,
|  | DataObject *& | refpObject
| ) |  |
| protected

Find the specified object from the data store.

Retrieve the object from the data store.

Parameters

  fullPath | String containing the full path necessary to locate the object.
  refpObject | Reference to the pointer finally holding the object

Returns
  StatusCode indicating success or failure.

Definition at line 52 of file SmartDataObjectPtr.cpp.

52 {
53 return m_dataProvider ? m_dataProvider->findObject(fullPath, refpObject)
54 : StatusCode::FAILURE;
55 }
StatusCode::FAILURE
Definition: StatusCode.h:29
IDataProviderSvc::findObject
virtual StatusCode findObject(IRegistry *pDirectory, const std::string &path, DataObject *&pObject)=0
Find object identified by its directory entry.
SmartDataObjectPtr::m_dataProvider
IDataProviderSvc * m_dataProvider
Pointer to contained object.
Definition: SmartDataObjectPtr.h:186

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

90 {
91 DataObject* pObj = nullptr;
92 m_status = ( m_pRegistry ? find(m_pRegistry,m_path,pObj) : find(m_path,pObj) );
93 if ( m_status.isSuccess() ) {
94 m_pRegistry = pObj->registry();
95 m_path.clear();
96 }
97 return pObj;
98 }
SmartDataObjectPtr::find
static DataObject * find(SmartDataObjectPtr *ptr)
Static Object find method.
Definition: SmartDataObjectPtr.h:113
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
DataObject::registry
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:74
SmartDataObjectPtr::m_path
std::string m_path
Path to object.
Definition: SmartDataObjectPtr.h:192
std::string::clear
T clear(T...args)
SmartDataObjectPtr::m_status
StatusCode m_status
Keep track of the last error.
Definition: SmartDataObjectPtr.h:190
SmartDataObjectPtr::m_pRegistry
IRegistry * m_pRegistry
Pointer to the data registry containing the object.
Definition: SmartDataObjectPtr.h:188
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30

const StatusCode& SmartDataObjectPtr::getLastError | ( |  | ) | const
| inline

Access to potential errors during data accesses.

Definition at line 98 of file SmartDataObjectPtr.h.

98 {
99 return m_status;
100 }
SmartDataObjectPtr::m_status
StatusCode m_status
Keep track of the last error.
Definition: SmartDataObjectPtr.h:190

SmartDataObjectPtr::operator IRegistry * | ( |  | ) |
| inline

Automatic conversion to data directory.

Definition at line 73 of file SmartDataObjectPtr.h.

73 {
74 return m_pRegistry;
75 }
SmartDataObjectPtr::m_pRegistry
IRegistry * m_pRegistry
Pointer to the data registry containing the object.
Definition: SmartDataObjectPtr.h:188

SmartDataObjectPtr & SmartDataObjectPtr::operator= | ( | const SmartDataObjectPtr & | copy | ) |
| virtual

Assignment operator.

Reimplemented in SmartDataStorePtr< TYPE, LOADER >, and SmartDataStorePtr< TYPE, SmartDataObjectPtr::ObjectLoader >.

Definition at line 26 of file SmartDataObjectPtr.cpp.

26 {
27 m_path = copy.m_path;
28 m_pRegistry = copy.m_pRegistry;
29 m_dataProvider = copy.m_dataProvider;
30 return *this;
31 }
SmartDataObjectPtr::m_path
std::string m_path
Path to object.
Definition: SmartDataObjectPtr.h:192
SmartDataObjectPtr::m_dataProvider
IDataProviderSvc * m_dataProvider
Pointer to contained object.
Definition: SmartDataObjectPtr.h:186
SmartDataObjectPtr::m_pRegistry
IRegistry * m_pRegistry
Pointer to the data registry containing the object.
Definition: SmartDataObjectPtr.h:188

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

Path name.

Definition at line 78 of file SmartDataObjectPtr.h.

78 {
79 return m_path;
80 }
SmartDataObjectPtr::m_path
std::string m_path
Path to object.
Definition: SmartDataObjectPtr.h:192

static DataObject* SmartDataObjectPtr::retrieve | ( | SmartDataObjectPtr * | ptr | ) |
| inline static

Static Object retrieval method.

Definition at line 108 of file SmartDataObjectPtr.h.

108 {
109 return ptr->retrieveObject();
110 }
SmartDataObjectPtr::retrieveObject
DataObject * retrieveObject()
Object retrieve method.
Definition: SmartDataObjectPtr.cpp:75

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

Retrieve the specified object from the data store.

Retrieve the object from the data store.

Parameters

  pDirectory | Pointer to the directory entry holding the object.
  refpObject | Reference to the pointer finally holding the object

Returns
  StatusCode indicating success or failure.

Definition at line 34 of file SmartDataObjectPtr.cpp.

34 {
35 return ( m_dataProvider && pRegistry ) ? m_dataProvider->retrieveObject(pRegistry, path, refpObject)
36 : StatusCode::FAILURE;
37 }
StatusCode::FAILURE
Definition: StatusCode.h:29
SmartDataObjectPtr::m_dataProvider
IDataProviderSvc * m_dataProvider
Pointer to contained object.
Definition: SmartDataObjectPtr.h:186
IDataProviderSvc::retrieveObject
virtual StatusCode retrieveObject(IRegistry *pDirectory, const std::string &path, DataObject *&pObject)=0
Retrieve object identified by its directory entry.

StatusCode SmartDataObjectPtr::retrieve | ( | const std::string & | fullPath,
|  | DataObject *& | refpObject
| ) |  |
| protected

Retrieve the specified object from the data store.

Retrieve the object from the data store.

Parameters

  fullPath | String containing the full path necessary to locate the object.
  refpObject | Reference to the pointer finally holding the object

Returns
  StatusCode indicating success or failure.

Definition at line 40 of file SmartDataObjectPtr.cpp.

40 {
41 return m_dataProvider ? m_dataProvider->retrieveObject(fullPath, refpObject)
42 : StatusCode::FAILURE;
43 }
StatusCode::FAILURE
Definition: StatusCode.h:29
SmartDataObjectPtr::m_dataProvider
IDataProviderSvc * m_dataProvider
Pointer to contained object.
Definition: SmartDataObjectPtr.h:186
IDataProviderSvc::retrieveObject
virtual StatusCode retrieveObject(IRegistry *pDirectory, const std::string &path, DataObject *&pObject)=0
Retrieve object identified by its directory entry.

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

75 {
76 DataObject* pObj = nullptr;
77 m_status = (!m_pRegistry ? retrieve(m_path,pObj) : retrieve(m_pRegistry,m_path,pObj) );
78 if ( m_status.isSuccess() ) {
79 m_pRegistry = pObj->registry();
80 m_path.clear();
81 }
82 return pObj;
83 }
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
DataObject::registry
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:74
SmartDataObjectPtr::retrieve
static DataObject * retrieve(SmartDataObjectPtr *ptr)
Static Object retrieval method.
Definition: SmartDataObjectPtr.h:108
SmartDataObjectPtr::m_path
std::string m_path
Path to object.
Definition: SmartDataObjectPtr.h:192
std::string::clear
T clear(T...args)
SmartDataObjectPtr::m_status
StatusCode m_status
Keep track of the last error.
Definition: SmartDataObjectPtr.h:190
SmartDataObjectPtr::m_pRegistry
IRegistry * m_pRegistry
Pointer to the data registry containing the object.
Definition: SmartDataObjectPtr.h:188
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30

IDataProviderSvc* SmartDataObjectPtr::service | ( |  | ) |
| inline

Retrieve data service.

Definition at line 93 of file SmartDataObjectPtr.h.

93 {
94 return m_dataProvider;
95 }
SmartDataObjectPtr::m_dataProvider
IDataProviderSvc * m_dataProvider
Pointer to contained object.
Definition: SmartDataObjectPtr.h:186

void SmartDataObjectPtr::setService | ( | IDataProviderSvc * | svc | ) |
| inline

Assign data service.

Definition at line 88 of file SmartDataObjectPtr.h.

88 {
89 m_dataProvider = svc;
90 }
SmartDataObjectPtr::m_dataProvider
IDataProviderSvc * m_dataProvider
Pointer to contained object.
Definition: SmartDataObjectPtr.h:186

static DataObject* SmartDataObjectPtr::update | ( | SmartDataObjectPtr * | ptr | ) |
| inline static

Static Object update method.

Definition at line 118 of file SmartDataObjectPtr.h.

118 {
119 return ptr->updateObject();
120 }
SmartDataObjectPtr::updateObject
DataObject * updateObject()
Object update method.
Definition: SmartDataObjectPtr.cpp:105

StatusCode SmartDataObjectPtr::update | ( | IRegistry * | pDirectory | ) |
| protected

Update the specified object from the data store.

update the object from the data store.

Parameters

  pDirectory | Pointer to the directory entry holding the object.

Returns
  StatusCode indicating success or failure.

Definition at line 59 of file SmartDataObjectPtr.cpp.

59 {
60 return ( m_dataProvider && pRegistry ) ? m_dataProvider->updateObject(pRegistry)
61 : StatusCode::FAILURE;
62 }
StatusCode::FAILURE
Definition: StatusCode.h:29
IDataProviderSvc::updateObject
virtual StatusCode updateObject(IRegistry *pDirectory)=0
Update object identified by its directory entry.
SmartDataObjectPtr::m_dataProvider
IDataProviderSvc * m_dataProvider
Pointer to contained object.
Definition: SmartDataObjectPtr.h:186

StatusCode SmartDataObjectPtr::update | ( | const std::string & | fullPath | ) |
| protected

Update the specified object from the data store.

update the object from the data store.

Parameters

  fullPath | String containing the full path necessary to locate the object.

Returns
  StatusCode indicating success or failure.

Definition at line 65 of file SmartDataObjectPtr.cpp.

65 {
66 return ( m_dataProvider ) ? m_dataProvider->updateObject(fullPath)
67 : StatusCode::FAILURE;
68 }
StatusCode::FAILURE
Definition: StatusCode.h:29
IDataProviderSvc::updateObject
virtual StatusCode updateObject(IRegistry *pDirectory)=0
Update object identified by its directory entry.
SmartDataObjectPtr::m_dataProvider
IDataProviderSvc * m_dataProvider
Pointer to contained object.
Definition: SmartDataObjectPtr.h:186

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

105 {
106 DataObject* pObj = accessData(); // Have to load AND update if not present.
107 if ( m_status.isSuccess() ) {
108 m_status = (!m_pRegistry ? update(m_path) : update(m_pRegistry) );
109 if ( !m_status.isSuccess() ) pObj = nullptr;
110 }
111 return pObj;
112 }
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
SmartDataObjectPtr::update
static DataObject * update(SmartDataObjectPtr *ptr)
Static Object update method.
Definition: SmartDataObjectPtr.h:118
SmartDataObjectPtr::m_path
std::string m_path
Path to object.
Definition: SmartDataObjectPtr.h:192
SmartDataObjectPtr::accessData
DataObject * accessData()
Static Object retrieval method: must call specific function.
Definition: SmartDataObjectPtr.h:103
SmartDataObjectPtr::m_status
StatusCode m_status
Keep track of the last error.
Definition: SmartDataObjectPtr.h:190
SmartDataObjectPtr::m_pRegistry
IRegistry * m_pRegistry
Pointer to the data registry containing the object.
Definition: SmartDataObjectPtr.h:188
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30

## Member Data Documentation

AccessFunction SmartDataObjectPtr::m_accessFunc
| protected

Data access function.

Definition at line 194 of file SmartDataObjectPtr.h.

IDataProviderSvc* SmartDataObjectPtr::m_dataProvider = nullptr
| mutable protected

Pointer to contained object.

Definition at line 186 of file SmartDataObjectPtr.h.

std::string SmartDataObjectPtr::m_path
| protected

Path to object.

Definition at line 192 of file SmartDataObjectPtr.h.

IRegistry* SmartDataObjectPtr::m_pRegistry = nullptr
| mutable protected

Pointer to the data registry containing the object.

Definition at line 188 of file SmartDataObjectPtr.h.

StatusCode SmartDataObjectPtr::m_status = { StatusCode::SUCCESS, true }
| mutable protected

Keep track of the last error.

Definition at line 190 of file SmartDataObjectPtr.h.

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

- GaudiKernel/GaudiKernel/SmartDataObjectPtr.h
- GaudiKernel/src/Lib/SmartDataObjectPtr.cpp