The Gaudi Framework  v29r0 (ff2e7097)
SmartRefBase Class Reference

User example objects: SmartRefBase. More...

#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...
 
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 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 47 of file SmartRefBase.h.

Member Enumeration Documentation

anonymous enum
Enumerator
DATAOBJECT 
CONTAINEDOBJECT 

Definition at line 61 of file SmartRefBase.h.

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

35 {
37  const _Container* cnt = dynamic_cast<const _Container*>( accessData( m_data ) );
38  if ( cnt ) return cnt->containedObject( m_linkID );
39  }
40  return nullptr;
41 }
const ContainedObject * accessData(const ContainedObject *typ) const
Load on demand of ContainedObject like references.
const DataObject * m_data
Object data: Pointer to the identifiable object the link originates.
Definition: SmartRefBase.h:55
long m_hintID
Object data: ID of the link hint to the identifiable object.
Definition: SmartRefBase.h:51
virtual 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)
Definition: SmartRefBase.h:53
ObjectContainerBase is the base class for Gaudi container classes.
const DataObject * SmartRefBase::accessData ( const DataObject typ) const

Load on demand of DataObject like references.

Load on demand: DataObject type references.

Definition at line 44 of file SmartRefBase.cpp.

45 {
46  DataObject* target = nullptr;
47  DataObject* source = nullptr;
48  if ( !m_data && m_contd ) m_data = m_contd->parent();
49  source = const_cast<DataObject*>( m_data );
50  if ( m_hintID != StreamBuffer::INVALID && source ) {
51  LinkManager* mgr = source->linkMgr();
52  if ( mgr ) {
53  LinkManager::Link* link = mgr->link( m_hintID );
54  if ( link ) {
55  target = link->object();
56  if ( !target ) {
57  IRegistry* reg = source->registry();
58  if ( reg ) {
59  IDataProviderSvc* datasvc = reg->dataSvc();
60  if ( datasvc && datasvc->retrieveObject( link->path(), target ).isSuccess() ) {
61  link->setObject( target );
62  }
63  }
64  }
65  }
66  }
67  }
68  return target;
69 }
const DataObject * m_data
Object data: Pointer to the identifiable object the link originates.
Definition: SmartRefBase.h:55
long m_hintID
Object data: ID of the link hint to the identifiable object.
Definition: SmartRefBase.h:51
Data provider interface definition.
const ObjectContainerBase * parent() const
Access to parent object.
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:72
LinkManager * linkMgr() const
Retrieve Link manager.
Definition: DataObject.h:74
const ContainedObject * m_contd
Object data: Pointer to the Contained object (if applicable)
Definition: SmartRefBase.h:57
virtual IDataProviderSvc * dataSvc() const =0
Retrieve pointer to Transient Store.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:29
virtual StatusCode retrieveObject(IRegistry *pDirectory, const std::string &path, DataObject *&pObject)=0
Retrieve object identified by its directory entry.
bool SmartRefBase::isEqual ( const ContainedObject ,
const SmartRefBase c 
) const
inline

Equality operator for ContainedObject like references.

Definition at line 73 of file SmartRefBase.h.

74  {
75  return ( m_hintID == c.m_hintID && m_linkID == c.m_linkID && m_data == c.m_data && m_contd == c.m_contd );
76  }
const DataObject * m_data
Object data: Pointer to the identifiable object the link originates.
Definition: SmartRefBase.h:55
long m_hintID
Object data: ID of the link hint to the identifiable object.
Definition: SmartRefBase.h:51
const ContainedObject * m_contd
Object data: Pointer to the Contained object (if applicable)
Definition: SmartRefBase.h:57
long m_linkID
Object data: ID of the object within the identifiable container (if any)
Definition: SmartRefBase.h:53
bool SmartRefBase::isEqual ( const DataObject ,
const SmartRefBase c 
) const
inline

Equality operator for DataObject like references.

Definition at line 78 of file SmartRefBase.h.

79  {
80  return m_linkID == c.m_linkID && m_data == c.m_data;
81  }
const DataObject * m_data
Object data: Pointer to the identifiable object the link originates.
Definition: SmartRefBase.h:55
long m_linkID
Object data: ID of the object within the identifiable container (if any)
Definition: SmartRefBase.h:53
bool SmartRefBase::isEqualEx ( const DataObject pObj,
const SmartRefBase c 
) const

Extended equality check.

Definition at line 72 of file SmartRefBase.cpp.

73 {
74  if ( c.m_hintID != StreamBuffer::INVALID && pObj ) {
75  DataObject* source = const_cast<DataObject*>( c.m_data );
76  if ( source ) {
77  LinkManager* mgr = source->linkMgr();
78  if ( mgr ) {
79  LinkManager::Link* link = mgr->link( c.m_hintID );
80  if ( link ) {
81  IRegistry* pReg = pObj->registry();
82  return pReg && link->path() == pReg->identifier();
83  }
84  }
85  }
86  }
87  return false;
88 }
const DataObject * m_data
Object data: Pointer to the identifiable object the link originates.
Definition: SmartRefBase.h:55
long m_hintID
Object data: ID of the link hint to the identifiable object.
Definition: SmartRefBase.h:51
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:72
LinkManager * linkMgr() const
Retrieve Link manager.
Definition: DataObject.h:74
virtual const id_type & identifier() const =0
Full identifier (or key)
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:29
bool SmartRefBase::isEqualEx ( const ContainedObject pObj,
const SmartRefBase c 
) const

