| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

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

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

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Types | Public Member Functions | Public Attributes | List of all members
SmartRefBase Class Reference

User example objects: SmartRefBase. More...

`#include <SmartRefBase.h>`

Collaboration diagram for SmartRefBase:
[legend]

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

{ 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.

{
if ( m_hintID != StreamBuffer::INVALID && m_linkID != StreamBuffer::INVALID ) {
const _Container* cnt = dynamic_cast<const _Container*>(accessData(m_data));
if ( 0 != cnt ) {
return cnt->containedObject(m_linkID);
}
}
return 0;
}

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.

{
DataObject* target = 0;
DataObject* source =0;
if ( 0 == m_data && 0 != m_contd ) {
m_data = m_contd->parent();
}
source = const_cast<DataObject*>(m_data);
if ( m_hintID != StreamBuffer::INVALID && source != 0 ) {
LinkManager* mgr = source->linkMgr();
if ( 0 != mgr ) {
LinkManager::Link* link = mgr->link(m_hintID);
if ( 0 != link ) {
target = link->object();
if ( 0 == target ) {
IRegistry* reg = source->registry();
if ( 0 != reg ) {
IDataProviderSvc* datasvc = reg->dataSvc();
if ( 0 != datasvc ) {
if ( datasvc->retrieveObject(link->path(), target).isSuccess() ) {
link->setObject(target);
}
}
}
}
}
}
}
return target;
}

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

Equality operator for ContainedObject like references.

Definition at line 72 of file SmartRefBase.h.

{
return (m_hintID == c.m_hintID && m_linkID == c.m_linkID &&
m_data == c.m_data && m_contd == c.m_contd);
}

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

Equality operator for DataObject like references.

Definition at line 77 of file SmartRefBase.h.

{
return m_linkID == c.m_linkID && m_data == c.m_data;
}

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

Extended equality check.

Definition at line 77 of file SmartRefBase.cpp.

{
if ( c.m_hintID != StreamBuffer::INVALID && 0 != pObj ) {
DataObject* source = const_cast<DataObject*>(c.m_data);
if ( 0 != source ) {
LinkManager* mgr = source->linkMgr();
if ( 0 != mgr ) {
LinkManager::Link* link = mgr->link(c.m_hintID);
if ( 0 != link ) {
IRegistry* pReg = pObj->registry();
if ( pReg != 0 ) {
return link->path() == pReg->identifier();
}
}
}
}
}
return false;
}

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

Extended equality check.

Definition at line 97 of file SmartRefBase.cpp.

{
if ( isEqualEx(pObj->parent(), c) ) {
return pObj->index() == c.m_linkID;
}
return false;
}

int SmartRefBase::objectType | ( |  | ) | const
| inline

Definition at line 111 of file SmartRefBase.h.

{
return m_type;
}

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

Shortcut to access the path to the linked object.

Definition at line 104 of file SmartRefBase.cpp.

{
static std::string s_empty_string = std::string();
DataObject *source = 0;
if ( 0 == m_data && 0 != m_contd ) {
m_data = m_contd->parent();
}
source = const_cast<DataObject*>(m_data);
if ( m_hintID != StreamBuffer::INVALID && source != 0 ) {
LinkManager* mgr = source->linkMgr();
if ( 0 != mgr ) {
LinkManager::Link* link = mgr->link(m_hintID);
if ( 0 != link )
return link->path();
}
}
return s_empty_string;
}

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

Input streamer for DataObject like references.

Definition at line 89 of file SmartRefBase.h.

{
DataObject* pObj = 0;
s.getIdentifiedLink(pObj, m_hintID);
return pObj;
}

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

Output streamer for ContainedObject like references.

Definition at line 95 of file SmartRefBase.h.

{
ContainedObject* pObj = 0;
s.getContainedLink(pObj, m_hintID, m_linkID);
return pObj;
}

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.

{
m_data = pObj;
m_hintID = hint_id;
m_linkID = link_id;
}

void SmartRefBase::setObjectType | ( | const ContainedObject * |  | ) | const
| inline

Definition at line 100 of file SmartRefBase.h.

{
m_type = CONTAINEDOBJECT;
}

void SmartRefBase::setObjectType | ( | const DataObject * |  | ) | const
| inline

Definition at line 103 of file SmartRefBase.h.

{
m_type = DATAOBJECT;
}

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

Output streamer for DataObject like references.

Definition at line 81 of file SmartRefBase.h.

{
s.addIdentifiedLink(pObject, m_hintID);
}

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

Output streamer for ContainedObject like references.

Definition at line 85 of file SmartRefBase.h.

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

## Member Data Documentation

const ContainedObject* SmartRefBase::m_contd
| mutable

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

Definition at line 56 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.

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.

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_v25r0/GaudiKernel/GaudiKernel/SmartRefBase.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v25r0/GaudiKernel/src/Lib/SmartRefBase.cpp