| # Gaudi Framework, version v21r10p1 |

Home |  | Generated: 29 Jul 2010

# 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]

List of all members.

## 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.
| SmartDataObjectPtr (const SmartDataObjectPtr &copy)
| Copy constructor: Construct an copy of a SmartDataStorePtr instance.
virtual | ~SmartDataObjectPtr ()
| Standard Destructor.
virtual SmartDataObjectPtr & | operator= (const SmartDataObjectPtr &copy)
| Assignment operator.
| operator IRegistry * ()
| Automatic conversion to data directory.
const std::string & | path () const
| Path name.
IRegistry * | directory ()
| Access to data directory.
void | setService (IDataProviderSvc *svc)
| Assign data service.
IDataProviderSvc * | service ()
| Retrieve data service.
StatusCode | getLastError () const
| Access to potential errors during data accesses.
DataObject * | accessData ()
| Static Object retrieval method: must call specific function.
DataObject * | retrieveObject ()
| Object retrieve method.
DataObject * | findObject ()
| Object find method.
DataObject * | updateObject ()
| Object update method.
## Static Public Member Functions
static DataObject * | retrieve (SmartDataObjectPtr *ptr)
| Static Object retrieval method.
static DataObject * | find (SmartDataObjectPtr *ptr)
| Static Object find method.
static DataObject * | update (SmartDataObjectPtr *ptr)
| Static Object update method.
## Protected Member Functions
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 | 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 | 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
IDataProviderSvc * | m_dataProvider
| Pointer to contained object.
IRegistry * | m_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.
## Classes
class | ObjectFinder
| Helper class to configure smart pointer functionality. More...
class | ObjectLoader
| Helper class to configure smart pointer functionality. 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)

## Constructor & Destructor Documentation

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

    00056     : m_dataProvider(pService),
    00057       m_pRegistry(pDir),
    00058       m_status(StatusCode::SUCCESS,true),
    00059       m_path(path),
    00060       m_accessFunc(access)
    00061   {
    00062   }

SmartDataObjectPtr::SmartDataObjectPtr | ( | const SmartDataObjectPtr & | copy | ) | `[inline]`

Copy constructor: Construct an copy of a SmartDataStorePtr instance.

Parameters:

  | copy | Copy of Smart Pointer to object.

Definition at line 66 of file SmartDataObjectPtr.h.

    00067     : m_dataProvider(copy.m_dataProvider),
    00068       m_pRegistry(copy.m_pRegistry),
    00069       m_status(copy.m_status),
    00070       m_path(copy.m_path),
    00071       m_accessFunc(copy.m_accessFunc)
    00072   {
    00073   }

virtual SmartDataObjectPtr::~SmartDataObjectPtr | ( |  | ) | `[inline, virtual]`

Standard Destructor.

Definition at line 75 of file SmartDataObjectPtr.h.

    00075                                  {
    00076   }

## Member Function Documentation

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.

    00027                                                                                   {
    00028   m_path          = copy.m_path;
    00029   m_pRegistry     = copy.m_pRegistry;
    00030   m_dataProvider  = copy.m_dataProvider;
    00031   return *this;
    00032 }