Extended equality check.

Definition at line 91 of file SmartRefBase.cpp.

92 {
93  return isEqualEx( pObj->parent(), c ) && pObj->index() == c.m_linkID;
94 }
bool isEqualEx(const DataObject *pObj, const SmartRefBase &c) const
Extended equality check.
virtual long index() const
Distance in the parent container.
const ObjectContainerBase * parent() const
Access to parent object.
long m_linkID
Object data: ID of the object within the identifiable container (if any)
Definition: SmartRefBase.h:53
int SmartRefBase::objectType ( ) const
inline

Definition at line 110 of file SmartRefBase.h.

110 { return m_type; }
const std::string & SmartRefBase::path ( ) const

Shortcut to access the path to the linked object.

Definition at line 96 of file SmartRefBase.cpp.

97 {
98  static std::string s_empty_string{};
99  DataObject* source = nullptr;
100  if ( !m_data && m_contd ) m_data = m_contd->parent();
101  source = const_cast<DataObject*>( m_data );
102  if ( m_hintID != StreamBuffer::INVALID && source ) {
103  LinkManager* mgr = source->linkMgr();
104  if ( mgr ) {
105  LinkManager::Link* link = mgr->link( m_hintID );
106  if ( link ) return link->path();
107  }
108  }
109  return s_empty_string;
110 }
const DataObject * m_data
Object data: Pointer to the identifiable object the link originates.
Definition: SmartRefBase.h:55
long m_hintID
Object data: ID of the link hint to the identifiable object.
Definition: SmartRefBase.h:51
const ObjectContainerBase * parent() const
Access to parent object.
LinkManager * linkMgr() const
Retrieve Link manager.
Definition: DataObject.h:74
STL class.
const ContainedObject * m_contd
Object data: Pointer to the Contained object (if applicable)
Definition: SmartRefBase.h:57
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:29
DataObject* SmartRefBase::readObject ( const DataObject ,
StreamBuffer s 
) const
inline

Input streamer for DataObject like references.

Definition at line 90 of file SmartRefBase.h.

91  {
92  DataObject* pObj = 0;
93  s.getIdentifiedLink( pObj, m_hintID );
94  return pObj;
95  }
long m_hintID
Object data: ID of the link hint to the identifiable object.
Definition: SmartRefBase.h:51
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:29
void getIdentifiedLink(DataObject *&pObject, long &hint)
Definition: StreamBuffer.h:292
ContainedObject* SmartRefBase::readObject ( const ContainedObject ,
StreamBuffer s 
) const
inline

Output streamer for ContainedObject like references.

Definition at line 97 of file SmartRefBase.h.

98  {
99  ContainedObject* pObj = 0;
100  s.getContainedLink( pObj, m_hintID, m_linkID );
101  return pObj;
102  }
long m_hintID
Object data: ID of the link hint to the identifiable object.
Definition: SmartRefBase.h:51
long m_linkID
Object data: ID of the object within the identifiable container (if any)
Definition: SmartRefBase.h:53
All classes that their objects may be contained in an LHCb ObjectContainer (e.g.
void getContainedLink(ContainedObject *&pObject, long &hint, long &link)
Definition: StreamBuffer.h:304
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.

27 {
28  m_data = pObj;
29  m_hintID = hint_id;
30  m_linkID = link_id;
31 }
const DataObject * m_data
Object data: Pointer to the identifiable object the link originates.
Definition: SmartRefBase.h:55
long m_hintID
Object data: ID of the link hint to the identifiable object.
Definition: SmartRefBase.h:51
long m_linkID
Object data: ID of the object within the identifiable container (if any)
Definition: SmartRefBase.h:53
void SmartRefBase::setObjectType ( const ContainedObject ) const
inline

Definition at line 103 of file SmartRefBase.h.

void SmartRefBase::setObjectType ( const DataObject ) const
inline

Definition at line 104 of file SmartRefBase.h.

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

Output streamer for DataObject like references.

Definition at line 83 of file SmartRefBase.h.

83 { s.addIdentifiedLink( pObject, m_hintID ); }
long m_hintID
Object data: ID of the link hint to the identifiable object.
Definition: SmartRefBase.h:51
void addIdentifiedLink(const DataObject *pObject, long hint)
Definition: StreamBuffer.h:299
void SmartRefBase::writeObject ( const ContainedObject pObject,
StreamBuffer s 
) const
inline

Output streamer for ContainedObject like references.

Definition at line 85 of file SmartRefBase.h.

86  {
87  s.addContainedLink( pObject, m_hintID, m_linkID );
88  }
long m_hintID
Object data: ID of the link hint to the identifiable object.
Definition: SmartRefBase.h:51
long m_linkID
Object data: ID of the object within the identifiable container (if any)
Definition: SmartRefBase.h:53
void addContainedLink(const ContainedObject *pObject, long hint, long link)
Definition: StreamBuffer.h:312

Member Data Documentation

const ContainedObject* SmartRefBase::m_contd
mutable

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

Definition at line 57 of file SmartRefBase.h.

const DataObject* SmartRefBase::m_data
mutable

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

Definition at line 55 of file SmartRefBase.h.

long SmartRefBase::m_hintID
mutable

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

Definition at line 51 of file SmartRefBase.h.

long SmartRefBase::m_linkID
mutable

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

Definition at line 53 of file SmartRefBase.h.

long SmartRefBase::m_type
mutable

Definition at line 59 of file SmartRefBase.h.


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