The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
SmartRefBase Class Reference

User example objects: SmartRefBase. More...

#include </builds/gaudi/Gaudi/GaudiKernel/include/GaudiKernel/SmartRefBase.h>

Collaboration diagram for SmartRefBase:

Public Types

enum  { DATAOBJECT , CONTAINEDOBJECT }
 

Public Member Functions

const ContainedObjectaccessData (const ContainedObject *typ) const
 Load on demand of ContainedObject like references.
 
const DataObjectaccessData (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.
 
DataObjectreadObject (const DataObject *, StreamBuffer &s) const
 Input streamer for DataObject like references.
 
ContainedObjectreadObject (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.
 
long 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 DataObjectm_data
 Object data: Pointer to the identifiable object the link originates.
 
const ContainedObjectm_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 45 of file SmartRefBase.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
DATAOBJECT 
CONTAINEDOBJECT 

Definition at line 58 of file SmartRefBase.h.

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

31 {
33 const _Container* cnt = dynamic_cast<const _Container*>( accessData( m_data ) );
34 if ( cnt ) return cnt->containedObject( m_linkID );
35 }
36 return nullptr;
37}
ObjectContainerBase _Container
virtual const ContainedObject * containedObject(long dist) const =0
Pointer to an object of a given distance.
long m_linkID
Object data: ID of the object within the identifiable container (if any)
const ContainedObject * accessData(const ContainedObject *typ) const
Load on demand of ContainedObject like references.
long m_hintID
Object data: ID of the link hint to the identifiable object.
const DataObject * m_data
Object data: Pointer to the identifiable object the link originates.

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

40 {
41 if ( !m_data && m_contd ) m_data = m_contd->parent();
42 DataObject* source = const_cast<DataObject*>( m_data );
43 if ( m_hintID == StreamBuffer::INVALID || !source ) return nullptr;
44 LinkManager* mgr = source->linkMgr();
45 if ( !mgr ) return nullptr;
46 LinkManager::Link* link = mgr->link( m_hintID );
47 if ( !link ) return nullptr;
48 DataObject* target = link->object();
49 if ( !target ) {
50 IRegistry* reg = source->registry();
51 if ( !reg ) return nullptr;
52 IDataProviderSvc* datasvc = reg->dataSvc();
53 if ( datasvc && datasvc->retrieveObject( link->path(), target ).isSuccess() ) { link->setObject( target ); }
54 }
55 return target;
56}
IRegistry * registry() const
Get pointer to Registry.
Definition DataObject.h:79
LinkManager * linkMgr()
Retrieve Link manager.
Definition DataObject.h:81
virtual StatusCode retrieveObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject)=0
Retrieve object identified by its directory entry.
virtual IDataProviderSvc * dataSvc() const =0
Retrieve pointer to Transient Store.
const ContainedObject * m_contd
Object data: Pointer to the Contained object (if applicable)
bool isSuccess() const
Definition StatusCode.h:314

◆ isEqual() [1/2]

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

Equality operator for ContainedObject like references.

Definition at line 70 of file SmartRefBase.h.

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

◆ isEqual() [2/2]

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

Equality operator for DataObject like references.

Definition at line 74 of file SmartRefBase.h.

74 {
75 return m_linkID == c.m_linkID && m_data == c.m_data;
76 }

◆ isEqualEx() [1/2]

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

Extended equality check.

Definition at line 77 of file SmartRefBase.cpp.

77 {
78 return isEqualEx( pObj->parent(), c ) && pObj->index() == c.m_linkID;
79}
const ObjectContainerBase * parent() const
Access to parent object.
virtual long index() const
Distance in the parent container.
bool isEqualEx(const DataObject *pObj, const SmartRefBase &c) const
Extended equality check.

◆ isEqualEx() [2/2]

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

Extended equality check.

Definition at line 59 of file SmartRefBase.cpp.

59 {
60 if ( c.m_hintID != StreamBuffer::INVALID && pObj ) {
61 DataObject* source = const_cast<DataObject*>( c.m_data );
62 if ( source ) {
63 LinkManager* mgr = source->linkMgr();
64 if ( mgr ) {
65 const LinkManager::Link* link = mgr->link( c.m_hintID );
66 if ( link ) {
67 IRegistry* pReg = pObj->registry();
68 return pReg && link->path() == pReg->identifier();
69 }
70 }
71 }
72 }
73 return false;
74}
virtual const id_type & identifier() const =0
Full identifier (or key)

◆ objectType()

long SmartRefBase::objectType ( ) const
inline

Definition at line 102 of file SmartRefBase.h.

102{ return m_type; }

◆ path()

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

Shortcut to access the path to the linked object.

Definition at line 81 of file SmartRefBase.cpp.

81 {
82 static std::string s_empty_string{};
83 DataObject* source = nullptr;
84 if ( !m_data && m_contd ) m_data = m_contd->parent();
85 source = const_cast<DataObject*>( m_data );
86 if ( m_hintID != StreamBuffer::INVALID && source ) {
87 LinkManager* mgr = source->linkMgr();
88 if ( mgr ) {
89 const LinkManager::Link* link = mgr->link( m_hintID );
90 if ( link ) return link->path();
91 }
92 }
93 return s_empty_string;
94}

◆ readObject() [1/2]

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

Output streamer for ContainedObject like references.

Definition at line 90 of file SmartRefBase.h.

90 {
91 ContainedObject* pObj = 0;
92 s.getContainedLink( pObj, m_hintID, m_linkID );
93 return pObj;
94 }

◆ readObject() [2/2]

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

Input streamer for DataObject like references.

Definition at line 84 of file SmartRefBase.h.

84 {
85 DataObject* pObj = 0;
86 s.getIdentifiedLink( pObj, m_hintID );
87 return pObj;
88 }

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

24 {
25 m_data = pObj;
26 m_hintID = hint_id;
27 m_linkID = link_id;
28}

◆ setObjectType() [1/2]

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

Definition at line 95 of file SmartRefBase.h.

◆ setObjectType() [2/2]

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

Definition at line 96 of file SmartRefBase.h.

96{ m_type = DATAOBJECT; }

◆ writeObject() [1/2]

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

Output streamer for ContainedObject like references.

Definition at line 80 of file SmartRefBase.h.

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

◆ writeObject() [2/2]

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

Output streamer for DataObject like references.

Definition at line 78 of file SmartRefBase.h.

78{ s.addIdentifiedLink( pObject, m_hintID ); }

Member Data Documentation

◆ m_contd

const ContainedObject* SmartRefBase::m_contd
mutable

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

Definition at line 54 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 52 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 48 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 50 of file SmartRefBase.h.

◆ m_type

long SmartRefBase::m_type
mutable

Definition at line 56 of file SmartRefBase.h.


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