The Gaudi Framework  master (37c0b60a)
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. More...
 
const DataObjectaccessData (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...
 
DataObjectreadObject (const DataObject *, StreamBuffer &s) const
 Input streamer for DataObject like references. More...
 
ContainedObjectreadObject (const ContainedObject *, StreamBuffer &s) const
 Output streamer for ContainedObject like references. More...
 
void setObjectType (const ContainedObject *) const
 
void setObjectType (const DataObject *) const
 
const std::stringpath () const
 Shortcut to access the path to the linked object. More...
 
long 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 DataObjectm_data
 Object data: Pointer to the identifiable object the link originates. More...
 
const ContainedObjectm_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 57 of file SmartRefBase.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
DATAOBJECT 
CONTAINEDOBJECT 

Definition at line 70 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 43 of file SmartRefBase.cpp.

43  {
45  const _Container* cnt = dynamic_cast<const _Container*>( accessData( m_data ) );
46  if ( cnt ) return cnt->containedObject( m_linkID );
47  }
48  return nullptr;
49 }

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

52  {
53  if ( !m_data && m_contd ) m_data = m_contd->parent();
54  DataObject* source = const_cast<DataObject*>( m_data );
55  if ( m_hintID == StreamBuffer::INVALID || !source ) return nullptr;
56  LinkManager* mgr = source->linkMgr();
57  if ( !mgr ) return nullptr;
58  LinkManager::Link* link = mgr->link( m_hintID );
59  if ( !link ) return nullptr;
60  DataObject* target = link->object();
61  if ( !target ) {
62  IRegistry* reg = source->registry();
63  if ( !reg ) return nullptr;
64  IDataProviderSvc* datasvc = reg->dataSvc();
65  if ( datasvc && datasvc->retrieveObject( link->path(), target ).isSuccess() ) { link->setObject( target ); }
66  }
67  return target;
68 }

◆ isEqual() [1/2]

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

Equality operator for ContainedObject like references.

Definition at line 82 of file SmartRefBase.h.

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

◆ isEqual() [2/2]

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

Equality operator for DataObject like references.

Definition at line 86 of file SmartRefBase.h.

86  {
87  return m_linkID == c.m_linkID && m_data == c.m_data;
88  }

◆ isEqualEx() [1/2]

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

Extended equality check.

Definition at line 89 of file SmartRefBase.cpp.

89  {
90  return isEqualEx( pObj->parent(), c ) && pObj->index() == c.m_linkID;
91 }

◆ isEqualEx() [2/2]

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

Extended equality check.

Definition at line 71 of file SmartRefBase.cpp.

71  {
72  if ( c.m_hintID != StreamBuffer::INVALID && pObj ) {
73  DataObject* source = const_cast<DataObject*>( c.m_data );
74  if ( source ) {
75  LinkManager* mgr = source->linkMgr();
76  if ( mgr ) {
77  const LinkManager::Link* link = mgr->link( c.m_hintID );
78  if ( link ) {
79  IRegistry* pReg = pObj->registry();
80  return pReg && link->path() == pReg->identifier();
81  }
82  }
83  }
84  }
85  return false;
86 }

◆ objectType()

long SmartRefBase::objectType ( ) const
inline

Definition at line 114 of file SmartRefBase.h.

114 { return m_type; }

◆ path()

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

Shortcut to access the path to the linked object.

Definition at line 93 of file SmartRefBase.cpp.

93  {
94  static std::string s_empty_string{};
95  DataObject* source = nullptr;
96  if ( !m_data && m_contd ) m_data = m_contd->parent();
97  source = const_cast<DataObject*>( m_data );
98  if ( m_hintID != StreamBuffer::INVALID && source ) {
99  LinkManager* mgr = source->linkMgr();
100  if ( mgr ) {
101  const LinkManager::Link* link = mgr->link( m_hintID );
102  if ( link ) return link->path();
103  }
104  }
105  return s_empty_string;
106 }

◆ readObject() [1/2]

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

Output streamer for ContainedObject like references.

Definition at line 102 of file SmartRefBase.h.

102  {
103  ContainedObject* pObj = 0;
104  s.getContainedLink( pObj, m_hintID, m_linkID );
105  return pObj;
106  }

◆ readObject() [2/2]

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

Input streamer for DataObject like references.

Definition at line 96 of file SmartRefBase.h.

96  {
97  DataObject* pObj = 0;
98  s.getIdentifiedLink( pObj, m_hintID );
99  return pObj;
100  }

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

36  {
37  m_data = pObj;
38  m_hintID = hint_id;
39  m_linkID = link_id;
40 }

◆ setObjectType() [1/2]

void SmartRefBase::setObjectType ( const ContainedObject ) const
inline

Definition at line 107 of file SmartRefBase.h.

107 { m_type = CONTAINEDOBJECT; }

◆ setObjectType() [2/2]

void SmartRefBase::setObjectType ( const DataObject ) const
inline

Definition at line 108 of file SmartRefBase.h.

108 { 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 92 of file SmartRefBase.h.

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

◆ writeObject() [2/2]

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

Output streamer for DataObject like references.

Definition at line 90 of file SmartRefBase.h.

90 { 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 66 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 64 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 60 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 62 of file SmartRefBase.h.

◆ m_type

long SmartRefBase::m_type
mutable

Definition at line 68 of file SmartRefBase.h.


The documentation for this class was generated from the following files:
std::string
STL class.
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:314
gaudirun.s
string s
Definition: gaudirun.py:346
SmartRefBase::CONTAINEDOBJECT
@ CONTAINEDOBJECT
Definition: SmartRefBase.h:70
gaudirun.c
c
Definition: gaudirun.py:525
IRegistry
Definition: IRegistry.h:32
SmartRefBase::m_linkID
long m_linkID
Object data: ID of the object within the identifiable container (if any)
Definition: SmartRefBase.h:62
compareOutputFiles.target
target
Definition: compareOutputFiles.py:489
SmartRefBase::m_type
long m_type
Definition: SmartRefBase.h:68
IDataProviderSvc::retrieveObject
virtual StatusCode retrieveObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject)=0
Retrieve object identified by its directory entry.
SmartRefBase::DATAOBJECT
@ DATAOBJECT
Definition: SmartRefBase.h:70
SmartRefBase::m_data
const DataObject * m_data
Object data: Pointer to the identifiable object the link originates.
Definition: SmartRefBase.h:64
ContainedObject::index
virtual long index() const
Distance in the parent container.
Definition: ContainedObject.h:68
SmartRefBase::m_hintID
long m_hintID
Object data: ID of the link hint to the identifiable object.
Definition: SmartRefBase.h:60
ContainedObject::parent
const ObjectContainerBase * parent() const
Access to parent object.
Definition: ContainedObject.h:63
ObjectContainerBase
Definition: ObjectContainerBase.h:29
SmartRefBase::m_contd
const ContainedObject * m_contd
Object data: Pointer to the Contained object (if applicable)
Definition: SmartRefBase.h:66
IRegistry::identifier
virtual const id_type & identifier() const =0
Full identifier (or key)
DataObject
Definition: DataObject.h:36
SmartRefBase::accessData
const ContainedObject * accessData(const ContainedObject *typ) const
Load on demand of ContainedObject like references.
Definition: SmartRefBase.cpp:43
IDataProviderSvc
Definition: IDataProviderSvc.h:53
DataObject::linkMgr
LinkManager * linkMgr()
Retrieve Link manager.
Definition: DataObject.h:80
SmartRefBase::isEqualEx
bool isEqualEx(const DataObject *pObj, const SmartRefBase &c) const
Extended equality check.
Definition: SmartRefBase.cpp:71
ObjectContainerBase::containedObject
virtual const ContainedObject * containedObject(long dist) const =0
Pointer to an object of a given distance.
DataObject::registry
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:78
IRegistry::dataSvc
virtual IDataProviderSvc * dataSvc() const =0
Retrieve pointer to Transient Store.
ContainedObject
Definition: ContainedObject.h:41
StreamBuffer::INVALID
@ INVALID
Definition: StreamBuffer.h:121