31#include <TBufferFile.h>
33#include <TInterpreter.h>
39#define SERIALIZER_END "EOF"
42 struct DataObjectPush {
51 if ( level < m_currentItem->depth() ) {
52 if ( dir->
object() != 0 ) {
93 m_TESMgr->traverseSubTree( obj,
this ).ignore( );
95 string text(
"WARNING: Cannot retrieve TES object(s) for serialisation: " );
100 cout << text << endl;
111 m_TESMgr->traverseSubTree( obj,
this ).ignore( );
117 std::vector<std::tuple<DataObject*, TClass*>> objects;
120 if (
auto cl =
getClass( obj ) ) objects.emplace_back( obj, cl );
124 buffer.WriteInt( objects.size() );
126 for (
auto& [pObj, cl] : objects ) {
127 DataObjectPush p( pObj );
130 std::string loc = pObj->registry()->identifier();
131 buffer.WriteString( loc.c_str() );
132 buffer.WriteString( cl->GetName() );
133 cl->Streamer( pObj, buffer );
137 long int numLinks = linkMgr->
size();
138 buffer.WriteInt( numLinks );
140 for (
int it = 0; it != numLinks; it++ ) {
141 const string& link = linkMgr->
link( it )->
path();
142 buffer.WriteString( link.c_str() );
149 buffer.WriteInt( 1 );
150 const string* par = iop->
par();
152 long clid = iop->
clID();
153 buffer.WriteLong( svcType );
154 buffer.WriteLong( clid );
155 buffer.WriteString( par->c_str() );
157 buffer.WriteInt( 0 );
186 StatusCode sc, registerStat, createAddressStat;
189 buffer.SetReadMode();
190 buffer.SetBufferOffset();
192 buffer.ReadInt( nObjects );
193 for (
int i = 0; i < nObjects; ++i ) {
195 buffer.ReadString( text,
sizeof( text ) );
196 string location( text );
197 if ( !location.compare(
"EOF" ) ) {
202 buffer.ReadString( text,
sizeof( text ) );
203 TClass* cl = gROOT->GetClass( text );
208 cout <<
"TESSerializer WARNING : gROOT->GetClass fails for clname : " << location.c_str() << endl;
215 DataObjectPush push( obj );
216 cl->Streamer( obj, buffer );
222 buffer.ReadInt( nlink );
224 for (
int j = 0; j < nlink; ++j ) {
225 buffer.ReadString( text,
sizeof( text ) );
231 registerStat =
m_TES->registerObject( location, obj );
234 if ( location ==
"/Event" ) {
235 sc =
m_TESMgr->setRoot( location, obj );
238 m_TES->findObject( location, dummy ).ignore( );
240 m_TES->registerObject( location, obj ).ignore( );
245 buffer.ReadInt( flag );
248 buffer.ReadLong( svcType );
250 buffer.ReadLong( clid );
251 buffer.ReadString( text,
sizeof( text ) );
263 buffer.ReadInt( flag );
271 buffer.ReadLong( svcType );
274 buffer.ReadLong( clid );
275 const CLID classid( clid );
278 cp = buffer.ReadString( text,
sizeof( text ) );
279 const string opaque( cp );
282 const string& p2 =
"";
283 unsigned long ip1( 0 );
284 unsigned long ip2( 0 );
291 throw GaudiException(
"Failure in creating OpaqueAddress for reconstructed registry",
"", createAddressStat );
307 std::string obj_path;
310 size_t sep = descriptor.rfind(
"#" );
311 if ( sep > descriptor.length() ) {
313 obj_path = descriptor;
317 obj_path = descriptor.substr( 0, sep );
318 slevel = descriptor.substr( sep + 1 );
322 if ( slevel ==
"*" ) {
325 level = std::stoi( slevel );
330 size_t idx = obj_path.find(
"/", 1 );
331 while ( idx != std::string::npos ) {
332 std::string sub_item = obj_path.substr( 0, idx );
334 cout <<
"... calling addItem with arg : " << sub_item << endl;
337 idx = obj_path.find(
"/", idx + 1 );
344 itms.push_back( item );
361 cout <<
"TESSerializer m_itemList : " <<
m_itemList.size() <<
" Items" << endl;
363 cout <<
"\tItem : " << ( *i )->path() << endl;
365 cout <<
"TESSerializer m_optItemList : " <<
m_optItemList.size() <<
" Items" << endl;
367 cout <<
"\tItem : " << ( *i )->path() << endl;
374 if ( ( *i )->path() == path )
return ( *i );
377 if ( ( *j )->path() == path )
return ( *j );
unsigned int CLID
Class ID definition.
A DataObject is the base class of any identifiable object on any data store.
IRegistry * registry() const
Get pointer to Registry.
LinkManager * linkMgr()
Retrieve Link manager.
Description of the DataStoreItem class.
Define general base for Gaudi exception.
IDataManagerSvc * m_TESMgr
TES pointer.
std::vector< DataStoreItem * > Items
Objects m_objects
Selected list of Objects to be serialized (DataObject ptrs)
bool analyse(IRegistry *dir, int level) override
Analysis callback.
void dumpBuffer(TBufferFile &)
Dump TES contents listed in m_itemList/m_optItemList to a TBufferFile.
DataStoreItem * m_currentItem
Current item while traversing the TES tree.
void checkItems()
print out the contents of m_itemList and m_optItemList (std::cout)
TClass * getClass(DataObject *obj)
caching wrapper to TClass::GetClass
bool m_verifyItems
Boolean Flag as used by GaudiSvc/PersistencySvc/OutputStreamer.
bool m_strict
Boolean Flag used to determine error tolerance.
TESSerializer(IDataProviderSvc *svc, IAddressCreator *ac)
Constructor.
void addOptItem(const std::string &path)
add an item to the TESSerializer's optional list (#notation)
IAddressCreator * m_addressCreator
IAddress Creator for Opaque Addresses.
void addItem(const std::string &path)
add an item to the TESSerializer's list (#notation)
void loadBuffer(TBufferFile &)
Rebuild TES from items in a TBufferFile.
IDataProviderSvc * m_TES
TES pointer.
Items m_itemList
Vector of items to be saved to this stream (DataStoreItem ptrs)
DataStoreItem * findItem(const std::string &path)
Find single item identified by its path (exact match)
Items m_optItemList
Vector of optional items to be saved to this stream (DataStoreItem ptrs)
Generic Transient Address.
long svcType() const override
Access : retrieve the storage type of the class id.
const CLID & clID() const override
Access : Retrieve class ID of the link.
const std::string * par() const override
Retrieve string parameters.
const unsigned long * ipar() const override
Retrieve integer parameters.
IAddressCreator interface definition.
Data provider interface definition.
Opaque address interface definition.
virtual long svcType() const =0
Retrieve service type.
virtual const CLID & clID() const =0
Retrieve class information from link.
virtual const std::string * par() const =0
Retrieve String parameters.
virtual IRegistry * registry() const =0
Update branch name.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
virtual DataObject * object() const =0
Retrieve object behind the link.
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
virtual void setAddress(IOpaqueAddress *pAddress)=0
Set/Update Opaque storage address.
const std::string & path() const
Access to path of object.
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)
Add link by object reference and path.
long size() const
Retrieve number of link present.
const Link * link(long id) const
Retrieve symbolic link identified by ID.
This class is used for returning status codes from appropriate routines.
constexpr static const auto FAILURE
GAUDI_API void pushCurrentDataObject(DataObject **pobjAddr)
GAUDI_API void popCurrentDataObject()