21 #include "TBufferFile.h" 23 #include "TInterpreter.h" 29 #define SERIALIZER_END "EOF" 32 struct DataObjectPush {
41 if ( level < m_currentItem->depth() ) {
42 if ( dir->
object() != 0 ) {
43 m_objects.push_back( dir->
object() );
55 , m_verifyItems( false )
57 , m_addressCreator( ac ) {}
75 m_objects.erase( m_objects.begin(), m_objects.end() );
78 for ( Items::iterator i = m_itemList.begin(); i != m_itemList.end(); i++ ) {
79 m_currentItem = ( *i );
81 status = m_TES->retrieveObject( m_currentItem->path(), obj );
83 m_TESMgr->traverseSubTree( obj,
this );
85 string text(
"WARNING: Cannot retrieve TES object(s) for serialisation: " );
86 text += m_currentItem->path();
96 for ( Items::iterator i = m_optItemList.begin(); i != m_optItemList.end(); i++ ) {
97 m_currentItem = ( *i );
99 status = m_TES->retrieveObject( m_currentItem->path(), obj );
100 if ( status.
isSuccess() ) { m_TESMgr->traverseSubTree( obj,
this ); }
104 buffer.WriteInt( m_objects.size() );
106 for ( Objects::iterator i = m_objects.begin(); i != m_objects.end(); ++i ) {
108 DataObjectPush p( pObj );
112 const type_info& objClass =
typeid( *pObj );
118 if ( m_classMap[objClassName] ) {
119 cl = m_classMap[objClassName];
122 const char* clName = objClassName.c_str();
124 cl = gROOT->GetClass( clName );
125 m_classMap[objClassName] = cl;
133 cout <<
"WARNING: gROOT->GetClass fails for clname : " << objClassName.c_str() <<
endl;
134 cout <<
"WARNING: Disregarding " << objClassName.c_str() <<
"erasing from object list" <<
endl;
135 m_objects.erase( i );
142 buffer.WriteString( loc.
c_str() );
143 buffer.WriteString( cl->GetName() );
144 cl->Streamer( pObj, buffer );
148 int numLinks = linkMgr->
size();
149 buffer.WriteInt( numLinks );
151 for (
int it = 0; it != numLinks; it++ ) {
152 const string& link = linkMgr->
link( it )->
path();
153 buffer.WriteString( link.
c_str() );
160 buffer.WriteInt( 1 );
161 const string*
par = iop->
par();
163 long clid = iop->
clID();
164 buffer.WriteLong( svcType );
165 buffer.WriteLong( clid );
166 buffer.WriteString(
par->c_str() );
168 buffer.WriteInt( 0 );
197 StatusCode sc, registerStat, createAddressStat;
200 buffer.SetReadMode();
201 buffer.SetBufferOffset();
203 buffer.ReadInt( nObjects );
204 for (
int i = 0; i < nObjects; ++i ) {
206 buffer.ReadString( text,
sizeof( text ) );
213 buffer.ReadString( text,
sizeof( text ) );
214 TClass* cl = gROOT->GetClass( text );
219 cout <<
"TESSerializer WARNING : gROOT->GetClass fails for clname : " <<
location.c_str() <<
endl;
226 DataObjectPush push( obj );
227 cl->Streamer( obj, buffer );
233 buffer.ReadInt( nlink );
235 for (
int j = 0; j < nlink; ++j ) {
236 buffer.ReadString( text,
sizeof( text ) );
242 registerStat = m_TES->registerObject(
location, obj );
246 sc = m_TESMgr->setRoot(
location, obj );
249 m_TES->findObject(
location, dummy );
251 m_TES->registerObject(
location, obj );
256 buffer.ReadInt( flag );
259 buffer.ReadLong( svcType );
261 buffer.ReadLong( clid );
262 buffer.ReadString( text,
sizeof( text ) );
274 buffer.ReadInt( flag );
282 buffer.ReadLong( svcType );
285 buffer.ReadLong( clid );
286 const CLID classid( clid );
289 cp = buffer.ReadString( text,
sizeof( text ) );
290 const string opaque(
cp );
293 const string& p2 =
"";
294 unsigned long ip1( 0 );
295 unsigned long ip2( 0 );
300 m_addressCreator->createAddress( gadd.
svcType(), gadd.
clID(), gadd.
par(), gadd.
ipar(), iopref );
302 throw GaudiException(
"Failure in creating OpaqueAddress for reconstructed registry",
"", createAddressStat );
321 size_t sep = descriptor.
rfind(
"#" );
322 if ( sep > descriptor.
length() ) {
324 obj_path = descriptor;
328 obj_path = descriptor.
substr( 0, sep );
329 slevel = descriptor.
substr( sep + 1 );
333 if ( slevel ==
"*" ) {
340 if ( m_verifyItems ) {
341 size_t idx = obj_path.
find(
"/", 1 );
342 while ( idx != std::string::npos ) {
344 if ( 0 == findItem( sub_item ) ) {
345 cout <<
"... calling addItem with arg : " << sub_item <<
endl;
346 addItem( itms, sub_item );
348 idx = obj_path.
find(
"/", idx + 1 );
361 addItem( m_itemList,
path );
367 addItem( m_optItemList,
path );
372 cout <<
"TESSerializer m_itemList : " << m_itemList.size() <<
" Items" <<
endl;
373 for ( Items::const_iterator i = m_itemList.begin(); i != m_itemList.end(); ++i ) {
374 cout <<
"\tItem : " << ( *i )->path() <<
endl;
376 cout <<
"TESSerializer m_optItemList : " << m_optItemList.size() <<
" Items" <<
endl;
377 for ( Items::const_iterator i = m_optItemList.begin(); i != m_optItemList.end(); ++i ) {
378 cout <<
"\tItem : " << ( *i )->path() <<
endl;
384 for ( Items::const_iterator i = m_itemList.begin(); i != m_itemList.end(); ++i ) {
385 if ( ( *i )->path() ==
path )
return ( *i );
387 for ( Items::const_iterator j = m_optItemList.begin(); j != m_optItemList.end(); ++j ) {
388 if ( ( *j )->path() ==
path )
return ( *j );
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.
IRegistry * registry() const
Get pointer to Registry.
const std::string * par() const override
Retrieve string parameters.
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()
LinkManager * linkMgr() const
Retrieve Link manager.
TESSerializer(IDataProviderSvc *svc, IAddressCreator *ac)
Constructor.
IAddressCreator interface definition.
const CLID & clID() const override
Access : Retrieve class ID of the link.
Generic Transient Address.
Data provider interface definition.
Description of the DataStoreItem class.
virtual long svcType() const =0
Retrieve service type.
long svcType() const override
Access : retrieve the storage type of the class id.
bool analyse(IRegistry *dir, int level) override
Analysis callback.
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.
const std::string & path() const
Access to path of object.
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.
virtual void setAddress(IOpaqueAddress *pAddress)=0
Set/Update Opaque storage address.
long size() const
Retrieve number of link present.
constexpr static const auto FAILURE
const unsigned long * ipar() const override
Retrieve integer parameters.
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 addLink(const std::string &path, const DataObject *pObject) const
Add link by object reference and path.