The Gaudi Framework  v29r0 (ff2e7097)
GaudiRoot::IOHandler< T > Class Template Reference
Inheritance diagram for GaudiRoot::IOHandler< T >:
Collaboration diagram for GaudiRoot::IOHandler< T >:

Public Member Functions

 IOHandler (TClass *c)
 Initializing constructor. More...
 
 ~IOHandler () override=default
 Standard destructor. More...
 
void operator() (TBuffer &b, void *obj) override
 ROOT I/O callback. More...
 
virtual void get (TBuffer &b, void *obj)
 Callback for reading the object. More...
 
virtual void put (TBuffer &b, void *obj)
 Callback for writing the object. More...
 
template<>
void get (TBuffer &b, void *obj)
 
template<>
void put (TBuffer &b, void *obj)
 
template<>
void get (TBuffer &b, void *obj)
 
template<>
void put (TBuffer &b, void *obj)
 
template<>
void get (TBuffer &b, void *obj)
 
template<>
void put (TBuffer &, void *)
 

Protected Attributes

TClass * m_root
 ROOT persistent class description. More...
 

Detailed Description

template<class T>
class GaudiRoot::IOHandler< T >

Definition at line 58 of file RootIOHandler.cpp.

Constructor & Destructor Documentation

template<class T >
GaudiRoot::IOHandler< T >::IOHandler ( TClass *  c)
inline

Initializing constructor.

Definition at line 66 of file RootIOHandler.cpp.

66 : m_root( c ) {}
TClass * m_root
ROOT persistent class description.
template<class T >
GaudiRoot::IOHandler< T >::~IOHandler ( )
overridedefault

Standard destructor.

Member Function Documentation

template<class T >
virtual void GaudiRoot::IOHandler< T >::get ( TBuffer &  b,
void *  obj 
)
virtual

Callback for reading the object.

template<>
void GaudiRoot::IOHandler< SmartRefBase >::get ( TBuffer &  b,
void *  obj 
)

Definition at line 93 of file RootIOHandler.cpp.

94  {
95  RefAccessor r( obj );
96  UInt_t start, count;
97  Version_t version = b.ReadVersion( &start, &count, m_root );
98  m_root->ReadBuffer( b, obj, version, start, count );
99  switch ( r.Base->objectType() ) {
101  ( *r.ObjectRef )( Gaudi::getCurrentDataObject() );
102  break;
104  ( *r.ContainedRef )( Gaudi::getCurrentDataObject() );
105  break;
106  default:
107  cout << "Hit uninitialized smartRef!!!!" << endl;
108  break;
109  }
110  }
GAUDI_API DataObject * getCurrentDataObject()
T endl(T...args)
TClass * m_root
ROOT persistent class description.
start
Definition: IOTest.py:99
T count(T...args)
template<>
void GaudiRoot::IOHandler< ContainedObject >::get ( TBuffer &  b,
void *  obj 
)

Definition at line 171 of file RootIOHandler.cpp.

172  {
173  UInt_t start, count;
174  Version_t version = b.ReadVersion( &start, &count, m_root );
175  m_root->ReadBuffer( b, obj, version, start, count );
176  ContainedObject* p = (ContainedObject*)obj;
178  }
GAUDI_API DataObject * getCurrentDataObject()
TClass * m_root
ROOT persistent class description.
start
Definition: IOTest.py:99
T count(T...args)
All classes that their objects may be contained in an LHCb ObjectContainer (e.g.
void setParent(ObjectContainerBase *value)
Update parent member.
ObjectContainerBase is the base class for Gaudi container classes.
template<>
void GaudiRoot::IOHandler< pool::Token >::get ( TBuffer &  b,
void *  obj 
)

Definition at line 187 of file RootIOHandler.cpp.

188  {
189  UInt_t start, count;
190  pool::Token* t = (pool::Token*)obj;
191  b.ReadVersion( &start, &count, m_root );
192  b.ReadFastArray( &t->m_oid.first, 2 );
193  b.CheckByteCount( start, count, m_root );
194  }
TClass * m_root
ROOT persistent class description.
std::pair< int, int > m_oid
Object global identifier.
Definition: PoolClasses.h:34
Shadow class to mimik POOL tokens.
Definition: PoolClasses.h:26
start
Definition: IOTest.py:99
T count(T...args)
template<class T >
void GaudiRoot::IOHandler< T >::operator() ( TBuffer &  b,
void *  obj 
)
inlineoverride

ROOT I/O callback.

Definition at line 70 of file RootIOHandler.cpp.

71  {
72  try {
73  if ( b.IsReading() )
74  get( b, obj );
75  else
76  put( b, obj );
77  } catch ( const exception& e ) {
78  string err = "Class:" + string( m_root->GetName() ) + "> Exception in object I/O";
79  err += e.what();
80  throw runtime_error( err );
81  } catch ( ... ) {
82  string err = "Class:" + string( m_root->GetName() ) + "> Exception in object I/O";
83  throw runtime_error( err );
84  }
85  }
TClass * m_root
ROOT persistent class description.
STL class.
T what(T...args)
STL class.
virtual void put(TBuffer &b, void *obj)
Callback for writing the object.
template<class T >
virtual void GaudiRoot::IOHandler< T >::put ( TBuffer &  b,
void *  obj 
)
virtual

Callback for writing the object.

template<>
void GaudiRoot::IOHandler< SmartRefBase >::put ( TBuffer &  b,
void *  obj 
)

Definition at line 113 of file RootIOHandler.cpp.

114  {
115  RefAccessor r( obj );
116  ContainedObject* p;
117  DataObject *curr, *pDO;
118  int hint, link;
119 
121  pDO = r.ObjectRef->data();
122  hint = r.ObjectRef->hintID();
123  link = r.ObjectRef->linkID();
124  if ( pDO ) {
125  switch ( r.Base->objectType() ) {
127  p = r.ContainedRef->data();
128  if ( p ) {
129  const ObjectContainerBase* parent = p->parent();
130  if ( parent ) {
131  link = p->index();
132  pDO = const_cast<ObjectContainerBase*>( parent );
133  break;
134  }
135  }
136  pDO = nullptr;
137  cout << "IOHandler<SmartRefBase>::onWrite> "
138  << "Found invalid smart reference with object "
139  << "having no parent." << endl;
140  throw runtime_error( "IOHandler<SmartRefBase>::onWrite> "
141  "Found invalid smart reference with object "
142  "having no parent." );
143  break;
145  link = StreamBuffer::INVALID;
146  break;
147  default:
148  break;
149  }
150  if ( pDO == last_link_object ) {
151  r.Base->set( curr, last_link_hint, link );
152  m_root->WriteBuffer( b, obj );
153  return;
154  } else if ( pDO ) {
155  LinkManager* mgr = curr->linkMgr();
156  IRegistry* reg = pDO->registry();
157  if ( reg && mgr ) {
158  hint = mgr->addLink( reg->identifier(), pDO );
159  last_link_hint = hint;
160  last_link_object = pDO;
161  }
162  } else {
163  hint = link = StreamBuffer::INVALID;
164  }
165  }
166  r.Base->set( curr, hint, link );
167  m_root->WriteBuffer( b, obj );
168  }
GAUDI_API DataObject * getCurrentDataObject()
T endl(T...args)
virtual long index() const
Distance in the parent container.
TClass * m_root
ROOT persistent class description.
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
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
All classes that their objects may be contained in an LHCb ObjectContainer (e.g.
ObjectContainerBase is the base class for Gaudi container classes.
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:29
template<>
void GaudiRoot::IOHandler< ContainedObject >::put ( TBuffer &  b,
void *  obj 
)

Definition at line 181 of file RootIOHandler.cpp.

182  {
183  m_root->WriteBuffer( b, obj );
184  }
TClass * m_root
ROOT persistent class description.
template<>
void GaudiRoot::IOHandler< pool::Token >::put ( TBuffer &  ,
void *   
)

Definition at line 197 of file RootIOHandler.cpp.

198  {
199  throw runtime_error( "Writing POOL files is not implemented!" );
200  }

Member Data Documentation

template<class T >
TClass* GaudiRoot::IOHandler< T >::m_root
protected

ROOT persistent class description.

Definition at line 62 of file RootIOHandler.cpp.


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