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

Additional Inherited Members

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

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 39 of file RootDirectoryCnv.h.

Constructor & Destructor Documentation

◆ RootDirectoryCnv()

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 40 of file RootDirectoryCnv.cpp.

41 : RootStatCnv( typ, clid, svc, mgr ) {}
RootStatCnv(long typ, const CLID &clid, ISvcLocator *svc, RootCnvSvc *mgr)
Initializing Constructor.

Member Function Documentation

◆ createObj()

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 44 of file RootDirectoryCnv.cpp.

44 {
45 refpObj = new NTuple::Directory();
47}
constexpr static const auto SUCCESS
Definition StatusCode.h:99

◆ createRep()

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 50 of file RootDirectoryCnv.cpp.

50 {
51 string dsc;
52 if ( objType() == CLID_StatisticsDirectory ) {
53 dsc = "Directory containing statistics results.";
54 } else if ( objType() == CLID_StatisticsFile ) {
55 dsc = "File containing statistics results.";
56 } else {
58 }
59 string ident = containerName( pObj->registry() );
60 string path = fileName( pObj->registry() );
61 return saveDescription( path, ident, dsc, ident, objType() );
62}
const CLID & objType() const override
Retrieve the class type of objects the converter produces.
Definition Converter.cpp:22
IRegistry * registry() const
Get pointer to Registry.
Definition DataObject.h:79
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 fileName(IRegistry *pReg) const
Retrieve the name of the file a given object is placed into.
virtual const std::string containerName(IRegistry *pDir) const
Retrieve the name of the container a given object is placed into.
constexpr static const auto FAILURE
Definition StatusCode.h:100
GAUDI_API std::string path(const AIDA::IBaseHistogram *aida)
get the path in THS for AIDA histogram

◆ fillObjRefs()

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 65 of file RootDirectoryCnv.cpp.

65 {
66 return updateObjRefs( pAddr, pObj );
67}
StatusCode updateObjRefs(IOpaqueAddress *pAddr, DataObject *pObj) override
Converter overrides: Update the references of an updated transient object.

◆ fillRepRefs()

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 167 of file RootDirectoryCnv.cpp.

167 {
168 return StatusCode::SUCCESS;
169}

◆ updateObj()

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 152 of file RootDirectoryCnv.cpp.

152 {
153 return StatusCode::SUCCESS;
154}

◆ updateObjRefs()

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 70 of file RootDirectoryCnv.cpp.

70 {
71 typedef vector<RootNTupleDescriptor*> REFS;
72 REFS refs;
73 StatusCode status = StatusCode::FAILURE;
74 if ( pAddr ) {
75 IRegistry* pReg = pAddr->registry();
76 if ( pReg ) {
77 typedef vector<IRegistry*> Leaves;
78 string ident = pReg->identifier();
79 string fname = fileName( pReg );
80 string cntName = containerName( pReg );
81 RootDataConnection* con = nullptr;
82 Leaves leaves;
83 status = m_dbMgr->connectDatabase( fname, IDataConnection::READ, &con );
84 if ( status.isSuccess() ) {
85 TBranch* b = con->getBranch( "##Descriptors", "GaudiStatisticsDescription" );
86 if ( b ) {
87 for ( Long64_t n = b->GetEntries(), i = 0; i < n; ++i ) {
88 RootNTupleDescriptor* ref = nullptr;
89 b->SetAddress( &ref );
90 int nb = b->GetEntry( i );
91 if ( nb > 1 ) {
92 string s = ref->container.substr( 0, cntName.length() );
93 log() << MSG::VERBOSE << "Read description:" << ref->container << " " << ident << " " << cntName
94 << endmsg;
95 if ( s == cntName ) {
96 if ( ref->container.length() >= cntName.length() + 1 ) {
97 if ( ref->container.find( '/', cntName.length() + 1 ) == string::npos ) {
98 refs.push_back( ref );
99 continue;
100 }
101 }
102 }
103 }
104 delete ref;
105 }
106 }
107 log() << MSG::DEBUG << "Got " << refs.size() << " tuple connection(s)....." << endmsg;
108 status = m_dataMgr->objectLeaves( pObject, leaves );
109 if ( status.isSuccess() ) {
110 for ( auto& ref : refs ) {
111 if ( ref ) {
112 bool need_to_add =
113 std::none_of( std::begin( leaves ), std::end( leaves ),
114 [&]( Leaves::const_reference j ) { return containerName( j ) == ref->container; } );
115 if ( need_to_add ) {
116 IOpaqueAddress* pA = nullptr;
117 if ( ref->clid == CLID_StatisticsDirectory || ref->clid == CLID_StatisticsFile ||
118 ref->clid == CLID_RowWiseTuple || ref->clid == CLID_ColumnWiseTuple ) {
119 string spar[] = { fname, ref->container };
120 unsigned long ipar[] = { ~0x0UL, ~0x0UL };
121 status = m_dbMgr->createAddress( repSvcType(), ref->clid, spar, ipar, pA );
122 }
123 if ( status.isSuccess() ) {
124 string top = topLevel( pReg );
125 string leaf_name = top + ref->container.substr( 7 );
126 status = m_dataMgr->registerAddress( leaf_name, pA );
127 if ( status.isSuccess() ) {
128 log() << MSG::DEBUG << "Created address for " << leaf_name << " of type " << ref->clid << endmsg;
129 continue;
130 }
131 makeError( "Failed to register leaves to directory:" + ident, false ).ignore();
132 break;
133 }
134 makeError( "Failed to create leave address to directory:" + ident, false ).ignore();
135 break;
136 }
137 }
138 makeError( "Failed to add leaves to directory:" + ident, false ).ignore();
139 break;
140 }
141 }
142 } else {
143 return makeError( "Failed to access required tuple data description.", false );
144 }
145 }
146 }
147 for ( auto& ref : refs ) delete ref;
148 return status;
149}
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
RootCnvSvc * m_dbMgr
Conversion service needed for proper operation to forward requests.
long repSvcType() const override
Retrieve the class type of the data store the converter uses.
TBranch * getBranch(std::string_view section, std::string_view branch_name)
Access data branch by name: Get existing branch in read only mode.
StatusCode makeError(const std::string &msg, bool throw_exception=false) const
Helper method to issue error messages.
MsgStream & log() const
Helper to use mesage logger.
Definition RootStatCnv.h:47
SmartIF< IDataManagerSvc > m_dataMgr
Reference to data manager service to manipulate the TES.
Definition RootStatCnv.h:42
virtual const std::string topLevel(IRegistry *pReg) const
Retrieve the full path of the file a given object is placed into.
virtual IRegistry * registry() const =0
Update branch name.
virtual const id_type & identifier() const =0
Full identifier (or key)
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
Definition StatusCode.h:139
bool isSuccess() const
Definition StatusCode.h:314
@ DEBUG
Definition IMessageSvc.h:22
@ VERBOSE
Definition IMessageSvc.h:22

◆ updateRep()

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 157 of file RootDirectoryCnv.cpp.

157 {
158 return StatusCode::SUCCESS;
159}

◆ updateRepRefs()

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 162 of file RootDirectoryCnv.cpp.

162 {
163 return StatusCode::SUCCESS;
164}

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