22 #include "TInterpreter.h"
23 #include "TClassStreamer.h"
30 static int last_link_hint = -1;
54 template <
class T>
class IOHandler :
public TClassStreamer {
71 catch(
const exception& e ) {
72 string err =
"Class:" + string(m_root->GetName()) +
"> Exception in object I/O";
74 throw runtime_error(err);
77 string err =
"Class:" + string(m_root->GetName()) +
"> Exception in object I/O";
78 throw runtime_error(err);
82 virtual void get(TBuffer &b,
void* obj);
84 virtual void put(TBuffer &b,
void* obj);
90 Version_t version = b.ReadVersion(&start, &count, m_root);
91 m_root->ReadBuffer(b, obj, version, start, count);
100 cout <<
"Hit uninitialized smartRef!!!!" << endl;
128 cout <<
"IOHandler<SmartRefBase>::onWrite> "
129 <<
"Found invalid smart reference with object "
130 <<
"having no parent."
132 throw runtime_error(
"IOHandler<SmartRefBase>::onWrite> "
133 "Found invalid smart reference with object "
134 "having no parent.");
142 if ( pDO == last_link_object ) {
143 r.
Base->
set(curr, last_link_hint, link);
144 m_root->WriteBuffer(b, obj);
152 last_link_hint = hint;
153 last_link_object = pDO;
161 m_root->WriteBuffer(b, obj);
166 Version_t version = b.ReadVersion(&start, &count, m_root);
167 m_root->ReadBuffer(b, obj, version, start, count);
173 m_root->WriteBuffer(b, obj);
179 b.ReadVersion(&start, &count, m_root);
180 b.ReadFastArray(&t->
m_oid.first, 2);
181 b.CheckByteCount(start, count, m_root);
185 throw runtime_error(
"Writing POOL files is not implemented!");
188 template <
class T>
static bool makeStreamer(
MsgStream&
log) {
190 TClass*
c = gROOT->GetClass(cl_name.c_str());
197 log <<
MSG::ERROR <<
"[No ROOT TClass] Failed to install IOHandler for class " << cl_name <<
endmsg;
202 static bool first =
true;
205 #if ROOT_VERSION_CODE < ROOT_VERSION(5,99,0)
206 gSystem->Load(
"libCintex");
207 gROOT->ProcessLine(
"Cintex::Cintex::Enable()");
208 gROOT->ProcessLine(
"#include <vector>");
209 gInterpreter->EnableAutoLoading();
210 gInterpreter->AutoLoad(
"DataObject");
211 gInterpreter->AutoLoad(
"PoolDbLinkManager");
212 gSystem->Load(
"libGaudiKernelDict");
213 gSystem->Load(
"libGaudiExamplesDict");
215 gInterpreter->EnableAutoLoading();
216 gInterpreter->AutoLoad(
"DataObject");
217 gInterpreter->AutoLoad(
"PoolDbLinkManager");
221 bool b1 = makeStreamer<SmartRefBase>(
s);
222 bool b2 = makeStreamer<ContainedObject>(
s);
223 bool b3 = makeStreamer<pool::Token>(
s);
224 return b1 && b2 && b3;
IOHandler(TClass *c)
Initializing constructor.
Definition of the MsgStream class used to transmit messages.
void popCurrentDataObject()
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
GAUDI_API void popCurrentDataObject()
GAUDI_API DataObject * getCurrentDataObject()
void pushCurrentDataObject(DataObject **pobjAddr)
virtual long index() const
Distance in the parent container.
bool patchStreamers(MsgStream &log)
User example objects: SmartRefBase.
long addLink(const std::string &path, const DataObject *pObject) const
Add link by object reference and path.
TClass * m_root
ROOT persistent class description.
const ObjectContainerBase * parent() const
Access to parent object.
IRegistry * registry() const
Get pointer to Registry.
LinkManager * linkMgr() const
Retrieve Link manager.
std::pair< int, int > m_oid
Object global identifier.
Shadow class to mimik POOL tokens.
virtual void operator()(TBuffer &b, void *obj)
ROOT I/O callback.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
GAUDI_API void pushCurrentDataObject(DataObject **pobjAddr)
All classes that their objects may be contained in an LHCb ObjectContainer (e.g.
virtual ~IOHandler()
Standard destructor.
void setParent(ObjectContainerBase *value)
Update parent member.
SmartRef< DataObject > * ObjectRef
virtual const id_type & identifier() const =0
Full identifier (or key)
ObjectContainerBase is the base class for Gaudi container classes.
void set(DataObject *pObj, long hint_id, long link_id)
Setup smart reference when reading. Must be allowed from external sources.
SmartRef< ContainedObject > * ContainedRef
A DataObject is the base class of any identifiable object on any data store.
A LinkManager is the object aggregated into a DataObject, which is responsible for the handling of no...
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.