The Gaudi Framework  v30r3 (a5ef0a68)
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...
 
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.

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 91 of file RootIOHandler.cpp.

92  {
93  RefAccessor r( obj );
94  UInt_t start, count;
95  Version_t version = b.ReadVersion( &start, &count, m_root );
96  m_root->ReadBuffer( b, obj, version, start, count );
97  switch ( r.Base->objectType() ) {
99  ( *r.ObjectRef )( Gaudi::getCurrentDataObject() );
100  break;
102  ( *r.ContainedRef )( Gaudi::getCurrentDataObject() );
103  break;
104  default:
105  cout << "Hit uninitialized smartRef!!!!" << endl;
106  break;
107  }
108  }
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 169 of file RootIOHandler.cpp.

170  {
171  UInt_t start, count;
172  Version_t version = b.ReadVersion( &start, &count, m_root );
173  m_root->ReadBuffer( b, obj, version, start, count );
174  ContainedObject* p = (ContainedObject*)obj;
176  }
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 185 of file RootIOHandler.cpp.

186  {
187  UInt_t start, count;
188  pool::Token* t = (pool::Token*)obj;
189  b.ReadVersion( &start, &count, m_root );
190  b.ReadFastArray( &t->m_oid.first, 2 );
191  b.CheckByteCount( start, count, m_root );
192  }
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 68 of file RootIOHandler.cpp.

69  {
70  try {
71  if ( b.IsReading() )
72  get( b, obj );
73  else
74  put( b, obj );
75  } catch ( const exception& e ) {
76  string err = "Class:" + string( m_root->GetName() ) + "> Exception in object I/O";
77  err += e.what();
78  throw runtime_error( err );
79  } catch ( ... ) {
80  string err = "Class:" + string( m_root->GetName() ) + "> Exception in object I/O";
81  throw runtime_error( err );
82  }
83  }
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 111 of file RootIOHandler.cpp.

112  {
113  RefAccessor r( obj );
114  ContainedObject* p;
115  DataObject * curr, *pDO;
116  int hint, link;
117 
119  pDO = r.ObjectRef->data();
120  hint = r.ObjectRef->hintID();
121  link = r.ObjectRef->linkID();
122  if ( pDO ) {
123  switch ( r.Base->objectType() ) {
125  p = r.ContainedRef->data();
126  if ( p ) {
127  const ObjectContainerBase* parent = p->parent();
128  if ( parent ) {
129  link = p->index();
130  pDO = const_cast<ObjectContainerBase*>( parent );
131  break;
132  }
133  }
134  pDO = nullptr;
135  cout << "IOHandler<SmartRefBase>::onWrite> "
136  << "Found invalid smart reference with object "
137  << "having no parent." << endl;
138  throw runtime_error( "IOHandler<SmartRefBase>::onWrite> "
139  "Found invalid smart reference with object "
140  "having no parent." );
141  break;
143  link = StreamBuffer::INVALID;
144  break;
145  default:
146  break;
147  }
148  if ( pDO == last_link_object ) {
149  r.Base->set( curr, last_link_hint, link );
150  m_root->WriteBuffer( b, obj );
151  return;
152  } else if ( pDO ) {
153  LinkManager* mgr = curr->linkMgr();
154  IRegistry* reg = pDO->registry();
155  if ( reg && mgr ) {
156  hint = mgr->addLink( reg->identifier(), pDO );
157  last_link_hint = hint;
158  last_link_object = pDO;
159  }
160  } else {
161  hint = link = StreamBuffer::INVALID;
162  }
163  }
164  r.Base->set( curr, hint, link );
165  m_root->WriteBuffer( b, obj );
166  }
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:73
LinkManager * linkMgr() const
Retrieve Link manager.
Definition: DataObject.h:75
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:30
template<>
void GaudiRoot::IOHandler< ContainedObject >::put ( TBuffer &  b,
void *  obj 
)

Definition at line 179 of file RootIOHandler.cpp.

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

Definition at line 195 of file RootIOHandler.cpp.

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

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: