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 ) {}
85 string text(
"WARNING: Cannot retrieve TES object(s) for serialisation: " );
108 DataObjectPush p( pObj );
112 const type_info& objClass =
typeid( *pObj );
122 const char* clName = objClassName.c_str();
124 cl = gROOT->GetClass( clName );
133 cout <<
"WARNING: gROOT->GetClass fails for clname : " << objClassName.c_str() <<
endl;
134 cout <<
"WARNING: Disregarding " << objClassName.c_str() <<
"erasing from object list" <<
endl;
142 buffer.WriteString( loc.
c_str() );
143 buffer.WriteString( cl->GetName() );
144 cl->Streamer( pObj, buffer );
148 int numLinks = linkMgr->
size();
149 buffer.WriteInt( numLinks );
151 for (
int it = 0; it != numLinks; it++ ) {
152 const string& link = linkMgr->
link( it )->
path();
153 buffer.WriteString( link.
c_str() );
160 buffer.WriteInt( 1 );
161 const string*
par = iop->
par();
163 long clid = iop->
clID();
164 buffer.WriteLong( svcType );
165 buffer.WriteLong( clid );
166 buffer.WriteString( par->
c_str() );
168 buffer.WriteInt( 0 );
197 StatusCode sc, registerStat, createAddressStat;
200 buffer.SetReadMode();
201 buffer.SetBufferOffset();
203 buffer.ReadInt( nObjects );
204 for (
int i = 0; i < nObjects; ++i ) {
206 buffer.ReadString( text,
sizeof( text ) );
208 if ( !location.
compare(
"EOF" ) ) {
213 buffer.ReadString( text,
sizeof( text ) );
214 TClass* cl = gROOT->GetClass( text );
219 cout <<
"TESSerializer WARNING : gROOT->GetClass fails for clname : " << location.
c_str() <<
endl;
226 DataObjectPush push( obj );
227 cl->Streamer( obj, buffer );
233 buffer.ReadInt( nlink );
235 for (
int j = 0; j < nlink; ++j ) {
236 buffer.ReadString( text,
sizeof( text ) );
245 if ( location ==
"/Event" ) {
256 buffer.ReadInt( flag );
259 buffer.ReadLong( svcType );
261 buffer.ReadLong( clid );
262 buffer.ReadString( text,
sizeof( text ) );
274 buffer.ReadInt( flag );
282 buffer.ReadLong( svcType );
285 buffer.ReadLong( clid );
286 const CLID classid( clid );
289 cp = buffer.ReadString( text,
sizeof( text ) );
290 const string opaque( cp );
293 const string& p2 =
"";
294 unsigned long ip1( 0 );
295 unsigned long ip2( 0 );
302 throw GaudiException(
"Failure in creating OpaqueAddress for reconstructed registry",
"", createAddressStat );
321 size_t sep = descriptor.
rfind(
"#" );
322 if ( sep > descriptor.
length() ) {
324 obj_path = descriptor;
328 obj_path = descriptor.
substr( 0, sep );
329 slevel = descriptor.
substr( sep + 1 );
333 if ( slevel ==
"*" ) {
341 size_t idx = obj_path.
find(
"/", 1 );
342 while ( idx != std::string::npos ) {
345 cout <<
"... calling addItem with arg : " << sub_item <<
endl;
348 idx = obj_path.
find(
"/", idx + 1 );
374 cout <<
"\tItem : " << ( *i )->path() <<
endl;
378 cout <<
"\tItem : " << ( *i )->path() <<
endl;
385 if ( ( *i )->path() ==
path )
return ( *i );
388 if ( ( *j )->path() ==
path )
return ( *j );
const std::string & path() const
Access to path of object.
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.
virtual StatusCode traverseSubTree(boost::string_ref sub_tree_path, IDataStoreAgent *pAgent)=0
Analyse by traversing all data objects below the sub tree identified by its full path name...
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.
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.
StatusCode registerObject(boost::string_ref fullPath, DataObject *pObject)
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)
constexpr static const auto FAILURE
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.