| # Gaudi Framework, version v21r7 |

Home |  | Generated: 22 Jan 2010

# SmartRefBase Class Reference

User example objects: SmartRefBase. More...

`#include <SmartRefBase.h>`

Collaboration diagram for SmartRefBase:

[legend]

List of all members.

## Public Types
enum | { DATAOBJECT, CONTAINEDOBJECT }
## Public Member Functions
const ContainedObject * | accessData (const ContainedObject *typ) const
| Load on demand of ContainedObject like references.
const DataObject * | accessData (const DataObject *typ) const
| Load on demand of DataObject like references.
bool | isEqualEx (const DataObject *pObj, const SmartRefBase &c) const
| Extended equality check.
bool | isEqualEx (const ContainedObject *pObj, const SmartRefBase &c) const
| Extended equality check.
bool | isEqual (const ContainedObject *, const SmartRefBase &c) const
| Equality operator for ContainedObject like references.
bool | isEqual (const DataObject *, const SmartRefBase &c) const
| Equality operator for DataObject like references.
void | writeObject (const DataObject *pObject, StreamBuffer &s) const
| Output streamer for DataObject like references.
void | writeObject (const ContainedObject *pObject, StreamBuffer &s) const
| Output streamer for ContainedObject like references.
DataObject * | readObject (const DataObject *, StreamBuffer &s) const
| Input streamer for DataObject like references.
ContainedObject * | readObject (const ContainedObject *, StreamBuffer &s) const
| Output streamer for ContainedObject like references.
void | setObjectType (const ContainedObject *) const
void | setObjectType (const DataObject *) const
const std::string & | path () const
| Shortcut to access the path to the linked object.
int | objectType () const
void | set (DataObject *pObj, long hint_id, long link_id)
| Setup smart reference when reading. Must be allowed from external sources.
## Public Attributes
long | m_hintID
| Object data: ID of the link hint to the identifiable object.
long | m_linkID
| Object data: ID of the object within the identifiable container (if any).
const DataObject * | m_data
| Object data: Pointer to the identifiable object the link originates.
const ContainedObject * | m_contd
| Object data: Pointer to the Contained object (if applicable).
long | m_type

## Detailed Description

User example objects: SmartRefBase.

Description: Base class of SmartReference objects. The base class handles the object requests to the data store. The separation of the SmartReference and the base class is mainly to avoid code blow up, because if the object is not yet present serious work must be performed in order to request the object from the store and invoke object updates to keep pointers in sync.

Base Class: None

Dependencies: None

History :

        +---------+----------------------------------------------+--------+
        |    Date |                 Comment                      | Who    |
        +---------+----------------------------------------------+--------+
        | 21/06/99| Initial version.                             | MF     |
        +---------+----------------------------------------------+--------+

Author: M.Frank Version: 1.0

Definition at line 47 of file SmartRefBase.h.

## Member Enumeration Documentation

anonymous enum

Enumerator:

  DATAOBJECT |
  CONTAINEDOBJECT |

Definition at line 60 of file SmartRefBase.h.

    00060 { DATAOBJECT, CONTAINEDOBJECT };

## Member Function Documentation

const ContainedObject * SmartRefBase::accessData | ( | const ContainedObject * | typ | ) | const

Load on demand of ContainedObject like references.

Load on demand: ContainedObject type references.

Definition at line 35 of file SmartRefBase.cpp.

    00035                                                                                 {
    00036   if ( m_hintID != StreamBuffer::INVALID && m_linkID != StreamBuffer::INVALID )   {
    00037     const _Container* cnt = dynamic_cast<const _Container*>(accessData(m_data));
    00038     if ( 0 != cnt )  {
    00039       return cnt->containedObject(m_linkID);
    00040     }
    00041   }
    00042   return 0;
    00043 }

const DataObject * SmartRefBase::accessData | ( | const DataObject * | typ | ) | const

Load on demand of DataObject like references.

Load on demand: DataObject type references.

