RootHistCnv::RDirectoryCnv Class Reference

Create persistent and transient representations of data store directories. More...

#include <src/RDirectoryCnv.h>

Inheritance diagram for RootHistCnv::RDirectoryCnv:
Collaboration diagram for RootHistCnv::RDirectoryCnv:

Public Member Functions

virtual StatusCode createObj (IOpaqueAddress *pAddr, DataObject *&refpObj)
 Create the transient representation of an object. More...
 
virtual StatusCode fillObjRefs (IOpaqueAddress *pAddr, DataObject *refpObj)
 Update the transient object from the other representation. More...
 
virtual StatusCode createRep (DataObject *pObj, IOpaqueAddress *&refpAddr)
 Convert the transient object to the requested representation. More...
 
virtual StatusCode updateRep (IOpaqueAddress *pAddr, DataObject *pObject)
 Convert the transient object to the requested representation. More...
 
 RDirectoryCnv (ISvcLocator *svc)
 Standard constructor. More...
 
 RDirectoryCnv (ISvcLocator *svc, const CLID &clid)
 Standard constructor. More...
 
virtual ~RDirectoryCnv ()
 Standard destructor. More...
 
- Public Member Functions inherited from RootHistCnv::RConverter
long repSvcType () const
 Retrieve the class type of the data store the converter uses. More...
 
StatusCode error (const std::string &msg)
 
StatusCode regTFile (const std::string, const TFile *)
 
StatusCode findTFile (const std::string, TFile *&)
 
std::string diskDirectory (const std::string &loc)
 
std::string directory (const std::string &loc)
 
void setDirectory (const std::string &loc)
 
void setDiskDirectory (const std::string &loc)
 
StatusCode createDirectory (const std::string &loc)
 
StatusCode createDiskDirectory (const std::string &loc)
 
std::string getDirectory ()
 
std::string convertId (const std::string &) const
 
- Public Member Functions inherited from Converter
virtual StatusCode initialize ()
 Initialize the converter. More...
 
virtual StatusCode finalize ()
 Initialize the converter. More...
 
virtual StatusCode setDataProvider (IDataProviderSvc *svc)
 Set Data provider service. More...
 
virtual SmartIF< IDataProviderSvc > & dataProvider () const
 Get Data provider service. More...
 
virtual StatusCode setConversionSvc (IConversionSvc *svc)
 Set conversion service the converter is connected to. More...
 
virtual SmartIF< IConversionSvc > & conversionSvc () const
 Get conversion service the converter is connected to. More...
 
virtual StatusCode setAddressCreator (IAddressCreator *creator)
 Set address creator facility. More...
 
virtual SmartIF< IAddressCreator > & addressCreator () const
 Retrieve address creator facility. More...
 
virtual const CLIDobjType () const
 Retrieve the class type of objects the converter produces. More...
 
virtual long i_repSvcType () const
 Retrieve the class type of the data store the converter uses. More...
 
virtual StatusCode updateObj (IOpaqueAddress *pAddress, DataObject *refpObject)
 Update the transient object from the other representation. More...
 
virtual StatusCode updateObjRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Update the references of an updated transient object. More...
 
virtual StatusCode fillRepRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Resolve the references of the converted object. More...
 
virtual StatusCode updateRepRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Update the references of an already converted object. More...
 
 Converter (long storage_type, const CLID &class_type, ISvcLocator *svc=0)
 Standard Constructor. More...
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=false) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode service (const std::string &type, const std::string &name, T *&psvc) const
 Access a service by name, type creating it if it doesn't already exist. More...
 
SmartIF< IServiceservice (const std::string &name, const bool createIf=true) const
 Return a pointer to the service identified by name (or "type/name") More...
 
virtual StatusCode initialize ()
 Initialize the converter. More...
 
virtual StatusCode finalize ()
 Initialize the converter. More...
 
virtual StatusCode setDataProvider (IDataProviderSvc *svc)
 Set Data provider service. More...
 
virtual SmartIF< IDataProviderSvc > & dataProvider () const
 Get Data provider service. More...
 
virtual StatusCode setConversionSvc (IConversionSvc *svc)
 Set conversion service the converter is connected to. More...
 
virtual SmartIF< IConversionSvc > & conversionSvc () const
 Get conversion service the converter is connected to. More...
 
virtual StatusCode setAddressCreator (IAddressCreator *creator)
 Set address creator facility. More...
 
virtual SmartIF< IAddressCreator > & addressCreator () const
 Retrieve address creator facility. More...
 
