| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

SmartDataPtr< TYPE > Class Template Reference

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

#include <SmartDataPtr.h>

Inheritance diagram for SmartDataPtr< TYPE >:

[legend]
Collaboration diagram for SmartDataPtr< TYPE >:
[legend]
List of all members.

Public Types

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

Public Member Functions

 SmartDataPtr (IDataProviderSvc *pService, const std::string &fullPath)
 Standard constructor: Construct an SmartDataPtr instance which is able to connect to a DataObject instance which is identified by its parent object and the path relative to the parent.
 SmartDataPtr (IDataProviderSvc *pService, IRegistry *pDirectory)
 Standard constructor: Construct an SmartDataPtr instance which is able to connect to a DataObject instance which is identified by its directory entry.
 SmartDataPtr (IDataProviderSvc *pService, DataObject *pObject, const std::string &path)
 Standard constructor: Construct an SmartDataPtr instance which is able to connect to a DataObject instance which is identified by its parent object and the path relative to the parent.
 SmartDataPtr (SmartDataObjectPtr &refObject, IRegistry *pDirectory)
 Standard constructor: Construct an SmartDataPtr instance which is able to connect to a DataObject instance which is identified by its parent object and the path relative to the parent.
 SmartDataPtr (SmartDataObjectPtr &refObject, const std::string &path)
 Standard constructor: Construct an SmartDataPtr instance which is able to connect to a DataObject instance which is identified by its parent object and the path relative to the parent.
 SmartDataPtr (const SmartDataObjectPtr &copy)
 Copy constructor: Construct an copy of a SmartDataPtr instance.
virtual ~SmartDataPtr ()
 Standard destructor.
template<class OTHER>
SmartDataPtroperator= (OTHER *pObj)
 Automatic conversion to data type.
template<class OTHER>
SmartDataPtroperator= (const OTHER *pObj)
 Automatic conversion to data type.
TYPE * ptr ()
 Automatic conversion to data type.
TYPE * operator-> ()
 Dereference operator: the heart of the smart pointer.
TYPE & operator * ()
 Dereference operator: the heart of the smart pointer.
 operator TYPE * ()
 Automatic conversion to data type.
 operator TYPE & ()
 Automatic conversion to data type.
 operator int ()
 operator int for statements like: if ( SmartDataStorePtr<XXX>(...) ) {}
bool operator! ()
 operator ! for statements like: if ( !SmartDataStorePtr<XXX>(...) ) {}
TYPE * accessTypeSafeData ()
 Internal type safe accessor to data.
 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.
StatusCode getLastError () 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 retrieve (IRegistry *pDirectory, const std::string &path, DataObject *&refpObject)
 Retrieve the specified object from the data store.
StatusCode retrieve (const std::string &fullPath, DataObject *&refpObject)
 Retrieve the specified object from the data store.
StatusCode find (IRegistry *pDirectory, const std::string &path, DataObject *&refpObject)
 Find the specified object from the data store.
StatusCode find (const std::string &fullPath, DataObject *&refpObject)
 Find the specified object from the data store.
StatusCode update (IRegistry *pDirectory)
 Update the specified object from the data store.
StatusCode update (const std::string &fullPath)
 Update the specified object from the data store.

Protected Attributes

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

Detailed Description

template<class TYPE>
class SmartDataPtr< TYPE >

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 tyo 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 the object will be requested from the store.

The SmartDataPtr 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 to would be invalid and returned object pointers would actually point to hyperspace.

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

Base Class: SmartDataStorePtr

Author:
M.Frank
Version:
1.0

Definition at line 46 of file SmartDataPtr.h.


Member Typedef Documentation

typedef DataObject*(* ) SmartDataObjectPtr::AccessFunction(SmartDataObjectPtr *ptr) [inherited]

Definition at line 35 of file SmartDataObjectPtr.h.


Constructor & Destructor Documentation

