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 ) {}
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 ); }
106 objects.
reserve( m_objects.size() );
107 for_each(
begin( m_objects ),
end( m_objects ), [
this, &objects](
auto obj ) {
112 buffer.WriteInt( objects.
size() );
114 for (
auto& [pObj, cl] : objects ) {
115 DataObjectPush p( pObj );
119 buffer.WriteString( loc.
c_str() );
120 buffer.WriteString( cl->GetName() );
121 cl->Streamer( pObj, buffer );
125 int numLinks = linkMgr->
size();
126 buffer.WriteInt( numLinks );
128 for (
int it = 0; it != numLinks; it++ ) {
129 const string& link = linkMgr->
link( it )->
path();
130 buffer.WriteString( link.
c_str() );
137 buffer.WriteInt( 1 );
138 const string*
par = iop->
par();
140 long clid = iop->
clID();
141 buffer.WriteLong( svcType );
142 buffer.WriteLong( clid );
143 buffer.WriteString(
par->c_str() );
145 buffer.WriteInt( 0 );
174 StatusCode sc, registerStat, createAddressStat;
177 buffer.SetReadMode();
178 buffer.SetBufferOffset();
180 buffer.ReadInt( nObjects );
181 for (
int i = 0; i < nObjects; ++i ) {
183 buffer.ReadString( text,
sizeof( text ) );
190 buffer.ReadString( text,
sizeof( text ) );
191 TClass* cl = gROOT->GetClass( text );
196 cout <<
"TESSerializer WARNING : gROOT->GetClass fails for clname : " <<
location.c_str() <<
endl;
203 DataObjectPush push( obj );
204 cl->Streamer( obj, buffer );
210 buffer.ReadInt( nlink );
212 for (
int j = 0; j < nlink; ++j ) {
213 buffer.ReadString( text,
sizeof( text ) );
219 registerStat = m_TES->registerObject(
location, obj );
223 sc = m_TESMgr->setRoot(
location, obj );
226 m_TES->findObject(
location, dummy );
228 m_TES->registerObject(
location, obj );
233 buffer.ReadInt( flag );
236 buffer.ReadLong( svcType );
238 buffer.ReadLong( clid );
239 buffer.ReadString( text,
sizeof( text ) );
251 buffer.ReadInt( flag );
259 buffer.ReadLong( svcType );
262 buffer.ReadLong( clid );
263 const CLID classid( clid );
266 cp = buffer.ReadString( text,
sizeof( text ) );
267 const string opaque(
cp );
270 const string& p2 =
"";
271 unsigned long ip1( 0 );
272 unsigned long ip2( 0 );
277 m_addressCreator->createAddress( gadd.
svcType(), gadd.
clID(), gadd.
par(), gadd.
ipar(), iopref );
279 throw GaudiException(
"Failure in creating OpaqueAddress for reconstructed registry",
"", createAddressStat );
298 size_t sep = descriptor.
rfind(
"#" );
299 if ( sep > descriptor.
length() ) {
301 obj_path = descriptor;
305 obj_path = descriptor.
substr( 0, sep );
306 slevel = descriptor.
substr( sep + 1 );
310 if ( slevel ==
"*" ) {
317 if ( m_verifyItems ) {
318 size_t idx = obj_path.
find(
"/", 1 );
319 while ( idx != std::string::npos ) {
321 if ( 0 == findItem( sub_item ) ) {
322 cout <<
"... calling addItem with arg : " << sub_item <<
endl;
323 addItem( itms, sub_item );
325 idx = obj_path.
find(
"/", idx + 1 );
338 addItem( m_itemList,
path );
344 addItem( m_optItemList,
path );
349 cout <<
"TESSerializer m_itemList : " << m_itemList.size() <<
" Items" <<
endl;
350 for ( Items::const_iterator i = m_itemList.begin(); i != m_itemList.end(); ++i ) {
351 cout <<
"\tItem : " << ( *i )->path() <<
endl;
353 cout <<
"TESSerializer m_optItemList : " << m_optItemList.size() <<
" Items" <<
endl;
354 for ( Items::const_iterator i = m_optItemList.begin(); i != m_optItemList.end(); ++i ) {
355 cout <<
"\tItem : " << ( *i )->path() <<
endl;
361 for ( Items::const_iterator i = m_itemList.begin(); i != m_itemList.end(); ++i ) {
362 if ( ( *i )->path() ==
path )
return ( *i );
364 for ( Items::const_iterator j = m_optItemList.begin(); j != m_optItemList.end(); ++j ) {
365 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.