All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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

typedef DataObject *(* AccessFunction )(SmartDataObjectPtr *ptr)
 

Public Member Functions

 SmartDataObjectPtr (AccessFunction access, IDataProviderSvc *pService, IRegistry *pDir, const std::string &path)
 Standard constructor: Construct an SmartDataObjectPtr instance. More...
 
 SmartDataObjectPtr (const SmartDataObjectPtr &copy)
 Copy constructor: Construct an copy of a SmartDataStorePtr instance. More...
 
virtual ~SmartDataObjectPtr ()
 Standard Destructor. More...
 
virtual SmartDataObjectPtroperator= (const SmartDataObjectPtr &copy)
 Assignment operator. More...
 
 operator IRegistry * ()
 Automatic conversion to data directory. More...
 
const std::string & path () const
 Path name. More...
 
IRegistrydirectory ()
 Access to data directory. More...
 
void setService (IDataProviderSvc *svc)
 Assign data service. More...
 
IDataProviderSvcservice ()
 Retrieve data service. More...
 
StatusCode getLastError () 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, 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

IDataProviderSvcm_dataProvider
 Pointer to contained object. More...
 
IRegistrym_pRegistry
 Pointer to the data registry containing the object. More...
 
StatusCode m_status
 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 33 of file SmartDataObjectPtr.h.

Member Typedef Documentation

typedef DataObject*(* SmartDataObjectPtr::AccessFunction)(SmartDataObjectPtr *ptr)

Definition at line 35 of file SmartDataObjectPtr.h.

Constructor & Destructor Documentation