template<class TYPE>
SmartDataPtr< TYPE >::SmartDataPtr ( IDataProviderSvc pService,
const std::string &  fullPath 
) [inline]

Standard constructor: Construct an SmartDataPtr instance which is able to connect to a DataObject instance which is identified by its parent object and the path relative to the parent.

Parameters:
pService Pointer to the data service interface which should be used to load the object.
fullPath Full path leading to the data object.

Definition at line 60 of file SmartDataPtr.h.

00061     : SmartDataStorePtr<TYPE,SmartDataObjectPtr::ObjectLoader>( pService,0,fullPath)
00062   {
00063   }

template<class TYPE>
SmartDataPtr< TYPE >::SmartDataPtr ( IDataProviderSvc pService,
IRegistry pDirectory 
) [inline]

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

FASTEST ACCESS TO THE DATA STORE ***

Parameters:
pService Pointer to the data service interface which should be used to load the object.
pDirectory Pointer to the data directory entry.

Definition at line 73 of file SmartDataPtr.h.

00074     : SmartDataStorePtr<TYPE,SmartDataObjectPtr::ObjectLoader>( pService,pDirectory,"")
00075   {
00076   }

template<class TYPE>
SmartDataPtr< TYPE >::SmartDataPtr ( IDataProviderSvc pService,
DataObject pObject,
const std::string &  path 
) [inline]

Standard constructor: Construct an SmartDataPtr instance which is able to connect to a DataObject instance which is identified by its parent object and the path relative to the parent.

The path is meant to address only ONE level, multiple path layers are invalid.

Parameters:
pService Pointer to the data service interface which should be used to load the object.
pObject Pointer to the parent object.
path Path to the data object relative to the parent object.

Definition at line 89 of file SmartDataPtr.h.

00090     : SmartDataStorePtr<TYPE,SmartDataObjectPtr::ObjectLoader>( pService,0,path)
00091   {
00092     if ( 0 != pObject )   {
00093       this->m_pRegistry = pObject->registry();
00094     }
00095   }

template<class TYPE>
SmartDataPtr< TYPE >::SmartDataPtr ( SmartDataObjectPtr refObject,
IRegistry pDirectory 
) [inline]

Standard constructor: Construct an SmartDataPtr instance which is able to connect to a DataObject instance which is identified by its parent object and the path relative to the parent.

The path is meant to address only ONE level, multiple path layers are invalid.

Parameters:
refObject Smart Pointer to the parent object.
pDirectory Pointer to the data directory entry.

Definition at line 106 of file SmartDataPtr.h.

00107     : SmartDataStorePtr<TYPE,SmartDataObjectPtr::ObjectLoader>( refObject.service(), pDirectory, "")
00108   {
00109   }

template<class TYPE>
SmartDataPtr< TYPE >::SmartDataPtr ( SmartDataObjectPtr refObject,
const std::string &  path 
) [inline]

Standard constructor: Construct an SmartDataPtr instance which is able to connect to a DataObject instance which is identified by its parent object and the path relative to the parent.

The path is meant to address only ONE level, multiple path layers are invalid.

Parameters:
refObject Smart Pointer to the parent object.
path Path to the data object relative to the parent object.

Definition at line 120 of file SmartDataPtr.h.

00121     : SmartDataStorePtr<TYPE,SmartDataObjectPtr::ObjectLoader>( refObject.service(), refObject.directory(), path)
00122   {
00123   }

template<class TYPE>
SmartDataPtr< TYPE >::SmartDataPtr ( const SmartDataObjectPtr copy  )  [inline]

Copy constructor: Construct an copy of a SmartDataPtr instance.

Parameters:
copy Copy Smart Pointer to object.

Definition at line 128 of file SmartDataPtr.h.

template<class TYPE>
virtual SmartDataPtr< TYPE >::~SmartDataPtr (  )  [inline, virtual]

Standard destructor.

Definition at line 135 of file SmartDataPtr.h.

00135                             {
00136   }


Member Function Documentation

