24 #include "TInterpreter.h"
25 #include "TBufferFile.h"
30 #define SERIALIZER_END "EOF"
33 struct DataObjectPush {
46 if ( level < m_currentItem->depth() ) {
47 if ( dir->
object() != 0 ) {
48 m_objects.push_back(dir->
object());
60 , m_verifyItems(false)
62 , m_addressCreator(ac)
82 m_objects.erase(m_objects.begin(), m_objects.end());
85 for ( Items::iterator
i = m_itemList.begin();
i != m_itemList.end();
i++ ) {
88 status = m_TES->retrieveObject(m_currentItem->path(), obj);
90 m_TESMgr->traverseSubTree(obj,
this);
93 string text(
"WARNING: Cannot retrieve TES object(s) for serialisation: ");
94 text += m_currentItem->path();
104 for ( Items::iterator
i = m_optItemList.begin();
i != m_optItemList.end();
i++ ) {
105 m_currentItem = (*i);
107 status= m_TES->retrieveObject(m_currentItem->path(), obj);
109 m_TESMgr->traverseSubTree(obj,
this);
114 buffer.WriteInt(m_objects.size());
116 for(Objects::iterator
i = m_objects.begin();
i != m_objects.end(); ++
i) {
118 DataObjectPush p(pObj);
122 const type_info& objClass =
typeid(*pObj);
128 if (m_classMap[objClassName]) {
129 cl=m_classMap[objClassName];
132 const char* clName = objClassName.c_str();
134 cl = gROOT->GetClass(clName);
135 m_classMap[objClassName]=cl;
143 cout <<
"WARNING: gROOT->GetClass fails for clname : "
144 << objClassName.c_str() << endl;
145 cout <<
"WARNING: Disregarding " << objClassName.c_str()
146 <<
"erasing from object list" << endl;
147 m_objects.erase(
i );
154 buffer.WriteString(loc.c_str());
155 buffer.WriteString(cl->GetName());
156 cl->Streamer(pObj,buffer);
160 int numLinks = linkMgr->
size();
161 buffer.WriteInt(numLinks);
163 for (
int it = 0; it != numLinks; it++) {
164 const string& link = linkMgr->
link(it)->
path();
165 buffer.WriteString(link.c_str());
173 const string *
par = iop->
par();
175 long clid = iop->
clID();
176 buffer.WriteLong(svcType);
177 buffer.WriteLong(clid);
178 buffer.WriteString(par->c_str());
212 buffer.SetReadMode();
213 buffer.SetBufferOffset();
215 buffer.ReadInt(nObjects);
216 for (
int i=0;
i<nObjects; ++
i) {
218 buffer.ReadString(text,
sizeof(text));
219 string location(text);
220 if (!location.compare(
"EOF")) {
225 buffer.ReadString(text,
sizeof(text));
226 TClass* cl = gROOT->GetClass(text);
231 cout <<
"TESSerializer WARNING : gROOT->GetClass fails for clname : " << location.c_str() << endl;
238 DataObjectPush push(obj);
239 cl->Streamer(obj, buffer);
246 buffer.ReadInt(nlink);
248 for (
int j = 0; j < nlink; ++j) {
249 buffer.ReadString(text,
sizeof(text));
255 registerStat = m_TES->registerObject(location, obj);
258 if ( location ==
"/Event" ) {
259 sc = m_TESMgr->setRoot(location, obj);
261 throw GaudiException(
"Cannot set root at location " + location,
"", sc);
264 m_TES->findObject(location, dummy);
266 m_TES->registerObject(location, obj);
271 buffer.ReadInt(flag);
274 buffer.ReadLong(svcType);
276 buffer.ReadLong(clid);
277 buffer.ReadString(text,
sizeof(text));
289 buffer.ReadInt(flag);
297 buffer.ReadLong(svcType);
300 buffer.ReadLong(clid);
301 const CLID classid(clid);
304 cp = buffer.ReadString(text,
sizeof(text));
305 const string opaque(cp);
309 unsigned long ip1(0);
310 unsigned long ip2(0);
314 createAddressStat = m_addressCreator->createAddress( gadd.
svcType(), gadd.
clID(), gadd.
par(), gadd.
ipar(), iopref );
316 throw GaudiException(
"Failure in creating OpaqueAddress for reconstructed registry",
"", createAddressStat);
332 std::string obj_path;
335 size_t sep = descriptor.rfind(
"#");
336 if (sep > descriptor.length()) {
338 obj_path = descriptor;
342 obj_path = descriptor.substr(0,sep);
343 slevel = descriptor.substr(sep+1);
347 if ( slevel ==
"*" ) {
351 level = atoi(slevel.c_str());
355 if ( m_verifyItems ) {
356 size_t idx = obj_path.find(
"/",1);
357 while(idx != std::string::npos) {
358 std::string sub_item = obj_path.substr(0,idx);
359 if ( 0 == findItem(sub_item) ) {
360 cout <<
"... calling addItem with arg : " << sub_item << endl;
361 addItem(itms, sub_item);
363 idx = obj_path.find(
"/",idx+1);
370 itms.push_back( item );
376 addItem( m_itemList, path );
382 addItem( m_optItemList, path);
387 cout <<
"TESSerializer m_itemList : " << m_itemList.size() <<
" Items"<< endl;
388 for(Items::const_iterator
i=m_itemList.begin();
i != m_itemList.end(); ++
i) {
389 cout <<
"\tItem : " << (*i)->path() << endl;
391 cout <<
"TESSerializer m_optItemList : " << m_optItemList.size() <<
" Items" << endl;
392 for(Items::const_iterator
i=m_optItemList.begin();
i != m_optItemList.end(); ++
i) {
393 cout <<
"\tItem : " << (*i)->path() << endl;
400 for(Items::const_iterator
i=m_itemList.begin();
i != m_itemList.end(); ++
i) {
401 if ( (*i)->path() ==
path )
return (*
i);
403 for(Items::const_iterator j=m_optItemList.begin(); j != m_optItemList.end(); ++j) {
404 if ( (*j)->path() ==
path )
return (*j);
const std::string & path() const
Access to path of object.
virtual const std::string * par() const =0
Retrieve String parameters.
void checkItems()
print out the contents of m_itemList and m_optItemList (std::cout)
Define general base for Gaudi exception.
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
void loadBuffer(TBufferFile &)
Rebuild TES from items in a TBufferFile.
GAUDI_API void popCurrentDataObject()
bool analyse(IRegistry *dir, int level)
Analysis callback.
bool isSuccess() const
Test for a status code of SUCCESS.
TESSerializer(IDataProviderSvc *svc, IAddressCreator *ac)
Constructor.
IAddressCreator interface definition.
long addLink(const std::string &path, const DataObject *pObject) const
Add link by object reference and path.
Generic Transient Address.
Data provider interface definition.
Description of the DataStoreItem class.
virtual long svcType() const =0
Retrieve service type.
bool isFailure() const
Test for a status code of FAILURE.
IRegistry * registry() const
Get pointer to Registry.
const CLID & clID() const
Access : Retrieve class ID of the link.
LinkManager * linkMgr() const
Retrieve Link manager.
long svcType() const
Access : retrieve the storage type of the class id.
virtual const std::string * par() const
Retrieve string parameters.
std::vector< DataStoreItem * > Items
virtual const unsigned long * ipar() const
Retrieve integer parameters.
virtual const CLID & clID() const =0
Retrieve class information from link.
void dumpBuffer(TBufferFile &)
Dump TES contents listed in m_itemList/m_optItemList to a TBufferFile.
This class is used for returning status codes from appropriate routines.
Link * link(long id)
Retrieve symbolic link identified by ID.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
void addItem(const std::string &path)
add an item to the TESSerializer's list (#notation)
unsigned int CLID
Class ID definition.
GAUDI_API void pushCurrentDataObject(DataObject **pobjAddr)
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
virtual DataObject * object() const =0
Retrieve object behind the link.
GAUDI_API std::string path(const AIDA::IBaseHistogram *aida)
get the path in THS for AIDA histogram
virtual void setAddress(IOpaqueAddress *pAddress)=0
Set/Update Opaque storage address.
std
AIDA -> ROTO converter.
virtual const id_type & identifier() const =0
Full identifier (or key)
void addOptItem(const std::string &path)
add an item to the TESSerializer's optional list (#notation)
DataStoreItem * findItem(const std::string &path)
Find single item identified by its path (exact match)
Opaque address interface definition.
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...
long size() const
Retrieve number of link present.