SmartDataObjectPtr::SmartDataObjectPtr ( AccessFunction  access,
IDataProviderSvc pService,
IRegistry pDir,
const 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 55 of file SmartDataObjectPtr.h.

56  : m_dataProvider(pService),
57  m_pRegistry(pDir),
59  m_path(path),
61  {
62  }
std::string m_path
Path to object.
const std::string & path() const
Path name.
bool access(const ContainedObject *from, ContainedObject **to)
Definition: KeyedObject.cpp:66
StatusCode m_status
Keep track of the last error.
AccessFunction m_accessFunc
Data access function.
IDataProviderSvc * m_dataProvider
Pointer to contained object.
IRegistry * m_pRegistry
Pointer to the data registry containing the object.
SmartDataObjectPtr::SmartDataObjectPtr ( const SmartDataObjectPtr copy)
inline

Copy constructor: Construct an copy of a SmartDataStorePtr instance.

Parameters
copyCopy of Smart Pointer to object.

Definition at line 66 of file SmartDataObjectPtr.h.

69  m_status(copy.m_status),
70  m_path(copy.m_path),
72  {
73  }
std::string m_path
Path to object.
StatusCode m_status
Keep track of the last error.
AccessFunction m_accessFunc
Data access function.
IDataProviderSvc * m_dataProvider
Pointer to contained object.
IRegistry * m_pRegistry
Pointer to the data registry containing the object.
virtual SmartDataObjectPtr::~SmartDataObjectPtr ( )
inlinevirtual

Standard Destructor.

Definition at line 75 of file SmartDataObjectPtr.h.

75  {
76  }

Member Function Documentation

DataObject* SmartDataObjectPtr::accessData ( )
inline

Static Object retrieval method: must call specific function.

Definition at line 111 of file SmartDataObjectPtr.h.

111  {
112  return m_accessFunc(this);
113  }
AccessFunction m_accessFunc
Data access function.
IRegistry* SmartDataObjectPtr::directory ( )
inline

Access to data directory.

Definition at line 91 of file SmartDataObjectPtr.h.

91  {
92  return m_pRegistry;
93  }
IRegistry * m_pRegistry
Pointer to the data registry containing the object.
static DataObject* SmartDataObjectPtr::find ( SmartDataObjectPtr ptr)
inlinestatic

Static Object find method.

Definition at line 121 of file SmartDataObjectPtr.h.

121  {
122  return ptr->findObject();
123  }
DataObject * findObject()
Object find method.
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
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 53 of file SmartDataObjectPtr.cpp.

53  {
55  if ( 0 != m_dataProvider && 0 != pDirectory ) {
56  status = m_dataProvider->findObject(pDirectory, path, refpObject);
57  }
58  return status;
59 }
virtual StatusCode findObject(IRegistry *pDirectory, const std::string &path, DataObject *&pObject)=0
Find object identified by its directory entry.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
const std::string & path() const
Path name.
IDataProviderSvc * m_dataProvider
Pointer to contained object.
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
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 62 of file SmartDataObjectPtr.cpp.

62  {
64  if ( 0 != m_dataProvider ) {
65  status = m_dataProvider->findObject(fullPath, refpObject);
66  }
67  return status;
68 }
virtual StatusCode findObject(IRegistry *pDirectory, const std::string &path, DataObject *&pObject)=0
Find object identified by its directory entry.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
IDataProviderSvc * m_dataProvider
Pointer to contained object.
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 109 of file SmartDataObjectPtr.cpp.

109  {
110  DataObject* pObj = 0;
111  m_status = (0==m_pRegistry) ? find(m_path,pObj) : find(m_pRegistry,m_path,pObj);
112  if ( m_status.isSuccess() ) {
113  m_pRegistry = pObj->registry();
114  m_path = "";
115  }
116  return pObj;
117 }
static DataObject * find(SmartDataObjectPtr *ptr)
Static Object find method.
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:62
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:69
std::string m_path
Path to object.
StatusCode m_status
Keep track of the last error.
IRegistry * m_pRegistry
Pointer to the data registry containing the object.
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:31
StatusCode SmartDataObjectPtr::getLastError ( ) const
inline

Access to potential errors during data accesses.

Definition at line 106 of file SmartDataObjectPtr.h.

106  {
107  return m_status;
108  }
StatusCode m_status
Keep track of the last error.
SmartDataObjectPtr::operator IRegistry * ( )
inline

Automatic conversion to data directory.

Definition at line 81 of file SmartDataObjectPtr.h.

81  {
82  return m_pRegistry;
83  }
IRegistry * m_pRegistry
Pointer to the data registry containing the object.
SmartDataObjectPtr & SmartDataObjectPtr::operator= ( const SmartDataObjectPtr copy)
virtual

Assignment operator.

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

Definition at line 27 of file SmartDataObjectPtr.cpp.

27  {
28  m_path = copy.m_path;
29  m_pRegistry = copy.m_pRegistry;
31  return *this;
32 }
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.
const std::string& SmartDataObjectPtr::path ( ) const
inline

Path name.

Definition at line 86 of file SmartDataObjectPtr.h.

86  {
87  return m_path;
88  }
std::string m_path
Path to object.
static DataObject* SmartDataObjectPtr::retrieve ( SmartDataObjectPtr ptr)
inlinestatic

Static Object retrieval method.

Definition at line 116 of file SmartDataObjectPtr.h.

116  {
117  return ptr->retrieveObject();
118  }
DataObject * retrieveObject()
Object retrieve method.
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
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 35 of file SmartDataObjectPtr.cpp.

35  {
37  if ( 0 != m_dataProvider && 0 != pRegistry ) {
38  status = m_dataProvider->retrieveObject(pRegistry, path, refpObject);
39  }
40  return status;
41 }
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
const std::string & path() const
Path name.
IDataProviderSvc * m_dataProvider
Pointer to contained object.
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
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 44 of file SmartDataObjectPtr.cpp.

44  {
46  if ( 0 != m_dataProvider ) {
47  status = m_dataProvider->retrieveObject(fullPath, refpObject);
48  }
49  return status;
50 }
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
IDataProviderSvc * m_dataProvider
Pointer to contained object.
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 94 of file SmartDataObjectPtr.cpp.

94  {
95  DataObject* pObj = 0;
97  if ( m_status.isSuccess() ) {
98  m_pRegistry = pObj->registry();
99  m_path = "";
100  }
101  return pObj;
102 }
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:62
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:69
static DataObject * retrieve(SmartDataObjectPtr *ptr)
Static Object retrieval method.
std::string m_path
Path to object.
StatusCode m_status
Keep track of the last error.
IRegistry * m_pRegistry
Pointer to the data registry containing the object.
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:31
IDataProviderSvc* SmartDataObjectPtr::service ( )
inline

Retrieve data service.

Definition at line 101 of file SmartDataObjectPtr.h.

101  {
102  return m_dataProvider;
103  }
IDataProviderSvc * m_dataProvider
Pointer to contained object.
void SmartDataObjectPtr::setService ( IDataProviderSvc svc)
inline

Assign data service.

Definition at line 96 of file SmartDataObjectPtr.h.

96  {
97  m_dataProvider = svc;
98  }
IDataProviderSvc * m_dataProvider
Pointer to contained object.
static DataObject* SmartDataObjectPtr::update ( SmartDataObjectPtr ptr)
inlinestatic

Static Object update method.

Definition at line 126 of file SmartDataObjectPtr.h.

126  {
127  return ptr->updateObject();
128  }
DataObject * updateObject()
Object update method.
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 72 of file SmartDataObjectPtr.cpp.

72  {
74  if ( 0 != m_dataProvider && 0 != pRegistry ) {
75  status = m_dataProvider->updateObject(pRegistry);
76  }
77  return status;
78 }
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
virtual StatusCode updateObject(IRegistry *pDirectory)=0
Update object identified by its directory entry.
IDataProviderSvc * m_dataProvider
Pointer to contained object.
StatusCode SmartDataObjectPtr::update ( const std::string &  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 81 of file SmartDataObjectPtr.cpp.

81  {
83  if ( 0 != m_dataProvider ) {
84  status = m_dataProvider->updateObject(fullPath);
85  }
86  return status;
87 }
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
virtual StatusCode updateObject(IRegistry *pDirectory)=0
Update object identified by its directory entry.
IDataProviderSvc * m_dataProvider
Pointer to contained object.
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 124 of file SmartDataObjectPtr.cpp.

124  {
125  DataObject* pObj = accessData(); // Have to load AND update if not present.
126  if ( m_status.isSuccess() ) {
128  if ( !m_status.isSuccess() ) pObj = 0;
129  }
130  return pObj;
131 }
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:62
static DataObject * update(SmartDataObjectPtr *ptr)
Static Object update method.
std::string m_path
Path to object.
DataObject * accessData()
Static Object retrieval method: must call specific function.
StatusCode m_status
Keep track of the last error.
IRegistry * m_pRegistry
Pointer to the data registry containing the object.
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:31

Member Data Documentation

AccessFunction SmartDataObjectPtr::m_accessFunc
protected

Data access function.

Definition at line 202 of file SmartDataObjectPtr.h.

IDataProviderSvc* SmartDataObjectPtr::m_dataProvider
mutableprotected

Pointer to contained object.

Definition at line 194 of file SmartDataObjectPtr.h.

std::string SmartDataObjectPtr::m_path
protected

Path to object.

Definition at line 200 of file SmartDataObjectPtr.h.

IRegistry* SmartDataObjectPtr::m_pRegistry
mutableprotected

Pointer to the data registry containing the object.

Definition at line 196 of file SmartDataObjectPtr.h.

StatusCode SmartDataObjectPtr::m_status
mutableprotected

Keep track of the last error.

Definition at line 198 of file SmartDataObjectPtr.h.


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