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 ).
ignore( );
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 );
111 m_TESMgr->traverseSubTree( obj,
this ).
ignore( );
118 objects.
reserve( m_objects.size() );
119 for_each(
begin( m_objects ),
end( m_objects ), [
this, &objects](
auto obj ) {
124 buffer.WriteInt( objects.
size() );
126 for (
auto& [pObj, cl] : objects ) {
127 DataObjectPush p( pObj );
131 buffer.WriteString( loc.
c_str() );
132 buffer.WriteString( cl->GetName() );
133 cl->Streamer( pObj, buffer );
137 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 ) );
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 );
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 );
289 m_addressCreator->createAddress( gadd.
svcType(), gadd.
clID(), gadd.
par(), gadd.
ipar(), iopref );
291 throw GaudiException(
"Failure in creating OpaqueAddress for reconstructed registry",
"", createAddressStat );
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 ==
"*" ) {
329 if ( m_verifyItems ) {
330 size_t idx = obj_path.
find(
"/", 1 );
331 while ( idx != std::string::npos ) {
333 if ( 0 == findItem( sub_item ) ) {
334 cout <<
"... calling addItem with arg : " << sub_item <<
endl;
335 addItem( itms, sub_item );
337 idx = obj_path.
find(
"/", idx + 1 );
350 addItem( m_itemList,
path );
356 addItem( m_optItemList,
path );
361 cout <<
"TESSerializer m_itemList : " << m_itemList.size() <<
" Items" <<
endl;
362 for ( Items::const_iterator i = m_itemList.begin(); i != m_itemList.end(); ++i ) {
363 cout <<
"\tItem : " << ( *i )->path() <<
endl;
365 cout <<
"TESSerializer m_optItemList : " << m_optItemList.size() <<
" Items" <<
endl;
366 for ( Items::const_iterator i = m_optItemList.begin(); i != m_optItemList.end(); ++i ) {
367 cout <<
"\tItem : " << ( *i )->path() <<
endl;
373 for ( Items::const_iterator i = m_itemList.begin(); i != m_itemList.end(); ++i ) {
374 if ( ( *i )->path() ==
path )
return ( *i );
376 for ( Items::const_iterator j = m_optItemList.begin(); j != m_optItemList.end(); ++j ) {
377 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.
const StatusCode & ignore() const
Ignore/check StatusCode.
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.