virtual const CLIDobjType () const
 Retrieve the class type of objects the converter produces. More...
 
virtual long i_repSvcType () const
 Retrieve the class type of the data store the converter uses. More...
 
virtual StatusCode updateObj (IOpaqueAddress *pAddress, DataObject *refpObject)
 Update the transient object from the other representation. More...
 
virtual StatusCode updateObjRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Update the references of an updated transient object. More...
 
virtual StatusCode fillRepRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Resolve the references of the converted object. More...
 
virtual StatusCode updateRepRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Update the references of an already converted object. More...
 
 Converter (long storage_type, const CLID &class_type, ISvcLocator *svc=0)
 Standard Constructor. More...
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=false) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode service (const std::string &type, const std::string &name, T *&psvc) const
 Access a service by name, type creating it if it doesn't already exist. More...
 
SmartIF< IServiceservice (const std::string &name, const bool createIf=true) const
 Return a pointer to the service identified by name (or "type/name") More...
 
- Public Member Functions inherited from extend_interfaces1< IConverter >
virtual ~extend_interfaces1 ()
 Virtual destructor. More...
 
virtual ~extend_interfaces1 ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IConverter
 DeclareInterfaceID (IConverter, 3, 0)
 InterfaceID. More...
 
virtual ~IConverter ()
 Virtual destructor. More...
 
 DeclareInterfaceID (IConverter, 3, 0)
 InterfaceID. More...
 
virtual ~IConverter ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IInterface
virtual void * i_cast (const InterfaceID &) const =0
 main cast function More...
 
virtual std::vector< std::string > getInterfaceNames () const =0
 Returns a vector of strings containing the names of all the implemented interfaces. More...
 
virtual unsigned long addRef ()=0
 Increment the reference count of Interface instance. More...
 
virtual unsigned long release ()=0
 Release Interface instance. More...
 
virtual unsigned long refCount () const =0
 Current reference count. More...
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)=0
 Set the void** to the pointer to the requested interface of the instance. More...
 
virtual ~IInterface ()
 Virtual destructor. More...
 
virtual void * i_cast (const InterfaceID &) const =0
 main cast function More...
 
virtual std::vector< std::string > getInterfaceNames () const =0
 Returns a vector of strings containing the names of all the implemented interfaces. More...
 
virtual unsigned long addRef ()=0
 Increment the reference count of Interface instance. More...
 
virtual unsigned long release ()=0
 Release Interface instance. More...
 
virtual unsigned long refCount () const =0
 Current reference count. More...
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)=0
 Set the void** to the pointer to the requested interface of the instance. More...
 
virtual ~IInterface ()
 Virtual destructor. More...
 

Static Public Member Functions

static const CLIDclassID ()
 Inquire class type. More...
 
- Static Public Member Functions inherited from RootHistCnv::RConverter
static long storageType ()
 Inquire storage type. More...
 
- Static Public Member Functions inherited from IInterface
static const InterfaceIDinterfaceID ()
 Return an instance of InterfaceID identifying the interface. More...
 
static const InterfaceIDinterfaceID ()
 Return an instance of InterfaceID identifying the interface. More...
 

Additional Inherited Members

- Public Types inherited from Converter
typedef Gaudi::PluginService::Factory< IConverter *, ISvcLocator * > Factory
 
typedef Gaudi::PluginService::Factory< IConverter *, ISvcLocator * > Factory
 
- Public Types inherited from implements1< IConverter >
typedef implements1 base_class
 Typedef to this class. More...
 
typedef implements1 base_class
 Typedef to this class. More...
 
typedef extend_interfaces1< IConverterextend_interfaces_base
 Typedef to the base of this class. More...
 
typedef extend_interfaces1< IConverterextend_interfaces_base
 Typedef to the base of this class. More...
 
typedef extend_interfaces_base::ext_iids interfaces
 MPL set of all the implemented interfaces. More...
 
typedef extend_interfaces_base::ext_iids interfaces
 MPL set of all the implemented interfaces. More...
 
- Public Types inherited from extend_interfaces1< IConverter >
typedef IConverter::iid::iids::type ext_iids
 MPL set of interfaces extended by this one. More...
 
typedef IConverter::iid::iids::type ext_iids
 MPL set of interfaces extended by this one. More...
 
