21 #include "TBufferFile.h" 23 #include "TInterpreter.h" 29 #define SERIALIZER_END "EOF" 33 struct DataObjectPush {
43 if ( level < m_currentItem->depth() ) {
44 if ( dir->
object() != 0 ) {
45 m_objects.push_back( dir->
object() );
57 , m_verifyItems( false )
59 , m_addressCreator( ac )
90 string text(
"WARNING: Cannot retrieve TES object(s) for serialisation: " );
115 DataObjectPush p( pObj );
119 const type_info& objClass =
typeid( *pObj );
129 const char* clName = objClassName.c_str();
131 cl = gROOT->GetClass( clName );
140 cout <<
"WARNING: gROOT->GetClass fails for clname : " << objClassName.c_str() <<
endl;
141 cout <<
"WARNING: Disregarding " << objClassName.c_str() <<
"erasing from object list" <<
endl;
149 buffer.WriteString( loc.
c_str() );
150 buffer.WriteString( cl->GetName() );
151 cl->Streamer( pObj, buffer );
155 int numLinks = linkMgr->
size();
156 buffer.WriteInt( numLinks );
158 for (
int it = 0; it != numLinks; it++ ) {
159 const string& link = linkMgr->
link( it )->
path();
160 buffer.WriteString( link.
c_str() );
167 buffer.WriteInt( 1 );
168 const string*
par = iop->
par();
170 long clid = iop->
clID();
171 buffer.WriteLong( svcType );
172 buffer.WriteLong( clid );
173 buffer.WriteString( par->
c_str() );
175 buffer.WriteInt( 0 );
205 StatusCode sc, registerStat, createAddressStat;
208 buffer.SetReadMode();
209 buffer.SetBufferOffset();
211 buffer.ReadInt( nObjects );
212 for (
int i = 0; i < nObjects; ++i ) {
214 buffer.ReadString( text,
sizeof( text ) );
216 if ( !location.
compare(
"EOF" ) ) {
221 buffer.ReadString( text,
sizeof( text ) );
222 TClass* cl = gROOT->GetClass( text );
227 cout <<
"TESSerializer WARNING : gROOT->GetClass fails for clname : " << location.
c_str() <<
endl;
234 DataObjectPush push( obj );
235 cl->Streamer( obj, buffer );
241 buffer.ReadInt( nlink );
243 for (
int j = 0; j < nlink; ++j ) {
244 buffer.ReadString( text,
sizeof( text ) );
253 if ( location ==
"/Event" ) {
264 buffer.ReadInt( flag );
267 buffer.ReadLong( svcType );
269 buffer.ReadLong( clid );
270 buffer.ReadString( text,
sizeof( text ) );
282 buffer.ReadInt( flag );
290 buffer.ReadLong( svcType );
293 buffer.ReadLong( clid );
294 const CLID classid( clid );
297 cp = buffer.ReadString( text,
sizeof( text ) );
298 const string opaque( cp );
301 const string& p2 =
"";
302 unsigned long ip1( 0 );
303 unsigned long ip2( 0 );
310 throw GaudiException(
"Failure in creating OpaqueAddress for reconstructed registry",
"", createAddressStat );
330 size_t sep = descriptor.
rfind(
"#" );
331 if ( sep > descriptor.
length() ) {
333 obj_path = descriptor;
337 obj_path = descriptor.
substr( 0, sep );
338 slevel = descriptor.
substr( sep + 1 );
342 if ( slevel ==
"*" ) {
350 size_t idx = obj_path.
find(
"/", 1 );
351 while ( idx != std::string::npos ) {
354 cout <<
"... calling addItem with arg : " << sub_item <<
endl;
357 idx = obj_path.
find(
"/", idx + 1 );
386 cout <<
"\tItem : " << ( *i )->path() <<
endl;
390 cout <<
"\tItem : " << ( *i )->path() <<
endl;
398 if ( ( *i )->path() ==
path )
return ( *i );
401 if ( ( *j )->path() ==
path )
return ( *j );
const std::string & path() const
Access to path of object.
constexpr static const auto FAILURE
void checkItems()
print out the contents of m_itemList and m_optItemList (std::cout)
Define general base for Gaudi exception.
virtual const CLID & clID() const =0
Retrieve class information from link.
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.
virtual StatusCode createAddress(long svc_type, const CLID &clid, const std::string *par, const unsigned long *ipar, IOpaqueAddress *&refpAddress)=0
Create a Generic address using explicit arguments to identify a single object.
GAUDI_API void popCurrentDataObject()
virtual StatusCode findObject(IRegistry *pDirectory, boost::string_ref path, DataObject *&pObject)=0
Find object identified by its directory entry.
virtual StatusCode setRoot(std::string root_name, DataObject *pObject)=0
Initialize data store for new event by giving new event path.
TESSerializer(IDataProviderSvc *svc, IAddressCreator *ac)
Constructor.
IAddressCreator interface definition.
Items m_optItemList
Vector of optional items to be saved to this stream (DataStoreItem ptrs)
bool m_verifyItems
Boolean Flag as used by GaudiSvc/PersistencySvc/OutputStreamer.
long addLink(const std::string &path, const DataObject *pObject) const
Add link by object reference and path.
Generic Transient Address.
Data provider interface definition.
virtual const std::string * par() const =0
Retrieve String parameters.
Description of the DataStoreItem class.
IAddressCreator * m_addressCreator
IAddress Creator for Opaque Addresses.
IRegistry * registry() const
Get pointer to Registry.
Items m_itemList
Vector of items to be saved to this stream (DataStoreItem ptrs)
bool m_strict
Boolean Flag used to determine error tolerance.
LinkManager * linkMgr() const
Retrieve Link manager.
const std::string & path() const
Accessor: Retrieve load path.
virtual StatusCode traverseSubTree(boost::string_ref sub_path, IDataStoreAgent *pAgent)=0
Analyse by traversing all data objects below the sub tree identified by its full path name...
IDataManagerSvc * m_TESMgr
TES pointer.
bool analyse(IRegistry *dir, int level) override
Analysis callback.
virtual const id_type & identifier() const =0
Full identifier (or key)
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 unsigned long * ipar() const override
Retrieve integer parameters.
const std::string * par() const override
Retrieve string parameters.
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...
virtual long svcType() const =0
Retrieve service type.
void addItem(const std::string &path)
add an item to the TESSerializer's list (#notation)
unsigned int CLID
Class ID definition.
virtual StatusCode retrieveObject(IRegistry *pDirectory, boost::string_ref path, DataObject *&pObject)=0
Retrieve object identified by its directory entry.
GAUDI_API void pushCurrentDataObject(DataObject **pobjAddr)
long svcType() const override
Access : retrieve the storage type of the class id.
virtual DataObject * object() const =0
Retrieve object behind the link.
virtual StatusCode registerObject(boost::string_ref fullPath, DataObject *pObject)=0
Register object with the data store.
virtual void setAddress(IOpaqueAddress *pAddress)=0
Set/Update Opaque storage address.
Objects m_objects
Selected list of Objects to be serialized (DataObject ptrs)
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.
DataStoreItem * m_currentItem
Current item while traversing the TES tree.
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
const CLID & clID() const override
Access : Retrieve class ID of the link.
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...
IDataProviderSvc * m_TES
TES pointer.
long size() const
Retrieve number of link present.
std::map< std::string, TClass * > m_classMap
Map of gROOT class information.