The Gaudi Framework  master (e98cfcff)
Loading...
Searching...
No Matches
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.
 
void operator() (TBuffer &b, void *obj) override
 ROOT I/O callback.
 
virtual void get (TBuffer &b, void *obj)
 Callback for reading the object.
 
virtual void put (TBuffer &b, void *obj)
 Callback for writing the object.
 
TClassStreamer * Generate () const override
 
void get (TBuffer &b, void *obj)
 
void put (TBuffer &b, void *obj)
 
void get (TBuffer &b, void *obj)
 
void put (TBuffer &b, void *obj)
 

Protected Attributes

TClass * m_root
 ROOT persistent class description.
 

Detailed Description

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

Definition at line 63 of file RootIOHandler.cpp.

Constructor & Destructor Documentation

◆ IOHandler()

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

Initializing constructor.

Definition at line 70 of file RootIOHandler.cpp.

70: m_root( c ) {}
TClass * m_root
ROOT persistent class description.

Member Function Documentation

◆ Generate()

template<class T>
TClassStreamer * GaudiRoot::IOHandler< T >::Generate ( ) const
inlineoverride

Definition at line 91 of file RootIOHandler.cpp.

91{ return new IOHandler( *this ); }
IOHandler(TClass *c)
Initializing constructor.

◆ get() [1/3]

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

Callback for reading the object.

◆ get() [2/3]

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

Definition at line 95 of file RootIOHandler.cpp.

95 {
96 RefAccessor r( obj );
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/3]

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

Definition at line 171 of file RootIOHandler.cpp.

171 {
173 Version_t version = b.ReadVersion( &start, &count, m_root );
174 m_root->ReadBuffer( b, obj, version, start, count );
175 ContainedObject* p = static_cast<ContainedObject*>( obj );
176 p->setParent( static_cast<ObjectContainerBase*>( Gaudi::getCurrentDataObject() ) );
177 }

◆ operator()()

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

ROOT I/O callback.

Definition at line 72 of file RootIOHandler.cpp.

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

◆ put() [1/3]

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

Callback for writing the object.

◆ put() [2/3]

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

Definition at line 114 of file RootIOHandler.cpp.

114 {
115 RefAccessor r( obj );
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;
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 );
161 }
162 } else {
164 }
165 }
166 r.Base->set( curr, hint, link );
167 m_root->WriteBuffer( b, obj );
168 }
GAUDI_API DataObject * getCurrentDataObject()

◆ put() [3/3]

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


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