The Gaudi Framework  v41r0 (bdbe7744)
Loading...
Searching...
No Matches
Gaudi::Hive::FetchLeavesFromFile Class Referencefinal
Inheritance diagram for Gaudi::Hive::FetchLeavesFromFile:
Collaboration diagram for Gaudi::Hive::FetchLeavesFromFile:

Public Member Functions

 FetchLeavesFromFile (const std::string &name, ISvcLocator *pSvcLocator)
StatusCode initialize () override
IDataStoreLeaves::LeavesList operator() () const override
StatusCode finalize () override
IDataStoreLeaves::LeavesList i_collectLeaves () const

Private Attributes

Gaudi::Property< std::string > m_dataSvcName
Gaudi::Property< std::string > m_rootNode { this, "Root", "", "Path to the element from which to start the scan" }
SmartIF< IDataManagerSvc > m_dataMgrSvc

Detailed Description

Definition at line 23 of file FetchLeavesFromFile.cpp.

Constructor & Destructor Documentation

◆ FetchLeavesFromFile()

Gaudi::Hive::FetchLeavesFromFile::FetchLeavesFromFile ( const std::string & name,
ISvcLocator * pSvcLocator )
inline

Definition at line 25 of file FetchLeavesFromFile.cpp.

26 : Producer( name, pSvcLocator, KeyValue( "InputFileLeavesLocation", "/Event/InputFileLeaves" ) ) {}
details::Producer< Signature, Traits_, details::isLegacy< Traits_ > > Producer
Definition Producer.h:37

Member Function Documentation

◆ finalize()

StatusCode Gaudi::Hive::FetchLeavesFromFile::finalize ( )
inlineoverride

Definition at line 32 of file FetchLeavesFromFile.cpp.

32 {
33 m_dataMgrSvc.reset();
34 return Producer::finalize();
35 }
SmartIF< IDataManagerSvc > m_dataMgrSvc

◆ i_collectLeaves()

IDataStoreLeaves::LeavesList Gaudi::Hive::FetchLeavesFromFile::i_collectLeaves ( ) const

Definition at line 63 of file FetchLeavesFromFile.cpp.

63 {
64 // we have to make sure that the node we start the traversal from is loaded
65 {
66 DataObject* obj = nullptr;
67 evtSvc()
68 ->retrieveObject( m_rootNode, obj )
69 .orThrow( std::format( "failed to retrieve {} from {}", m_rootNode.value(), m_dataSvcName.value() ),
70 name() );
71 }
72 // result
74 // used to test for nodes with same origin
75 std::string origin;
76 // we do not get info from exceptions in the data store agent, so we record the exception message, if any
77 std::string failure_msg;
79 ->traverseSubTree( m_rootNode,
80 [&]( IRegistry* reg, int ) {
81 if ( reg->address() && reg->dataSvc() ) { // we consider only objects that come from a
82 // file
83 if ( origin.empty() ) {
84 // this is the first node we encounter, so we record where it comes from
85 origin = reg->address()->par()[0];
86 }
87 // if the current object comes from the same file as the first entry...
88 if ( origin == reg->address()->par()[0] ) {
89 // ... make sure the object has been loaded...
90 DataObject* obj = reg->object();
91 if ( !obj )
92 reg->dataSvc()
93 ->retrieveObject( reg->identifier(), obj )
94 .orElse( [&]() {
95 failure_msg = std::format( "failed to retrieve {} from {}",
96 reg->identifier(), m_dataSvcName.value() );
97 // we do not really care about the exception we throw because traverseSubTree
98 // will just use it to abort the traversal
99 throw GaudiException( failure_msg, name(), StatusCode::FAILURE );
100 } )
101 .ignore();
102 // ... and add it to the list
103 all_leaves.push_back( obj );
104 if ( msgLevel( MSG::VERBOSE ) )
105 verbose() << "::i_collectLeaves added " << reg->identifier() << endmsg;
106 return true; // we can continue the recursion
107 }
108 }
109 // if we reach this point the object was not interesting, so no need to recurse further
110 return false;
111 } )
112 .orThrow( failure_msg, name() );
113 return all_leaves;
114 }
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
Gaudi::Property< std::string > m_dataSvcName
Gaudi::Property< std::string > m_rootNode
virtual StatusCode retrieveObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject)=0
Retrieve object identified by its directory entry.
std::vector< DataObject * > LeavesList
Returned type.
virtual const std::string * par() const =0
Retrieve String parameters.
virtual const id_type & identifier() const =0
Full identifier (or key).
virtual DataObject * object() const =0
Retrieve object behind the link.
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
virtual IDataProviderSvc * dataSvc() const =0
Retrieve pointer to Transient Store.
StatusCode orElse(F &&f, ARGS &&... args) const
Chain code blocks making the execution conditional a failure result.
Definition StatusCode.h:173
constexpr static const auto FAILURE
Definition StatusCode.h:100
@ VERBOSE
Definition IMessageSvc.h:22

◆ initialize()

StatusCode Gaudi::Hive::FetchLeavesFromFile::initialize ( )
override

Definition at line 52 of file FetchLeavesFromFile.cpp.

52 {
53 return Producer::initialize().andThen( [&]() {
54 m_dataMgrSvc = serviceLocator()->service( m_dataSvcName );
55 if ( !m_dataMgrSvc ) {
56 error() << "Cannot get IDataManagerSvc " << m_dataSvcName << endmsg;
58 }
60 } );
61 }
constexpr static const auto SUCCESS
Definition StatusCode.h:99

◆ operator()()

IDataStoreLeaves::LeavesList Gaudi::Hive::FetchLeavesFromFile::operator() ( ) const
inlineoverride

Definition at line 30 of file FetchLeavesFromFile.cpp.

30{ return i_collectLeaves(); }
IDataStoreLeaves::LeavesList i_collectLeaves() const

Member Data Documentation

◆ m_dataMgrSvc

SmartIF<IDataManagerSvc> Gaudi::Hive::FetchLeavesFromFile::m_dataMgrSvc
private

Definition at line 47 of file FetchLeavesFromFile.cpp.

◆ m_dataSvcName

Gaudi::Property<std::string> Gaudi::Hive::FetchLeavesFromFile::m_dataSvcName
private
Initial value:
{ this, "DataService", "EventDataSvc",
"Name of the data service to use" }

Definition at line 41 of file FetchLeavesFromFile.cpp.

41 { this, "DataService", "EventDataSvc",
42 "Name of the data service to use" };

◆ m_rootNode

Gaudi::Property<std::string> Gaudi::Hive::FetchLeavesFromFile::m_rootNode { this, "Root", "", "Path to the element from which to start the scan" }
private

Definition at line 44 of file FetchLeavesFromFile.cpp.

44{ this, "Root", "", "Path to the element from which to start the scan" };

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