The Gaudi Framework  v30r3 (a5ef0a68)
Gaudi::RootDirectoryCnv Class Reference

Description: NTuple directory converter class definition Definition of the converter to manage the directories in an database representing N-Tuples. More...

#include <src/RootDirectoryCnv.h>

Inheritance diagram for Gaudi::RootDirectoryCnv:
Collaboration diagram for Gaudi::RootDirectoryCnv:

Public Member Functions

 RootDirectoryCnv (long typ, const CLID &clid, ISvcLocator *svc, RootCnvSvc *mgr)
 Initializing Constructor. More...
 
StatusCode createObj (IOpaqueAddress *pAddr, DataObject *&refpObj) override
 Converter overrides: Create transient object from persistent data. More...
 
StatusCode fillObjRefs (IOpaqueAddress *pAddr, DataObject *pObj) override
 Converter overrides: Resolve the references of the transient object. More...
 
StatusCode updateObj (IOpaqueAddress *pAddr, DataObject *pObj) override
 Converter overrides: Update transient object from persistent data. More...
 
StatusCode updateObjRefs (IOpaqueAddress *pAddr, DataObject *pObj) override
 Converter overrides: Update the references of an updated transient object. More...
 
StatusCode createRep (DataObject *pObj, IOpaqueAddress *&refpAddr) override
 Converter overrides: Convert the transient object to the requested representation. More...
 
StatusCode fillRepRefs (IOpaqueAddress *pAddr, DataObject *pObj) override
 Converter overrides: Fill references of persistent object representation. More...
 
StatusCode updateRep (IOpaqueAddress *pAddr, DataObject *pObj) override
 Converter overrides: Update persistent object representation. More...
 
StatusCode updateRepRefs (IOpaqueAddress *pAddr, DataObject *pObj) override
 Converter overrides: Update references of persistent object representation. More...
 
- Public Member Functions inherited from Gaudi::RootStatCnv
 RootStatCnv (long typ, const CLID &clid, ISvcLocator *svc, RootCnvSvc *mgr)
 Initializing Constructor. More...
 
- Public Member Functions inherited from Gaudi::RootConverter
 RootConverter (long typ, const CLID &clid, ISvcLocator *svc, RootCnvSvc *mgr)
 Initializing Constructor. More...
 
long repSvcType () const override
 Retrieve the class type of the data store the converter uses. More...
 
StatusCode createObj (IOpaqueAddress *pAddr, DataObject *&refpObj) override
 Converter overrides: Create transient object from persistent data. More...
 
StatusCode fillObjRefs (IOpaqueAddress *pAddr, DataObject *pObj) override
 Resolve the references of the created transient object. More...
 
StatusCode createRep (DataObject *pObj, IOpaqueAddress *&refpAddr) override
 Converter overrides: Convert the transient object to the requested representation. More...
 
StatusCode fillRepRefs (IOpaqueAddress *pAddr, DataObject *pObj) override
 Resolve the references of the created transient object. More...
 
- Public Member Functions inherited from Converter
StatusCode initialize () override
 Initialize the converter. More...
 
StatusCode finalize () override
 Initialize the converter. More...
 
StatusCode setDataProvider (IDataProviderSvc *svc) override
 Set Data provider service. More...
 
SmartIF< IDataProviderSvc > & dataProvider () const override
 Get Data provider service. More...
 
StatusCode setConversionSvc (IConversionSvc *svc) override
 Set conversion service the converter is connected to. More...
 
SmartIF< IConversionSvc > & conversionSvc () const override
 Get conversion service the converter is connected to. More...
 
StatusCode setAddressCreator (IAddressCreator *creator) override
 Set address creator facility. More...
 
SmartIF< IAddressCreator > & addressCreator () const override
 Retrieve address creator facility. More...
 
const CLIDobjType () const override
 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...
 
StatusCode createObj (IOpaqueAddress *pAddress, DataObject *&refpObject) override
 Create the transient representation of an object. More...
 
StatusCode fillObjRefs (IOpaqueAddress *pAddress, DataObject *pObject) override
 Resolve the references of the created transient object. More...
 
StatusCode updateObj (IOpaqueAddress *pAddress, DataObject *refpObject) override
 Update the transient object from the other representation. More...
 
StatusCode updateObjRefs (IOpaqueAddress *pAddress, DataObject *pObject) override
 Update the references of an updated transient object. More...
 
StatusCode createRep (DataObject *pObject, IOpaqueAddress *&refpAddress) override
 Convert the transient object to the requested representation. More...
 
StatusCode fillRepRefs (IOpaqueAddress *pAddress, DataObject *pObject) override
 Resolve the references of the converted object. More...
 
StatusCode updateRep (IOpaqueAddress *pAddress, DataObject *pObject) override
 Update the converted representation of a transient object. More...
 
StatusCode updateRepRefs (IOpaqueAddress *pAddress, DataObject *pObject) override
 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 implements< IConverter >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::stringgetInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 implements ()=default
 Default constructor. More...
 
 implements (const implements &)
 Copy constructor (zero the reference count) More...
 
implementsoperator= (const implements &)
 Assignment operator (do not touch the reference count). More...
 
unsigned long addRef () override
 Reference Interface instance. More...
 
unsigned long release () override
 Release Interface instance. More...
 
unsigned long refCount () const override
 Current reference count. More...
 

Additional Inherited Members

- Public Types inherited from Converter
using Factory = Gaudi::PluginService::Factory< IConverter *(ISvcLocator *)>
 
- Public Types inherited from implements< IConverter >
using base_class = implements< Interfaces... >
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces... >
 Typedef to the base of this class. More...
 
using iids = typename extend_interfaces_base::ext_iids
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type
 take union of the ext_iids of all Interfaces... More...
 
- Protected Member Functions inherited from Gaudi::RootStatCnv
MsgStreamlog () const
 Helper to use mesage logger. More...
 
StatusCode initialize () override
 Initialize converter object. More...
 
StatusCode finalize () override
 Finalize converter object. More...
 
virtual const std::string containerName (IRegistry *pDir) const
 Retrieve the name of the container a given object is placed into. More...
 
virtual const std::string fileName (IRegistry *pReg) const
 Retrieve the name of the file a given object is placed into. More...
 
virtual const std::string topLevel (IRegistry *pReg) const
 Retrieve the full path of the file a given object is placed into. More...
 
StatusCode makeError (const std::string &msg, bool throw_exception=false) const
 Helper method to issue error messages. More...
 
StatusCode saveDescription (const std::string &path, const std::string &ident, const std::string &desc, const std::string &opt, const CLID &clid)
 Save statistics object description. More...
 
- Protected Member Functions inherited from Converter
SmartIF< ISvcLocator > & serviceLocator () const
 Retrieve pointer to service locator. More...
 
SmartIF< IMessageSvc > & msgSvc () const
 Retrieve pointer to message service. More...
 
SmartIF< IDataManagerSvc > & dataManager () const
 Get Data Manager service. More...
 
- Protected Attributes inherited from Gaudi::RootStatCnv
SmartIF< IDataManagerSvcm_dataMgr
 Reference to data manager service to manipulate the TES. More...
 
std::unique_ptr< MsgStreamm_log
 Reference to logger object. More...
 
- Protected Attributes inherited from Gaudi::RootConverter
RootCnvSvcm_dbMgr
 Conversion service needed for proper operation to forward requests. More...
 
- Protected Attributes inherited from implements< IConverter >
std::atomic_ulong m_refCount
 Reference counter. More...
 

Detailed Description

Description: NTuple directory converter class definition Definition of the converter to manage the directories in an database representing N-Tuples.

Author
M.Frank
Version
1.0

Definition at line 31 of file RootDirectoryCnv.h.

Constructor & Destructor Documentation

RootDirectoryCnv::RootDirectoryCnv ( long  typ,
const CLID clid,
ISvcLocator svc,
RootCnvSvc mgr 
)

Initializing Constructor.

Parameters
typ[IN] Concrete storage type of the converter
clid[IN] Class identifier of the object
svc[IN] Pointer to service locator object
Returns
Reference to RootBaseCnv object

Definition at line 30 of file RootDirectoryCnv.cpp.

31  : RootStatCnv( typ, clid, svc, mgr )
32 {
33 }
RootStatCnv(long typ, const CLID &clid, ISvcLocator *svc, RootCnvSvc *mgr)
Initializing Constructor.
Definition: RootStatCnv.cpp:24

Member Function Documentation

StatusCode RootDirectoryCnv::createObj ( IOpaqueAddress pAddr,
DataObject *&  refpObj 
)
override

Converter overrides: Create transient object from persistent data.

Parameters
pAddr[IN] Pointer to object address.
refpObj[OUT] Location to pointer to store data object
Returns
Status code indicating success or failure.

Definition at line 36 of file RootDirectoryCnv.cpp.

37 {
38  refpObj = new NTuple::Directory();
39  return StatusCode::SUCCESS;
40 }
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
Small class representing an N tuple directory in the transient store.
Definition: NTuple.h:978
StatusCode RootDirectoryCnv::createRep ( DataObject pObj,
IOpaqueAddress *&  refpAddr 
)
override

Converter overrides: Convert the transient object to the requested representation.

Parameters
pObj[IN] Pointer to data object
refpAddr[OUT] Location to store pointer to object address.
Returns
Status code indicating success or failure.

Definition at line 43 of file RootDirectoryCnv.cpp.

44 {
45  string dsc;
46  if ( objType() == CLID_StatisticsDirectory ) {
47  dsc = "Directory containing statistics results.";
48  } else if ( objType() == CLID_StatisticsFile ) {
49  dsc = "File containing statistics results.";
50  } else {
51  return StatusCode::FAILURE;
52  }
53  string ident = containerName( pObj->registry() );
54  string path = fileName( pObj->registry() );
55  return saveDescription( path, ident, dsc, ident, objType() );
56 }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
const CLID & objType() const override
Retrieve the class type of objects the converter produces.
Definition: Converter.cpp:13
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:73
virtual const std::string fileName(IRegistry *pReg) const
Retrieve the name of the file a given object is placed into.
Definition: RootStatCnv.cpp:70
StatusCode saveDescription(const std::string &path, const std::string &ident, const std::string &desc, const std::string &opt, const CLID &clid)
Save statistics object description.
virtual const std::string containerName(IRegistry *pDir) const
Retrieve the name of the container a given object is placed into.
Definition: RootStatCnv.cpp:52
StatusCode RootDirectoryCnv::fillObjRefs ( IOpaqueAddress pAddr,
DataObject pObj 
)
override

Converter overrides: Resolve the references of the transient object.

Parameters
pAddr[IN] Pointer to object address.
pObj[IN] Pointer to data object
Returns
Status code indicating success or failure.

Definition at line 59 of file RootDirectoryCnv.cpp.

60 {
61  return updateObjRefs( pAddr, pObj );
62 }
StatusCode updateObjRefs(IOpaqueAddress *pAddr, DataObject *pObj) override
Converter overrides: Update the references of an updated transient object.
StatusCode RootDirectoryCnv::fillRepRefs ( IOpaqueAddress pAddr,
DataObject pObj 
)
override

Converter overrides: Fill references of persistent object representation.

Parameters
pObj[IN] Pointer to data object
refpAddr[OUT] Location to store pointer to object address.
Returns
Status code indicating success or failure.

Definition at line 166 of file RootDirectoryCnv.cpp.

167 {
168  return StatusCode::SUCCESS;
169 }
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
StatusCode RootDirectoryCnv::updateObj ( IOpaqueAddress pAddr,
DataObject pObj 
)
override

Converter overrides: Update transient object from persistent data.

Parameters
pAddr[IN] Pointer to object address.
pObj[IN] Pointer to data object
Returns
Status code indicating success or failure.

Definition at line 148 of file RootDirectoryCnv.cpp.

149 {
150  return StatusCode::SUCCESS;
151 }
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
StatusCode RootDirectoryCnv::updateObjRefs ( IOpaqueAddress pAddr,
DataObject pObj 
)
override

Converter overrides: Update the references of an updated transient object.

Parameters
pAddr[IN] Pointer to object address.
pObj[IN] Pointer to data object
Returns
Status code indicating success or failure.

Definition at line 65 of file RootDirectoryCnv.cpp.

66 {
67  typedef vector<RootNTupleDescriptor*> REFS;
68  REFS refs;
69  StatusCode status = StatusCode( StatusCode::FAILURE, true );
70  if ( pAddr ) {
71  IRegistry* pReg = pAddr->registry();
72  if ( pReg ) {
73  typedef vector<IRegistry*> Leaves;
74  string ident = pReg->identifier();
75  string fname = fileName( pReg );
76  string cntName = containerName( pReg );
77  RootDataConnection* con = nullptr;
78  Leaves leaves;
79  status = m_dbMgr->connectDatabase( fname, IDataConnection::READ, &con );
80  if ( status.isSuccess() ) {
81  TBranch* b = con->getBranch( "##Descriptors", "GaudiStatisticsDescription" );
82  if ( b ) {
83  for ( Long64_t n = b->GetEntries(), i = 0; i < n; ++i ) {
84  RootNTupleDescriptor* ref = nullptr;
85  b->SetAddress( &ref );
86  int nb = b->GetEntry( i );
87  if ( nb > 1 ) {
88  string s = ref->container.substr( 0, cntName.length() );
89  log() << MSG::VERBOSE << "Read description:" << ref->container << " " << ident << " " << cntName
90  << endmsg;
91  if ( s == cntName ) {
92  if ( ref->container.length() >= cntName.length() + 1 ) {
93  if ( ref->container.find( '/', cntName.length() + 1 ) == string::npos ) {
94  refs.push_back( ref );
95  continue;
96  }
97  }
98  }
99  }
100  delete ref;
101  }
102  }
103  log() << MSG::DEBUG << "Got " << refs.size() << " tuple connection(s)....." << endmsg;
104  status = m_dataMgr->objectLeaves( pObject, leaves );
105  if ( status.isSuccess() ) {
106  for ( auto& ref : refs ) {
107  if ( ref ) {
108  bool need_to_add =
109  std::none_of( std::begin( leaves ), std::end( leaves ),
110  [&]( Leaves::const_reference j ) { return containerName( j ) == ref->container; } );
111  if ( need_to_add ) {
112  IOpaqueAddress* pA = nullptr;
113  if ( ref->clid == CLID_StatisticsDirectory || ref->clid == CLID_StatisticsFile ||
114  ref->clid == CLID_RowWiseTuple || ref->clid == CLID_ColumnWiseTuple ) {
115  string spar[] = {fname, ref->container};
116  unsigned long ipar[] = {~0x0UL, ~0x0UL};
117  status = m_dbMgr->createAddress( repSvcType(), ref->clid, spar, ipar, pA );
118  }
119  if ( status.isSuccess() ) {
120  string top = topLevel( pReg );
121  string leaf_name = top + ref->container.substr( 7 );
122  status = m_dataMgr->registerAddress( leaf_name, pA );
123  if ( status.isSuccess() ) {
124  log() << MSG::DEBUG << "Created address for " << leaf_name << " of type " << ref->clid << endmsg;
125  continue;
126  }
127  makeError( "Failed to register leaves to directory:" + ident, false ).ignore();
128  break;
129  }
130  makeError( "Failed to create leave address to directory:" + ident, false ).ignore();
131  break;
132  }
133  }
134  makeError( "Failed to add leaves to directory:" + ident, false ).ignore();
135  break;
136  }
137  }
138  } else {
139  return makeError( "Failed to access required tuple data description.", false );
140  }
141  }
142  }
143  for ( auto& ref : refs ) delete ref;
144  return status;
145 }
MsgStream & log() const
Helper to use mesage logger.
Definition: RootStatCnv.h:40
constexpr static const auto FAILURE
Definition: StatusCode.h:88
virtual StatusCode objectLeaves(const DataObject *pObject, std::vector< IRegistry * > &refLeaves)=0
Explore the object store: retrieve all leaves attached to the object The object is identified by its ...
virtual const std::string topLevel(IRegistry *pReg) const
Retrieve the full path of the file a given object is placed into.
Definition: RootStatCnv.cpp:85
StatusCode createAddress(long svc_type, const CLID &clid, const std::string *par, const unsigned long *ip, IOpaqueAddress *&refpAddress) override
IAddressCreator implementation: Address creation.
Definition: RootCnvSvc.cpp:370
bool isSuccess() const
Definition: StatusCode.h:287
RootCnvSvc * m_dbMgr
Conversion service needed for proper operation to forward requests.
Definition: RootConverter.h:37
virtual IRegistry * registry() const =0
Update branch name.
StatusCode makeError(const std::string &msg, bool throw_exception=false) const
Helper method to issue error messages.
T end(T...args)
StatusCode connectDatabase(const std::string &dataset, int mode, RootDataConnection **con)
Connect the output file to the service with open mode.
Definition: RootCnvSvc.cpp:210
SmartIF< IDataManagerSvc > m_dataMgr
Reference to data manager service to manipulate the TES.
Definition: RootStatCnv.h:35
long repSvcType() const override
Retrieve the class type of the data store the converter uses.
Definition: RootConverter.h:53
virtual const id_type & identifier() const =0
Full identifier (or key)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
virtual const std::string fileName(IRegistry *pReg) const
Retrieve the name of the file a given object is placed into.
Definition: RootStatCnv.cpp:70
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
TBranch * getBranch(boost::string_ref section, boost::string_ref branch_name)
Access data branch by name: Get existing branch in read only mode.
T find(T...args)
T length(T...args)
STL class.
T begin(T...args)
T none_of(T...args)
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:165
std::string container
Identifier of description.
Definition: RootRefs.h:85
virtual StatusCode registerAddress(boost::string_ref fullPath, IOpaqueAddress *pAddress)=0
Register object address with the data store.
string s
Definition: gaudirun.py:253
T substr(T...args)
unsigned long clid
Class ID of the described object.
Definition: RootRefs.h:87
Opaque address interface definition.
virtual const std::string containerName(IRegistry *pDir) const
Retrieve the name of the container a given object is placed into.
Definition: RootStatCnv.cpp:52
Concrete implementation of the IDataConnection interface to access ROOT files.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
StatusCode RootDirectoryCnv::updateRep ( IOpaqueAddress pAddr,
DataObject pObj 
)
override

Converter overrides: Update persistent object representation.

Parameters
pObj[IN] Pointer to data object
refpAddr[OUT] Location to store pointer to object address.
Returns
Status code indicating success or failure.

Definition at line 154 of file RootDirectoryCnv.cpp.

155 {
156  return StatusCode::SUCCESS;
157 }
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
StatusCode RootDirectoryCnv::updateRepRefs ( IOpaqueAddress pAddr,
DataObject pObj 
)
override

Converter overrides: Update references of persistent object representation.

Parameters
pObj[IN] Pointer to data object
refpAddr[OUT] Location to store pointer to object address.
Returns
Status code indicating success or failure.

Definition at line 160 of file RootDirectoryCnv.cpp.

161 {
162  return StatusCode::SUCCESS;
163 }
constexpr static const auto SUCCESS
Definition: StatusCode.h:87

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