- Public Types inherited from IConverter
enum  Status {
  INVALID_ADDRESS = IInterface::LAST_ERROR+1, INVALID_OBJECT, NO_MEMORY, BAD_STORAGE_TYPE,
  NO_SOURCE_OBJECT, ICONVERSIONSVC_LAST_ERROR, INVALID_ADDRESS = IInterface::LAST_ERROR+1, INVALID_OBJECT,
  NO_MEMORY, BAD_STORAGE_TYPE, NO_SOURCE_OBJECT, ICONVERSIONSVC_LAST_ERROR
}
 Status code. More...
 
enum  Status {
  INVALID_ADDRESS = IInterface::LAST_ERROR+1, INVALID_OBJECT, NO_MEMORY, BAD_STORAGE_TYPE,
  NO_SOURCE_OBJECT, ICONVERSIONSVC_LAST_ERROR, INVALID_ADDRESS = IInterface::LAST_ERROR+1, INVALID_OBJECT,
  NO_MEMORY, BAD_STORAGE_TYPE, NO_SOURCE_OBJECT, ICONVERSIONSVC_LAST_ERROR
}
 Status code. More...
 
- Public Types inherited from IInterface
enum  Status {
  SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR,
  SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR
}
 Return status. More...
 
enum  Status {
  SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR,
  SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR
}
 Return status. More...
 
typedef Gaudi::InterfaceId< IInterface, 0, 0 > iid
 Interface ID. More...
 
typedef mpl::set1< iidext_iids
 Extra interfaces. More...
 
typedef Gaudi::InterfaceId< IInterface, 0, 0 > iid
 Interface ID. More...
 
typedef mpl::set1< iidext_iids
 Extra interfaces. More...
 
- Protected Member Functions inherited from RootHistCnv::RConverter
 RConverter (const CLID &clid, ISvcLocator *svc)
 Standard constructor. More...
 
virtual ~RConverter ()
 Standard destructor. More...
 
virtual StatusCode readObject (IOpaqueAddress *pAddr, DataObject *&refpObj)
 Create the transient representation of an object. More...
 
virtual TObject * createPersistent (DataObject *pObj)
 Create the persistent representation of an object. More...
 
StatusCode createAddress (DataObject *pObject, TDirectory *pDir, TObject *pTObject, IOpaqueAddress *&refpAddr)
 Create address of the transient object according to the requested representation. More...
 
StatusCode createAddress (const std::string &rzdir, const CLID &clid, long id, TObject *pTobj, IOpaqueAddress *&refpAddress)
 
StatusCode createAddress (const std::string &rzdir, const CLID &clid, const std::string &title, TObject *pTobj, IOpaqueAddress *&refpAddress)
 
TDirectory * changeDirectory (DataObject *pObject)
 Switch to object directory (=Parent directory) More...
 
- Protected Member Functions inherited from Converter
virtual ~Converter ()
 Standard Destructor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const
 Retrieve pointer to service locator. More...
 
SmartIF< IMessageSvc > & msgSvc () const
 Retrieve pointer to message service. More...
 
SmartIF< IMessageSvc > & messageService () const
 
SmartIF< IDataManagerSvc > & dataManager () const
 Get Data Manager service. More...
 
virtual ~Converter ()
 Standard Destructor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const
 Retrieve pointer to service locator. More...
 
SmartIF< IMessageSvc > & msgSvc () const
 Retrieve pointer to message service. More...
 
SmartIF< IMessageSvc > & messageService () const
 
SmartIF< IDataManagerSvc > & dataManager () const
 Get Data Manager service. More...
 

Detailed Description

Create persistent and transient representations of data store directories.

Author
Charles Leggett

Definition at line 17 of file RDirectoryCnv.h.

Constructor & Destructor Documentation

RootHistCnv::RDirectoryCnv::RDirectoryCnv ( ISvcLocator svc)
inline

Standard constructor.

Definition at line 30 of file RDirectoryCnv.h.

30 : RConverter(CLID_NTupleDirectory, svc) {}
RConverter(const CLID &clid, ISvcLocator *svc)
Standard constructor.
Definition: RConverter.h:59
RootHistCnv::RDirectoryCnv::RDirectoryCnv ( ISvcLocator svc,
const CLID clid 
)
inline

Standard constructor.

Definition at line 32 of file RDirectoryCnv.h.

32 : RConverter(clid, svc){}
RConverter(const CLID &clid, ISvcLocator *svc)
Standard constructor.
Definition: RConverter.h:59
virtual RootHistCnv::RDirectoryCnv::~RDirectoryCnv ( )
inlinevirtual

Standard destructor.

Definition at line 34 of file RDirectoryCnv.h.

34 {}

Member Function Documentation

static const CLID& RootHistCnv::RDirectoryCnv::classID ( )
inlinestatic

Inquire class type.

Definition at line 28 of file RDirectoryCnv.h.

28 { return CLID_NTupleDirectory; }
StatusCode RootHistCnv::RDirectoryCnv::createObj ( IOpaqueAddress pAddr,
DataObject *&  refpObj 
)
virtual

Create the transient representation of an object.

Reimplemented from Converter.

Reimplemented in RootHistCnv::RFileCnv.

Definition at line 28 of file RDirectoryCnv.cpp.

31 {
32  refpObject = new NTuple::Directory();
33  return StatusCode::SUCCESS;
34 }
Small class representing an N tuple directory in the transient store.
Definition: NTuple.h:1065
StatusCode RootHistCnv::RDirectoryCnv::createRep ( DataObject pObj,
IOpaqueAddress *&  refpAddr 
)
virtual

Convert the transient object to the requested representation.

Reimplemented from RootHistCnv::RConverter.

Reimplemented in RootHistCnv::RFileCnv.

Definition at line 38 of file RDirectoryCnv.cpp.

41 {
42  const std::string& loc = pObject->registry()->identifier();
43  if ( createDirectory(loc).isSuccess() ) {
44  setDirectory(loc);
45  setDiskDirectory(loc);
46 // return createAddress(pObject, pObject->registry()->name(), refpAddress);
47  return createAddress(pObject, gDirectory, 0, refpAddress);
48  }
49  refpAddress = 0;
50  return StatusCode::FAILURE;
51 }
void setDirectory(const std::string &loc)
Definition: RConverter.cpp:120
StatusCode createDirectory(const std::string &loc)
Definition: RConverter.cpp:26
StatusCode createAddress(DataObject *pObject, TDirectory *pDir, TObject *pTObject, IOpaqueAddress *&refpAddr)
Create address of the transient object according to the requested representation. ...
Definition: RConverter.cpp:171
void setDiskDirectory(const std::string &loc)
Definition: RConverter.cpp:155
StatusCode RootHistCnv::RDirectoryCnv::fillObjRefs ( IOpaqueAddress pAddr,
DataObject refpObj 
)
virtual

Update the transient object from the other representation.

Reimplemented from Converter.

Definition at line 70 of file RDirectoryCnv.cpp.

