The Gaudi Framework  master (37c0b60a)
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...
 
void get (TBuffer &b, void *obj)
 
void put (TBuffer &b, void *obj)
 
void get (TBuffer &b, void *obj)
 
void put (TBuffer &b, void *obj)
 
void get (TBuffer &b, void *obj)
 
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 64 of file RootIOHandler.cpp.

Constructor & Destructor Documentation

◆ IOHandler()

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

Initializing constructor.

Definition at line 71 of file RootIOHandler.cpp.

71 : m_root( c ) {}

Member Function Documentation

◆ get() [1/4]

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

Callback for reading the object.

◆ get() [2/4]

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

Definition at line 95 of file RootIOHandler.cpp.

95  {
96  RefAccessor r( obj );
97  UInt_t start, count;
98  Version_t version = b.ReadVersion( &start, &count, m_root );
99  m_root->ReadBuffer( b, obj, version, start, count );
100  switch ( r.Base->objectType() ) {
102  ( *r.ObjectRef )( Gaudi::getCurrentDataObject() );
103  break;
105  ( *r.ContainedRef )( Gaudi::getCurrentDataObject() );
106  break;
107  default:
108  cout << "Hit uninitialized smartRef!!!!" << endl;
109  break;
110  }
111  }

◆ get() [3/4]

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

Definition at line 171 of file RootIOHandler.cpp.

171  {
172  UInt_t start, count;
173  Version_t version = b.ReadVersion( &start, &count, m_root );
174  m_root->ReadBuffer( b, obj, version, start, count );
175  ContainedObject* p = (ContainedObject*)obj;
177  }

◆ get() [4/4]

void GaudiRoot::IOHandler< pool::Token >::get ( TBuffer &  b,
void *  obj 
)

Definition at line 185 of file RootIOHandler.cpp.

185  {
186  UInt_t start, count;
187  pool::Token* t = (pool::Token*)obj;
188  b.ReadVersion( &start, &count, m_root );
189  b.ReadFastArray( &t->m_oid.first, 2 );
190  b.CheckByteCount( start, count, m_root );
191  }

◆ operator()()

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

ROOT I/O callback.

Definition at line 73 of file RootIOHandler.cpp.

73  {
74  try {
75  if ( b.IsReading() )
76  get( b, obj );
77  else
78  put( b, obj );
79  } catch ( const exception& e ) {
80  string err = "Class:" + string( m_root->GetName() ) + "> Exception in object I/O";
81  err += e.what();
82  throw runtime_error( err );
83  } catch ( ... ) {
84  string err = "Class:" + string( m_root->GetName() ) + "> Exception in object I/O";
85  throw runtime_error( err );
86  }
87  }

◆ put() [1/4]

void GaudiRoot::IOHandler< pool::Token >::put ( TBuffer &  ,
void *   
)

Definition at line 194 of file RootIOHandler.cpp.

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

◆ put() [2/4]

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

Callback for writing the object.

◆ put() [3/4]

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

Definition at line 114 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  }

◆ put() [4/4]

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

Definition at line 180 of file RootIOHandler.cpp.

180  {
181  m_root->WriteBuffer( b, obj );
182  }

Member Data Documentation

◆ m_root

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

ROOT persistent class description.

Definition at line 67 of file RootIOHandler.cpp.


The documentation for this class was generated from the following file:
std::string
STL class.
std::exception
STL class.
SmartRefBase::CONTAINEDOBJECT
@ CONTAINEDOBJECT
Definition: SmartRefBase.h:70
GaudiRoot::IOHandler::put
virtual void put(TBuffer &b, void *obj)
Callback for writing the object.
gaudirun.c
c
Definition: gaudirun.py:525
IRegistry
Definition: IRegistry.h:32
IOTest.start
start
Definition: IOTest.py:110
Gaudi::getCurrentDataObject
GAUDI_API DataObject * getCurrentDataObject()
bug_34121.t
t
Definition: bug_34121.py:31
std::cout
conf.version
string version
Definition: conf.py:25
SmartRefBase::DATAOBJECT
@ DATAOBJECT
Definition: SmartRefBase.h:70
std::runtime_error
STL class.
ContainedObject::index
virtual long index() const
Distance in the parent container.
Definition: ContainedObject.h:68
ContainedObject::parent
const ObjectContainerBase * parent() const
Access to parent object.
Definition: ContainedObject.h:63
GaudiRoot::IOHandler::m_root
TClass * m_root
ROOT persistent class description.
Definition: RootIOHandler.cpp:67
std::endl
T endl(T... args)
ContainedObject::setParent
void setParent(ObjectContainerBase *value)
Update parent member.
Definition: ContainedObject.h:65
ObjectContainerBase
Definition: ObjectContainerBase.h:29
IRegistry::identifier
virtual const id_type & identifier() const =0
Full identifier (or key)
DataObject
Definition: DataObject.h:36
std::count
T count(T... args)
GaudiRoot::IOHandler::get
virtual void get(TBuffer &b, void *obj)
Callback for reading the object.
pool::Token
Definition: PoolClasses.h:34
DataObject::linkMgr
LinkManager * linkMgr()
Retrieve Link manager.
Definition: DataObject.h:80
DataObject::registry
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:78
ContainedObject
Definition: ContainedObject.h:41
std::exception::what
T what(T... args)
StreamBuffer::INVALID
@ INVALID
Definition: StreamBuffer.h:121