template<class TYPE>
template<class OTHER>
SmartDataPtr& SmartDataPtr< TYPE >::operator= ( OTHER *  pObj  )  [inline]

Automatic conversion to data type.

Definition at line 140 of file SmartDataPtr.h.

00140                                             {
00141     this->m_pObject = dynamic_cast<TYPE*>(pObj);
00142     return *this;
00143   }

template<class TYPE>
template<class OTHER>
SmartDataPtr& SmartDataPtr< TYPE >::operator= ( const OTHER *  pObj  )  [inline]

Automatic conversion to data type.

Definition at line 147 of file SmartDataPtr.h.

00147                                                   {
00148     this->m_pObject = dynamic_cast<TYPE*>(const_cast<OTHER*>(pObj));
00149     return *this;
00150   }

TYPE * SmartDataStorePtr< TYPE , SmartDataObjectPtr::ObjectLoader >::ptr (  )  [inline, inherited]

Automatic conversion to data type.

Definition at line 89 of file SmartDataStorePtr.h.

00089                  {
00090     return accessTypeSafeData();
00091   }

TYPE * SmartDataStorePtr< TYPE , SmartDataObjectPtr::ObjectLoader >::operator-> (  )  [inline, inherited]

Dereference operator: the heart of the smart pointer.

Definition at line 94 of file SmartDataStorePtr.h.

00094                         {
00095     return accessTypeSafeData();
00096   }

TYPE & SmartDataStorePtr< TYPE , SmartDataObjectPtr::ObjectLoader >::operator * (  )  [inline, inherited]

Dereference operator: the heart of the smart pointer.

Definition at line 99 of file SmartDataStorePtr.h.

00099                        {
00100     TYPE* result = accessTypeSafeData();
00101     return *result;
00102   }

SmartDataStorePtr< TYPE , SmartDataObjectPtr::ObjectLoader >::operator TYPE * (  )  [inline, inherited]

Automatic conversion to data type.

Definition at line 105 of file SmartDataStorePtr.h.

00105                       {
00106     return accessTypeSafeData();
00107   }

SmartDataStorePtr< TYPE , SmartDataObjectPtr::ObjectLoader >::operator TYPE & (  )  [inline, inherited]

Automatic conversion to data type.

Definition at line 110 of file SmartDataStorePtr.h.

00110                       {
00111     TYPE* result = accessTypeSafeData();
00112     return *result;
00113   }

SmartDataStorePtr< TYPE , SmartDataObjectPtr::ObjectLoader >::operator int (  )  [inline, inherited]

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

Definition at line 116 of file SmartDataStorePtr.h.

00116                    {
00117     return 0 != accessTypeSafeData();
00118   }

bool SmartDataStorePtr< TYPE , SmartDataObjectPtr::ObjectLoader >::operator! (  )  [inline, inherited]

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

Definition at line 121 of file SmartDataStorePtr.h.

00121                       {
00122     return 0 == accessTypeSafeData();
00123   }

TYPE * SmartDataStorePtr< TYPE , SmartDataObjectPtr::ObjectLoader >::accessTypeSafeData (  )  [inline, inherited]

Internal type safe accessor to data.

Definition at line 126 of file SmartDataStorePtr.h.

00126                                  {
00127     if ( 0 == m_pObject )   {
00128       m_pObject = dynamic_cast<TYPE*>(accessData());
00129     }
00130     return m_pObject;
00131   }

SmartDataObjectPtr::operator IRegistry * (  )  [inline, inherited]

Automatic conversion to data directory.

Definition at line 81 of file SmartDataObjectPtr.h.

00081                            {
00082     return m_pRegistry;
00083   }

const std::string& SmartDataObjectPtr::path (  )  const [inline, inherited]

Path name.

Definition at line 86 of file SmartDataObjectPtr.h.

00086                                     {
00087     return m_path;
00088   }

IRegistry* SmartDataObjectPtr::directory (  )  [inline, inherited]

Access to data directory.

Definition at line 91 of file SmartDataObjectPtr.h.

00091                             {
00092     return m_pRegistry;
00093   }

void SmartDataObjectPtr::setService ( IDataProviderSvc svc  )  [inline, inherited]

Assign data service.

Definition at line 96 of file SmartDataObjectPtr.h.

00096                                               {
00097     m_dataProvider = svc;
00098   }

IDataProviderSvc* SmartDataObjectPtr::service (  )  [inline, inherited]

Retrieve data service.

Definition at line 101 of file SmartDataObjectPtr.h.

00101                                  {
00102     return m_dataProvider;
00103   }

StatusCode SmartDataObjectPtr::getLastError (  )  const [inline, inherited]

Access to potential errors during data accesses.

Definition at line 106 of file SmartDataObjectPtr.h.

00106                                       {
00107     return m_status;
00108   }

DataObject* SmartDataObjectPtr::accessData (  )  [inline, inherited]

Static Object retrieval method: must call specific function.

Definition at line 111 of file SmartDataObjectPtr.h.

00111                               {
00112     return m_accessFunc(this);
00113   }

static DataObject* SmartDataObjectPtr::retrieve ( SmartDataObjectPtr ptr  )  [inline, static, inherited]

Static Object retrieval method.

Definition at line 116 of file SmartDataObjectPtr.h.

00116                                                          {
00117     return ptr->retrieveObject();
00118   }

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

Retrieve the specified 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.

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

Retrieve the specified 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.

static DataObject* SmartDataObjectPtr::find ( SmartDataObjectPtr ptr  )  [inline, static, inherited]

Static Object find method.

Definition at line 121 of file SmartDataObjectPtr.h.

00121                                                      {
00122     return ptr->findObject();
00123   }

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

Find the specified 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.

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

Find the specified 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.

static DataObject* SmartDataObjectPtr::update ( SmartDataObjectPtr ptr  )  [inline, static, inherited]

Static Object update method.

Definition at line 126 of file SmartDataObjectPtr.h.

00126                                                        {
00127     return ptr->updateObject();
00128   }

StatusCode SmartDataObjectPtr::update ( IRegistry pDirectory  )  [protected, inherited]

Update the specified object from the data store.

Parameters:
pDirectory Pointer to the directory entry holding the object.
Returns:
StatusCode indicating success or failure.

StatusCode SmartDataObjectPtr::update ( const std::string &  fullPath  )  [protected, inherited]

Update the specified object from the data store.

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

DataObject* SmartDataObjectPtr::retrieveObject (  )  [inherited]

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

DataObject* SmartDataObjectPtr::findObject (  )  [inherited]

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.

DataObject* SmartDataObjectPtr::updateObject (  )  [inherited]

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.


Member Data Documentation

TYPE * SmartDataStorePtr< TYPE , SmartDataObjectPtr::ObjectLoader >::m_pObject [mutable, protected, inherited]

Pointer to data store object.

Definition at line 135 of file SmartDataStorePtr.h.

IDataProviderSvc* SmartDataObjectPtr::m_dataProvider [mutable, protected, inherited]

Pointer to contained object.

Definition at line 194 of file SmartDataObjectPtr.h.

IRegistry* SmartDataObjectPtr::m_pRegistry [mutable, protected, inherited]

Pointer to the data registry containing the object.

Definition at line 196 of file SmartDataObjectPtr.h.

StatusCode SmartDataObjectPtr::m_status [mutable, protected, inherited]

Keep track of the last error.

Definition at line 198 of file SmartDataObjectPtr.h.

std::string SmartDataObjectPtr::m_path [protected, inherited]

Path to object.

Definition at line 200 of file SmartDataObjectPtr.h.

AccessFunction SmartDataObjectPtr::m_accessFunc [protected, inherited]

Data access function.

Definition at line 202 of file SmartDataObjectPtr.h.


The documentation for this class was generated from the following file:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 19:57:14 2011 for GaudiKernel by doxygen 1.4.7