70  {
71  MsgStream log(msgSvc(), "RDirectoryCnv");
72  IRegistry* pReg = pObj->registry();
73  std::string full = pReg->identifier();
74  const std::string& fname = pAddr->par()[0];
75 
76  TFile *tf;
77  findTFile(full,tf).ignore();
78 
79  // cd to TFile:
80  setDirectory(full);
81  TIter nextkey(gDirectory->GetListOfKeys());
82  while (TKey *key = (TKey*)nextkey()) {
83  IOpaqueAddress* pA = 0;
84  TObject *obj = key->ReadObj();
85  std::string title = obj->GetTitle();
86  std::string sid = obj->GetName();
87  std::string f2 = full + "/" + sid;
88  int idh = ::strtol(sid.c_str(),NULL,10);
89  // introduced by Grigori Rybkine
90  std::string clname = key->GetClassName();
91  std::string clnm = clname.substr(0,3);
92  TClass* isa = obj->IsA();
93  if (isa->InheritsFrom("TTree")) {
94  createAddress(full, CLID_ColumnWiseTuple, idh, obj, pA).ignore();
95  TTree* tree = (TTree*) obj;
96  tree->Print();
97  log << MSG::DEBUG << "Reg CWNT \"" << obj->GetTitle()
98  << "\" as " << f2 << endmsg;
99  title = "/" + sid;
100  } else if (isa->InheritsFrom("TDirectory")) {
101  createAddress(full,CLID_NTupleDirectory, title, obj, pA).ignore();
102  } else if ( isa == TProfile::Class() ) {
103  createAddress(full,CLID_ProfileH,idh,obj,pA).ignore();
104  title = sid;
105  } else if ( isa == TProfile2D::Class() ) {
106  createAddress(full,CLID_ProfileH2,idh,obj,pA).ignore();
107  title = sid;
108  } else if ( isa == TH1C::Class() ) {
109  createAddress(full,CLID_H1D,idh,obj,pA).ignore();
110  title = sid;
111  } else if ( isa == TH1S::Class() ) {
112  createAddress(full,CLID_H1D,idh,obj,pA).ignore();
113  title = sid;
114  } else if ( isa == TH1I::Class() ) {
115  createAddress(full,CLID_H1D,idh,obj,pA).ignore();
116  title = sid;
117  } else if ( isa == TH1F::Class() ) {
118  createAddress(full,CLID_H1D,idh,obj,pA).ignore();
119  title = sid;
120  } else if ( isa == TH1D::Class() ) {
121  createAddress(full,CLID_H1D,idh,obj,pA).ignore();
122  title = sid;
123  } else if ( isa == TH2C::Class() ) {
124  createAddress(full,CLID_H2D,idh,obj,pA).ignore();
125  title = sid;
126  } else if ( isa == TH2S::Class() ) {
127  createAddress(full,CLID_H2D,idh,obj,pA).ignore();
128  title = sid;
129  } else if ( isa == TH2I::Class() ) {
130  createAddress(full,CLID_H2D,idh,obj,pA).ignore();
131  title = sid;
132  } else if ( isa == TH2F::Class() ) {
133  createAddress(full,CLID_H2D,idh,obj,pA).ignore();
134  title = sid;
135  } else if ( isa == TH2D::Class() ) {
136  createAddress(full,CLID_H2D,idh,obj,pA).ignore();
137  title = sid;
138  } else if ( isa == TH3C::Class() ) {
139  createAddress(full,CLID_H3D,idh,obj,pA).ignore();
140  title = sid;
141  } else if ( isa == TH3S::Class() ) {
142  createAddress(full,CLID_H3D,idh,obj,pA).ignore();
143  title = sid;
144  } else if ( isa == TH3I::Class() ) {
145  createAddress(full,CLID_H3D,idh,obj,pA).ignore();
146  title = sid;
147  } else if ( isa == TH3F::Class() ) {
148  createAddress(full,CLID_H3D,idh,obj,pA).ignore();
149  title = sid;
150  } else if ( isa == TH3D::Class() ) {
151  createAddress(full,CLID_H3D,idh,obj,pA).ignore();
152  title = sid;
153  } else {
154  log << MSG::ERROR << "Encountered an unknown object with key: "
155  << obj->GetName() << " in ROOT file " << fname << endmsg;
156  return StatusCode::FAILURE;
157  }
158  if ( 0 != pA ) {
159  StatusCode sc = dataManager()->registerAddress(pReg, title, pA);
160  if ( !sc.isSuccess() ) {
161  log << MSG::ERROR << "Failed to register address for " << full << endmsg;
162  return sc;
163  }
164  log << MSG::VERBOSE << "Created address for " << clnm
165  << "'" << title << "' in " << full << endmsg;
166  }
167  }
168  return StatusCode::SUCCESS;
169 }
virtual const std::string * par() const =0
Retrieve String parameters.
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
void setDirectory(const std::string &loc)
Definition: RConverter.cpp:120
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
SmartIF< IMessageSvc > & msgSvc() const
Retrieve pointer to message service.
Definition: Converter.cpp:131
StatusCode findTFile(const std::string, TFile *&)
Definition: RConverter.cpp:331
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
SmartIF< IDataManagerSvc > & dataManager() const
Get Data Manager service.
Definition: Converter.cpp:99
virtual const id_type & identifier() const =0
Full identifier (or key)
virtual StatusCode registerAddress(const std::string &fullPath, IOpaqueAddress *pAddress)=0
Register object address with the data store.
Opaque address interface definition.
void ignore() const
Definition: StatusCode.h:107
StatusCode createAddress(DataObject *pObject, TDirectory *pDir, TObject *pTObject, IOpaqueAddress *&refpAddr)
Create address of the transient object according to the requested representation. ...
Definition: RConverter.cpp:171
StatusCode RootHistCnv::RDirectoryCnv::updateRep ( IOpaqueAddress pAddr,
DataObject pObject 
)
virtual

Convert the transient object to the requested representation.

Reimplemented from Converter.

Reimplemented in RootHistCnv::RFileCnv.

Definition at line 55 of file RDirectoryCnv.cpp.

58 {
59  const std::string& loc = pObject->registry()->identifier();
60  if ( createDirectory(loc).isSuccess() ) {
61  setDirectory(loc);
62  return StatusCode::SUCCESS;
63  }
64  return StatusCode::FAILURE;
65 }
void setDirectory(const std::string &loc)
Definition: RConverter.cpp:120
StatusCode createDirectory(const std::string &loc)
Definition: RConverter.cpp:26
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:69
virtual const id_type & identifier() const =0
Full identifier (or key)

The documentation for this class was generated from the following files: