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 ) {
53 m_objects.push_back( dir->
object() );
65 , m_verifyItems( false )
67 , m_addressCreator( ac ) {}
88 for ( Items::iterator i = m_itemList.begin(); i != m_itemList.end(); i++ ) {
89 m_currentItem = ( *i );
91 status = m_TES->retrieveObject( m_currentItem->path(), obj );
93 m_TESMgr->traverseSubTree( obj,
this );
95 string text(
"WARNING: Cannot retrieve TES object(s) for serialisation: " );
96 text += m_currentItem->path();
106 for ( Items::iterator i = m_optItemList.begin(); i != m_optItemList.end(); i++ ) {
107 m_currentItem = ( *i );
109 status = m_TES->retrieveObject( m_currentItem->path(), obj );
110 if ( status.
isSuccess() ) { m_TESMgr->traverseSubTree( obj,
this ); }
116 objects.
reserve( m_objects.size() );
117 for_each(
begin( m_objects ),
end( m_objects ), [
this, &objects](
auto obj ) {
122 buffer.WriteInt( objects.
size() );
124 for (
auto& [pObj, cl] : objects ) {
125 DataObjectPush p( pObj );
129 buffer.WriteString( loc.
c_str() );
130 buffer.WriteString( cl->GetName() );
131 cl->Streamer( pObj, buffer );
135 int numLinks = linkMgr->
size();
136 buffer.WriteInt( numLinks );
138 for (
int it = 0; it != numLinks; it++ ) {
139 const string& link = linkMgr->
link( it )->
path();
140 buffer.WriteString( link.
c_str() );
147 buffer.WriteInt( 1 );
148 const string*
par = iop->
par();
150 long clid = iop->
clID();
151 buffer.WriteLong( svcType );
152 buffer.WriteLong( clid );
153 buffer.WriteString(
par->c_str() );
155 buffer.WriteInt( 0 );
184 StatusCode sc, registerStat, createAddressStat;
187 buffer.SetReadMode();
188 buffer.SetBufferOffset();
190 buffer.ReadInt( nObjects );
191 for (
int i = 0; i < nObjects; ++i ) {
193 buffer.ReadString( text,
sizeof( text ) );
200 buffer.ReadString( text,
sizeof( text ) );
201 TClass* cl = gROOT->GetClass( text );
206 cout <<
"TESSerializer WARNING : gROOT->GetClass fails for clname : " <<
location.c_str() <<
endl;
213 DataObjectPush push( obj );
214 cl->Streamer( obj, buffer );
220 buffer.ReadInt( nlink );
222 for (
int j = 0; j < nlink; ++j ) {
223 buffer.ReadString( text,
sizeof( text ) );
229 registerStat = m_TES->registerObject(
location, obj );
233 sc = m_TESMgr->setRoot(
location, obj );
236 m_TES->findObject(
location, dummy );
238 m_TES->registerObject(
location, obj );
243 buffer.ReadInt( flag );
246 buffer.ReadLong( svcType );
248 buffer.ReadLong( clid );
249 buffer.ReadString( text,
sizeof( text ) );
261 buffer.ReadInt( flag );
269 buffer.ReadLong( svcType );
272 buffer.ReadLong( clid );
273 const CLID classid( clid );
276 cp = buffer.ReadString( text,
sizeof( text ) );
277 const string opaque(
cp );
280 const string& p2 =
"";
281 unsigned long ip1( 0 );
282 unsigned long ip2( 0 );
287 m_addressCreator->createAddress( gadd.
svcType(), gadd.
clID(), gadd.
par(), gadd.
ipar(), iopref );
289 throw GaudiException(
"Failure in creating OpaqueAddress for reconstructed registry",
"", createAddressStat );
308 size_t sep = descriptor.
rfind(
"#" );
309 if ( sep > descriptor.
length() ) {
311 obj_path = descriptor;
315 obj_path = descriptor.
substr( 0, sep );
316 slevel = descriptor.
substr( sep + 1 );
320 if ( slevel ==
"*" ) {
327 if ( m_verifyItems ) {
328 size_t idx = obj_path.
find(
"/", 1 );
329 while ( idx != std::string::npos ) {
331 if ( 0 == findItem( sub_item ) ) {
332 cout <<
"... calling addItem with arg : " << sub_item <<
endl;
333 addItem( itms, sub_item );
335 idx = obj_path.
find(
"/", idx + 1 );
348 addItem( m_itemList,
path );
354 addItem( m_optItemList,
path );
359 cout <<
"TESSerializer m_itemList : " << m_itemList.size() <<
" Items" <<
endl;
360 for ( Items::const_iterator i = m_itemList.begin(); i != m_itemList.end(); ++i ) {
361 cout <<
"\tItem : " << ( *i )->path() <<
endl;
363 cout <<
"TESSerializer m_optItemList : " << m_optItemList.size() <<
" Items" <<
endl;
364 for ( Items::const_iterator i = m_optItemList.begin(); i != m_optItemList.end(); ++i ) {
365 cout <<
"\tItem : " << ( *i )->path() <<
endl;
371 for ( Items::const_iterator i = m_itemList.begin(); i != m_itemList.end(); ++i ) {
372 if ( ( *i )->path() ==
path )
return ( *i );
374 for ( Items::const_iterator j = m_optItemList.begin(); j != m_optItemList.end(); ++j ) {
375 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.
void loadBuffer(TBufferFile &)
Rebuild TES from items in a TBufferFile.
GAUDI_API void popCurrentDataObject()
LinkManager * linkMgr() const
Retrieve Link manager.
def getClass(name, libs=[])
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.
virtual IRegistry * registry() const =0
Update branch name.
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.
AttribStringParser::Iterator begin(const AttribStringParser &parser)
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...
T emplace_back(T... args)
long addLink(const std::string &path, const DataObject *pObject) const
Add link by object reference and path.