SmartDataObjectPtr::operator IRegistry * | ( |  | ) | `[inline]`

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]`

Path name.

Definition at line 86 of file SmartDataObjectPtr.h.

    00086                                     {
    00087     return m_path;
    00088   }

IRegistry* SmartDataObjectPtr::directory | ( |  | ) | `[inline]`

Access to data directory.

Definition at line 91 of file SmartDataObjectPtr.h.

    00091                             {
    00092     return m_pRegistry;
    00093   }

void SmartDataObjectPtr::setService | ( | IDataProviderSvc * | svc | ) | `[inline]`

Assign data service.

Definition at line 96 of file SmartDataObjectPtr.h.

    00096                                               {
    00097     m_dataProvider = svc;
    00098   }

IDataProviderSvc* SmartDataObjectPtr::service | ( |  | ) | `[inline]`

Retrieve data service.

Definition at line 101 of file SmartDataObjectPtr.h.

    00101                                  {
    00102     return m_dataProvider;
    00103   }

StatusCode SmartDataObjectPtr::getLastError | ( |  | ) | const`[inline]`

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]`

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]`

Static Object retrieval method.

Definition at line 116 of file SmartDataObjectPtr.h.

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

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

Static Object find method.

Definition at line 121 of file SmartDataObjectPtr.h.

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

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

Static Object update method.

Definition at line 126 of file SmartDataObjectPtr.h.

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

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.

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.

    00094                                                  {
    00095   DataObject* pObj = 0;
    00096   m_status = (0==m_pRegistry) ? retrieve(m_path,pObj) : retrieve(m_pRegistry,m_path,pObj);
    00097   if ( m_status.isSuccess() )   {
    00098     m_pRegistry = pObj->registry();
    00099     m_path = "";
    00100   }
    00101   return pObj;
    00102 }

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.

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.

    00109                                              {
    00110   DataObject* pObj = 0;
    00111   m_status = (0==m_pRegistry) ? find(m_path,pObj) : find(m_pRegistry,m_path,pObj);
    00112   if ( m_status.isSuccess() )   {
    00113     m_pRegistry = pObj->registry();
    00114     m_path = "";
    00115   }
    00116   return pObj;
    00117 }

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.

    00124                                                {
    00125   DataObject* pObj = accessData();    // Have to load AND update if not present.
    00126   if ( m_status.isSuccess() )   {
    00127     m_status = (0 == m_pRegistry) ? update(m_path) : update(m_pRegistry);
    00128     if ( !m_status.isSuccess() )  pObj = 0;
    00129   }
    00130   return pObj;
    00131 }

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

    00053                                                                                                             {
    00054   StatusCode status = StatusCode::FAILURE;
    00055   if ( 0 != m_dataProvider && 0 != pDirectory )    {
    00056     status = m_dataProvider->findObject(pDirectory, path, refpObject);
    00057   }
    00058   return status;
    00059 }

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

    00062                                                                                          {
    00063   StatusCode status = StatusCode::FAILURE;
    00064   if ( 0 != m_dataProvider )    {
    00065     status = m_dataProvider->findObject(fullPath, refpObject);
    00066   }
    00067   return status;
    00068 }

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

    00035                                                                                                                {
    00036   StatusCode status = StatusCode::FAILURE;
    00037   if ( 0 != m_dataProvider && 0 != pRegistry )    {
    00038     status = m_dataProvider->retrieveObject(pRegistry, path, refpObject);
    00039   }
    00040   return status;
    00041 }

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

    00044                                                                                              {
    00045   StatusCode status = StatusCode::FAILURE;
    00046   if ( 0 != m_dataProvider )    {
    00047     status = m_dataProvider->retrieveObject(fullPath, refpObject);
    00048   }
    00049   return status;
    00050 }

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

    00072                                                              {
    00073   StatusCode status = StatusCode::FAILURE;
    00074   if ( 0 != m_dataProvider && 0 != pRegistry )    {
    00075     status = m_dataProvider->updateObject(pRegistry);
    00076   }
    00077   return status;
    00078 }

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

    00081                                                                   {
    00082   StatusCode status = StatusCode::FAILURE;
    00083   if ( 0 != m_dataProvider )    {
    00084     status = m_dataProvider->updateObject(fullPath);
    00085   }
    00086   return status;
    00087 }

## Member Data Documentation

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

Pointer to contained object.

Definition at line 194 of file SmartDataObjectPtr.h.

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

Pointer to the data registry containing the object.

Definition at line 196 of file SmartDataObjectPtr.h.

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

Keep track of the last error.

Definition at line 198 of file SmartDataObjectPtr.h.

std::string SmartDataObjectPtr::m_path`[protected]`

Path to object.

Definition at line 200 of file SmartDataObjectPtr.h.

AccessFunction SmartDataObjectPtr::m_accessFunc`[protected]`

Data access function.

Definition at line 202 of file SmartDataObjectPtr.h.

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r10p1/GaudiKernel/GaudiKernel/SmartDataObjectPtr.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r10p1/GaudiKernel/src/Lib/SmartDataObjectPtr.cpp