Definition at line 46 of file SmartRefBase.cpp.

    00046                                                                       {
    00047   DataObject* target = 0;
    00048   DataObject* source  =0;
    00049   if ( 0 == m_data && 0 != m_contd )  {
    00050     m_data = m_contd->parent();
    00051   }
    00052   source  = const_cast<DataObject*>(m_data);
    00053   if ( m_hintID != StreamBuffer::INVALID && source != 0 )   {
    00054     LinkManager* mgr = source->linkMgr();
    00055     if ( 0 != mgr )   {
    00056       LinkManager::Link* link = mgr->link(m_hintID);
    00057       if ( 0 != link )  {
    00058         target = link->object();
    00059         if ( 0 == target )    {
    00060           IRegistry* reg = source->registry();
    00061           if ( 0 != reg )   {
    00062             IDataProviderSvc* datasvc = reg->dataSvc();
    00063             if ( 0 != datasvc )   {
    00064               if ( datasvc->retrieveObject(link->path(), target).isSuccess() )   {
    00065                 link->setObject(target);
    00066               }
    00067             }
    00068           }
    00069         }
    00070       }
    00071     }
    00072   }
    00073   return target;
    00074 }

bool SmartRefBase::isEqualEx | ( | const DataObject * | pObj,
|  | const SmartRefBase & | c |
| ) |  |  | const

Extended equality check.

Definition at line 77 of file SmartRefBase.cpp.

    00077                                                                                     {
    00078   if ( c.m_hintID != StreamBuffer::INVALID && 0 != pObj )   {
    00079     DataObject* source  = const_cast<DataObject*>(c.m_data);
    00080     if ( 0 != source )   {
    00081       LinkManager* mgr = source->linkMgr();
    00082       if ( 0 != mgr )   {
    00083         LinkManager::Link* link = mgr->link(c.m_hintID);
    00084         if ( 0 != link )  {
    00085           IRegistry* pReg = pObj->registry();
    00086           if ( pReg != 0 )   {
    00087             return link->path() == pReg->identifier();
    00088           }
    00089         }
    00090       }
    00091     }
    00092   }
    00093   return false;
    00094 }

bool SmartRefBase::isEqualEx | ( | const ContainedObject * | pObj,
|  | const SmartRefBase & | c |
| ) |  |  | const

Extended equality check.

Definition at line 97 of file SmartRefBase.cpp.

    00097                                                                                         {
    00098   if ( isEqualEx(pObj->parent(), c) )   {
    00099     return pObj->index() == c.m_linkID;
    00100   }
    00101   return false;
    00102 }

bool SmartRefBase::isEqual | ( | const ContainedObject * | ,
|  | const SmartRefBase & | c |
| ) |  |  | const`[inline]`

Equality operator for ContainedObject like references.

Definition at line 72 of file SmartRefBase.h.

    00072                                                                                            {
    00073     return (m_hintID == c.m_hintID && m_linkID == c.m_linkID &&
    00074             m_data   == c.m_data   && m_contd  == c.m_contd);
    00075   }

bool SmartRefBase::isEqual | ( | const DataObject * | ,
|  | const SmartRefBase & | c |
| ) |  |  | const`[inline]`

Equality operator for DataObject like references.

Definition at line 77 of file SmartRefBase.h.

    00077                                                                                         {
    00078     return m_linkID == c.m_linkID && m_data   == c.m_data;
    00079   }

void SmartRefBase::writeObject | ( | const DataObject * | pObject,
|  | StreamBuffer & | s |
| ) |  |  | const`[inline]`

Output streamer for DataObject like references.

Definition at line 81 of file SmartRefBase.h.

    00081                                                                           {
    00082     s.addIdentifiedLink(pObject, m_hintID);
    00083   }

void SmartRefBase::writeObject | ( | const ContainedObject * | pObject,
|  | StreamBuffer & | s |
| ) |  |  | const`[inline]`

Output streamer for ContainedObject like references.

Definition at line 85 of file SmartRefBase.h.

    00085                                                                                 {
    00086     s.addContainedLink(pObject, m_hintID, m_linkID);
    00087   }

DataObject* SmartRefBase::readObject | ( | const DataObject * | ,
|  | StreamBuffer & | s |
| ) |  |  | const`[inline]`

Input streamer for DataObject like references.

Definition at line 89 of file SmartRefBase.h.

    00089                                                                                        {
    00090     DataObject* pObj = 0;
    00091     s.getIdentifiedLink(pObj, m_hintID);
    00092     return pObj;
    00093   }

ContainedObject* SmartRefBase::readObject | ( | const ContainedObject * | ,
|  | StreamBuffer & | s |
| ) |  |  | const`[inline]`

Output streamer for ContainedObject like references.

Definition at line 95 of file SmartRefBase.h.

    00095                                                                                                {
    00096     ContainedObject* pObj = 0;
    00097     s.getContainedLink(pObj, m_hintID, m_linkID);
    00098     return pObj;
    00099   }

void SmartRefBase::setObjectType | ( | const ContainedObject * |  | ) | const`[inline]`

Definition at line 100 of file SmartRefBase.h.

    00100                                                               {
    00101     m_type = CONTAINEDOBJECT;
    00102   }

void SmartRefBase::setObjectType | ( | const DataObject * |  | ) | const`[inline]`

Definition at line 103 of file SmartRefBase.h.

    00103                                                           {
    00104     m_type = DATAOBJECT;
    00105   }

const std::string & SmartRefBase::path | ( |  | ) | const

Shortcut to access the path to the linked object.

Definition at line 104 of file SmartRefBase.cpp.

    00104                                            {
    00105   static std::string s_empty_string = std::string();
    00106   DataObject *source = 0;
    00107   if ( 0 == m_data && 0 != m_contd )  {
    00108     m_data = m_contd->parent();
    00109   }
    00110   source = const_cast<DataObject*>(m_data);
    00111   if ( m_hintID != StreamBuffer::INVALID && source != 0 ) {
    00112     LinkManager* mgr = source->linkMgr();
    00113     if ( 0 != mgr ) {
    00114       LinkManager::Link* link = mgr->link(m_hintID);
    00115       if ( 0 != link )
    00116         return link->path();
    00117     }
    00118   }
    00119   return s_empty_string;
    00120 }

int SmartRefBase::objectType | ( |  | ) | const`[inline]`

Definition at line 111 of file SmartRefBase.h.

    00111                           {
    00112     return m_type;
    00113   }

void SmartRefBase::set | ( | DataObject * | pObj,
|  | long | hint_id,
|  | long | link_id |
| ) |  |  |

Setup smart reference when reading. Must be allowed from external sources.

Setup smart reference.

Definition at line 28 of file SmartRefBase.cpp.

    00028                                                                     {
    00029   m_data = pObj;
    00030   m_hintID = hint_id;
    00031   m_linkID = link_id;
    00032 }

## Member Data Documentation

long SmartRefBase::m_hintID`[mutable]`

Object data: ID of the link hint to the identifiable object.

Definition at line 50 of file SmartRefBase.h.

long SmartRefBase::m_linkID`[mutable]`

Object data: ID of the object within the identifiable container (if any).

Definition at line 52 of file SmartRefBase.h.

const DataObject* SmartRefBase::m_data`[mutable]`

Object data: Pointer to the identifiable object the link originates.

Definition at line 54 of file SmartRefBase.h.

const ContainedObject* SmartRefBase::m_contd`[mutable]`

Object data: Pointer to the Contained object (if applicable).

Definition at line 56 of file SmartRefBase.h.

long SmartRefBase::m_type`[mutable]`

Definition at line 58 of file SmartRefBase.h.

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r7/GaudiKernel/GaudiKernel/SmartRefBase.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r7/GaudiKernel/src/Lib/SmartRefBase.cpp