| The Gaudi Framework v32r1 (f65d50dc)

Public Types | Public Member Functions | Public Attributes | List of all members
SmartRefBase Class Reference

User example objects: SmartRefBase. More...

`#include <GaudiKernel/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. More...
const DataObject * | accessData (const DataObject *typ) const
| Load on demand of DataObject like references. More...
bool | isEqualEx (const DataObject *pObj, const SmartRefBase &c) const
| Extended equality check. More...
bool | isEqualEx (const ContainedObject *pObj, const SmartRefBase &c) const
| Extended equality check. More...
bool | isEqual (const ContainedObject *, const SmartRefBase &c) const
| Equality operator for ContainedObject like references. More...
bool | isEqual (const DataObject *, const SmartRefBase &c) const
| Equality operator for DataObject like references. More...
void | writeObject (const DataObject *pObject, StreamBuffer &s) const
| Output streamer for DataObject like references. More...
void | writeObject (const ContainedObject *pObject, StreamBuffer &s) const
| Output streamer for ContainedObject like references. More...
DataObject * | readObject (const DataObject *, StreamBuffer &s) const
| Input streamer for DataObject like references. More...
ContainedObject * | readObject (const ContainedObject *, StreamBuffer &s) const
| Output streamer for ContainedObject like references. More...
void | setObjectType (const ContainedObject *) const
void | setObjectType (const DataObject *) const
const std::string & | path () const
| Shortcut to access the path to the linked object. More...
int | objectType () const
void | set (DataObject *pObj, long hint_id, long link_id)
| Setup smart reference when reading. Must be allowed from external sources. More...

## Public Attributes
long | m_hintID
| Object data: ID of the link hint to the identifiable object. More...
long | m_linkID
| Object data: ID of the object within the identifiable container (if any) More...
const DataObject * | m_data
| Object data: Pointer to the identifiable object the link originates. More...
const ContainedObject * | m_contd
| Object data: Pointer to the Contained object (if applicable) More...
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

anonymous enum

Enumerator
DATAOBJECT |
CONTAINEDOBJECT |

Definition at line 60 of file SmartRefBase.h.

60 { DATAOBJECT, CONTAINEDOBJECT };
SmartRefBase::DATAOBJECT
Definition: SmartRefBase.h:60
SmartRefBase::CONTAINEDOBJECT
Definition: SmartRefBase.h:60

## Member Function Documentation

## ◆ accessData() [1/2]

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

Load on demand of ContainedObject like references.

Load on demand: ContainedObject type references.

Definition at line 33 of file SmartRefBase.cpp.

33 {
34 if ( m_hintID != StreamBuffer::INVALID && m_linkID != StreamBuffer::INVALID ) {
35 const _Container* cnt = dynamic_cast<const _Container*>( accessData( m_data ) );
36 if ( cnt ) return cnt->containedObject( m_linkID );
37 }
38 return nullptr;
39 }
SmartRefBase::m_data
const DataObject * m_data
Object data: Pointer to the identifiable object the link originates.
Definition: SmartRefBase.h:54
SmartRefBase::m_hintID
long m_hintID
Object data: ID of the link hint to the identifiable object.
Definition: SmartRefBase.h:50
SmartRefBase::accessData
const ContainedObject * accessData(const ContainedObject *typ) const
Load on demand of ContainedObject like references.
Definition: SmartRefBase.cpp:33
ObjectContainerBase::containedObject
virtual const ContainedObject * containedObject(long dist) const =0
Pointer to an object of a given distance.
SmartRefBase::m_linkID
long m_linkID
Object data: ID of the object within the identifiable container (if any)
Definition: SmartRefBase.h:52
ObjectContainerBase
ObjectContainerBase is the base class for Gaudi container classes.
Definition: ObjectContainerBase.h:19
StreamBuffer::INVALID
Definition: StreamBuffer.h:111

## ◆ accessData() [2/2]

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

Load on demand of DataObject like references.

Load on demand: DataObject type references.

Definition at line 42 of file SmartRefBase.cpp.

42 {
43 DataObject* target = nullptr;
44 DataObject* source = nullptr;
45 if ( !m_data && m_contd ) m_data = m_contd->parent();
46 source = const_cast<DataObject*>( m_data );
47 if ( m_hintID != StreamBuffer::INVALID && source ) {
48 LinkManager* mgr = source->linkMgr();
49 if ( mgr ) {
50 LinkManager::Link* link = mgr->link( m_hintID );
51 if ( link ) {
52 target = link->object();
53 if ( !target ) {
54 IRegistry* reg = source->registry();
55 if ( reg ) {
56 IDataProviderSvc* datasvc = reg->dataSvc();
57 if ( datasvc && datasvc->retrieveObject( link->path(), target ).isSuccess() ) { link->setObject( target ); }
58 }
59 }
60 }
61 }
62 }
63 return target;
64 }
LinkManager::Link::object
const DataObject * object() const
Const access to data object.
Definition: LinkManager.h:58
DataObject::registry
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:72
SmartRefBase::m_data
const DataObject * m_data
Object data: Pointer to the identifiable object the link originates.
Definition: SmartRefBase.h:54
DataObject::linkMgr
LinkManager * linkMgr() const
Retrieve Link manager.
Definition: DataObject.h:74
SmartRefBase::m_hintID
long m_hintID
Object data: ID of the link hint to the identifiable object.
Definition: SmartRefBase.h:50
IDataProviderSvc
Data provider interface definition.
Definition: IDataProviderSvc.h:43
SmartRefBase::m_contd
const ContainedObject * m_contd
Object data: Pointer to the Contained object (if applicable)
Definition: SmartRefBase.h:56
LinkManager::Link::setObject
void setObject(const DataObject *pObject)
Update object pointer.
Definition: LinkManager.h:56
LinkManager::Link::path
const std::string & path() const
Access to path of object.
Definition: LinkManager.h:61
LinkManager::link
Link * link(long id)
Retrieve symbolic link identified by ID.
Definition: LinkManager.cpp:29
IRegistry
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
IDataProviderSvc::retrieveObject
virtual StatusCode retrieveObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject)=0
Retrieve object identified by its directory entry.
IRegistry::dataSvc
virtual IDataProviderSvc * dataSvc() const =0
Retrieve pointer to Transient Store.
ContainedObject::parent
const ObjectContainerBase * parent() const
Access to parent object.
Definition: ContainedObject.h:51
StreamBuffer::INVALID
Definition: StreamBuffer.h:111
LinkManager::Link
Embedded class defining a symbolic link Note: No copy constructor; bitwise copy (done by the compiler...
Definition: LinkManager.h:31
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
LinkManager
A LinkManager is the object aggregated into a DataObject, which is responsible for the handling of no...
Definition: LinkManager.h:21

## ◆ isEqual() [1/2]

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

Equality operator for ContainedObject like references.

Definition at line 72 of file SmartRefBase.h.

72 {
73 return ( m_hintID == c.m_hintID && m_linkID == c.m_linkID && m_data == c.m_data && m_contd == c.m_contd );
74 }
gaudirun.c
c
Definition: gaudirun.py:487
SmartRefBase::m_data
const DataObject * m_data
Object data: Pointer to the identifiable object the link originates.
Definition: SmartRefBase.h:54
SmartRefBase::m_hintID
long m_hintID
Object data: ID of the link hint to the identifiable object.
Definition: SmartRefBase.h:50
SmartRefBase::m_contd
const ContainedObject * m_contd
Object data: Pointer to the Contained object (if applicable)
Definition: SmartRefBase.h:56
SmartRefBase::m_linkID
long m_linkID
Object data: ID of the object within the identifiable container (if any)
Definition: SmartRefBase.h:52

## ◆ isEqual() [2/2]

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

Equality operator for DataObject like references.

Definition at line 76 of file SmartRefBase.h.

76 {
77 return m_linkID == c.m_linkID && m_data == c.m_data;
78 }
gaudirun.c
c
Definition: gaudirun.py:487
SmartRefBase::m_data
const DataObject * m_data
Object data: Pointer to the identifiable object the link originates.
Definition: SmartRefBase.h:54
SmartRefBase::m_linkID
long m_linkID
Object data: ID of the object within the identifiable container (if any)
Definition: SmartRefBase.h:52

## ◆ isEqualEx() [1/2]

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

Extended equality check.

Definition at line 67 of file SmartRefBase.cpp.

67 {
68 if ( c.m_hintID != StreamBuffer::INVALID && pObj ) {
69 DataObject* source = const_cast<DataObject*>( c.m_data );
70 if ( source ) {
71 LinkManager* mgr = source->linkMgr();
72 if ( mgr ) {
73 LinkManager::Link* link = mgr->link( c.m_hintID );
74 if ( link ) {
75 IRegistry* pReg = pObj->registry();
76 return pReg && link->path() == pReg->identifier();
77 }
78 }
79 }
80 }
81 return false;
82 }
gaudirun.c
c
Definition: gaudirun.py:487
DataObject::registry
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:72
DataObject::linkMgr
LinkManager * linkMgr() const
Retrieve Link manager.
Definition: DataObject.h:74
LinkManager::Link::path
const std::string & path() const
Access to path of object.
Definition: LinkManager.h:61
LinkManager::link
Link * link(long id)
Retrieve symbolic link identified by ID.
Definition: LinkManager.cpp:29
IRegistry
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
IRegistry::identifier
virtual const id_type & identifier() const =0
Full identifier (or key)
StreamBuffer::INVALID
Definition: StreamBuffer.h:111
LinkManager::Link
Embedded class defining a symbolic link Note: No copy constructor; bitwise copy (done by the compiler...
Definition: LinkManager.h:31
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
LinkManager
A LinkManager is the object aggregated into a DataObject, which is responsible for the handling of no...
Definition: LinkManager.h:21

## ◆ isEqualEx() [2/2]

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

Extended equality check.

Definition at line 85 of file SmartRefBase.cpp.

85 {
86 return isEqualEx( pObj->parent(), c ) && pObj->index() == c.m_linkID;
87 }
gaudirun.c
c
Definition: gaudirun.py:487
SmartRefBase::isEqualEx
bool isEqualEx(const DataObject *pObj, const SmartRefBase &c) const
Extended equality check.
Definition: SmartRefBase.cpp:67
ContainedObject::index
virtual long index() const
Distance in the parent container.
Definition: ContainedObject.h:56
ContainedObject::parent
const ObjectContainerBase * parent() const
Access to parent object.
Definition: ContainedObject.h:51

## ◆ objectType()

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

Definition at line 104 of file SmartRefBase.h.

104 { return m_type; }
SmartRefBase::m_type
long m_type
Definition: SmartRefBase.h:58

## ◆ path()

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

Shortcut to access the path to the linked object.

Definition at line 89 of file SmartRefBase.cpp.

89 {
90 static std::string s_empty_string{};
91 DataObject* source = nullptr;
92 if ( !m_data && m_contd ) m_data = m_contd->parent();
93 source = const_cast<DataObject*>( m_data );
94 if ( m_hintID != StreamBuffer::INVALID && source ) {
95 LinkManager* mgr = source->linkMgr();
96 if ( mgr ) {
97 LinkManager::Link* link = mgr->link( m_hintID );
98 if ( link ) return link->path();
99 }
100 }
101 return s_empty_string;
102 }
SmartRefBase::m_data
const DataObject * m_data
Object data: Pointer to the identifiable object the link originates.
Definition: SmartRefBase.h:54
DataObject::linkMgr
LinkManager * linkMgr() const
Retrieve Link manager.
Definition: DataObject.h:74
SmartRefBase::m_hintID
long m_hintID
Object data: ID of the link hint to the identifiable object.
Definition: SmartRefBase.h:50
std::string
STL class.
SmartRefBase::m_contd
const ContainedObject * m_contd
Object data: Pointer to the Contained object (if applicable)
Definition: SmartRefBase.h:56
LinkManager::Link::path
const std::string & path() const
Access to path of object.
Definition: LinkManager.h:61
LinkManager::link
Link * link(long id)
Retrieve symbolic link identified by ID.
Definition: LinkManager.cpp:29
ContainedObject::parent
const ObjectContainerBase * parent() const
Access to parent object.
Definition: ContainedObject.h:51
StreamBuffer::INVALID
Definition: StreamBuffer.h:111
LinkManager::Link
Embedded class defining a symbolic link Note: No copy constructor; bitwise copy (done by the compiler...
Definition: LinkManager.h:31
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
LinkManager
A LinkManager is the object aggregated into a DataObject, which is responsible for the handling of no...
Definition: LinkManager.h:21

## ◆ readObject() [1/2]

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

Input streamer for DataObject like references.

Definition at line 86 of file SmartRefBase.h.

86 {
87 DataObject* pObj = 0;
88 s.getIdentifiedLink( pObj, m_hintID );
89 return pObj;
90 }
SmartRefBase::m_hintID
long m_hintID
Object data: ID of the link hint to the identifiable object.
Definition: SmartRefBase.h:50
gaudirun.s
string s
Definition: gaudirun.py:316
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30

## ◆ readObject() [2/2]

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

Output streamer for ContainedObject like references.

Definition at line 92 of file SmartRefBase.h.

92 {
93 ContainedObject* pObj = 0;
94 s.getContainedLink( pObj, m_hintID, m_linkID );
95 return pObj;
96 }
SmartRefBase::m_hintID
long m_hintID
Object data: ID of the link hint to the identifiable object.
Definition: SmartRefBase.h:50
SmartRefBase::m_linkID
long m_linkID
Object data: ID of the object within the identifiable container (if any)
Definition: SmartRefBase.h:52
ContainedObject
All classes that their objects may be contained in an LHCb ObjectContainer (e.g.
Definition: ContainedObject.h:31
gaudirun.s
string s
Definition: gaudirun.py:316

## ◆ set()

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 26 of file SmartRefBase.cpp.

26 {
27 m_data = pObj;
28 m_hintID = hint_id;
29 m_linkID = link_id;
30 }
SmartRefBase::m_data
const DataObject * m_data
Object data: Pointer to the identifiable object the link originates.
Definition: SmartRefBase.h:54
SmartRefBase::m_hintID
long m_hintID
Object data: ID of the link hint to the identifiable object.
Definition: SmartRefBase.h:50
SmartRefBase::m_linkID
long m_linkID
Object data: ID of the object within the identifiable container (if any)
Definition: SmartRefBase.h:52

## ◆ setObjectType() [1/2]

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

Definition at line 97 of file SmartRefBase.h.

97 { m_type = CONTAINEDOBJECT; }
SmartRefBase::CONTAINEDOBJECT
Definition: SmartRefBase.h:60
SmartRefBase::m_type
long m_type
Definition: SmartRefBase.h:58

## ◆ setObjectType() [2/2]

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

Definition at line 98 of file SmartRefBase.h.

98 { m_type = DATAOBJECT; }
SmartRefBase::DATAOBJECT
Definition: SmartRefBase.h:60
SmartRefBase::m_type
long m_type
Definition: SmartRefBase.h:58

## ◆ writeObject() [1/2]

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

Output streamer for DataObject like references.

Definition at line 80 of file SmartRefBase.h.

80 { s.addIdentifiedLink( pObject, m_hintID ); }
SmartRefBase::m_hintID
long m_hintID
Object data: ID of the link hint to the identifiable object.
Definition: SmartRefBase.h:50
gaudirun.s
string s
Definition: gaudirun.py:316

## ◆ writeObject() [2/2]

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

Output streamer for ContainedObject like references.

Definition at line 82 of file SmartRefBase.h.

82 {
83 s.addContainedLink( pObject, m_hintID, m_linkID );
84 }
SmartRefBase::m_hintID
long m_hintID
Object data: ID of the link hint to the identifiable object.
Definition: SmartRefBase.h:50
SmartRefBase::m_linkID
long m_linkID
Object data: ID of the object within the identifiable container (if any)
Definition: SmartRefBase.h:52
gaudirun.s
string s
Definition: gaudirun.py:316

## Member Data Documentation

## ◆ m_contd

const ContainedObject* SmartRefBase::m_contd
| mutable

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

Definition at line 56 of file SmartRefBase.h.

## ◆ m_data

const DataObject* SmartRefBase::m_data
| mutable

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

Definition at line 54 of file SmartRefBase.h.

## ◆ m_hintID

long SmartRefBase::m_hintID
| mutable

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

Definition at line 50 of file SmartRefBase.h.

## ◆ m_linkID

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.

## ◆ m_type

long SmartRefBase::m_type
| mutable

Definition at line 58 of file SmartRefBase.h.

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

- GaudiKernel/GaudiKernel/SmartRefBase.h
- GaudiKernel/src/Lib/SmartRefBase.cpp