| The Gaudi Framework v32r1 (f65d50dc)

FetchDataFromFile.cpp
Go to the documentation of this file.
1 #include "GaudiAlg/GaudiAlgorithm.h"
2
3 namespace Gaudi {
4 namespace Hive {
5 class FetchDataFromFile final : public ::Algorithm {
6 public:
7 FetchDataFromFile( const std::string& name, ISvcLocator* pSvcLocator ) : Algorithm( name, pSvcLocator ) {
8 // make sure this algorithm is seen as reentrant by Gaudi
9 this->setProperty( "Cardinality", 0 );
10 }
11 StatusCode initialize() override {
12 StatusCode sc = Algorithm::initialize();
13 if ( sc ) {
14 // this is a hack to reuse the automatic dependencies declaration
15 for ( auto k : m_dataKeys ) { addDependency( k, Gaudi::DataHandle::Writer ); }
16 }
17 return sc;
18 }
19 StatusCode start() override {
20 StatusCode sc = Algorithm::start();
21 if ( sc ) {
22 for ( const auto& k : outputDataObjs() ) {
23 if ( UNLIKELY( msgLevel( MSG::DEBUG ) ) ) debug() << "adding data key " << k << endmsg;
24 evtSvc()->addPreLoadItem( k.key() );
25 }
26 }
27 return sc;
28 }
29 StatusCode execute() override { return evtSvc()->preLoad(); }
30
31 private:
32 Gaudi::Property<std::vector<std::string>> m_dataKeys{
33 this, "DataKeys", {}, "list of objects to be read from file"};
34 };
35 } // namespace Hive
36 } // namespace Gaudi
37 using Gaudi::Hive::FetchDataFromFile;
38 DECLARE_COMPONENT( FetchDataFromFile )
UNLIKELY
#define UNLIKELY(x)
Definition: Kernel.h:96
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:352
PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >::setProperty
StatusCode setProperty(const Gaudi::Details::PropertyBase &p) override
set the property form another property
Definition: PropertyHolder.h:145
IDataProviderSvc::addPreLoadItem
virtual StatusCode addPreLoadItem(const DataStoreItem &item)=0
Add an item to the preload list.
Gaudi::Algorithm::start
StatusCode start() override
the default (empty) implementation of IStateful::start() method
Definition: Algorithm.h:182
GaudiAlgorithm.h
Header file for class GaudiAlgorithm.
MSG::DEBUG
Definition: IMessageSvc.h:15
IDataProviderSvc::preLoad
virtual StatusCode preLoad()=0
Load all preload items of the list.
Gaudi::Algorithm::evtSvc
SmartIF< IDataProviderSvc > & evtSvc() const
shortcut for method eventSvc
Definition: Algorithm.h:265
Gaudi::Hive::FetchDataFromFile::m_dataKeys
Gaudi::Property< std::vector< std::string > > m_dataKeys
Definition: FetchDataFromFile.cpp:32
CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > >::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:138
std::string
STL class.
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginServiceV1.h:46
Gaudi::Algorithm::initialize
StatusCode initialize() override
the default (empty) implementation of IStateful::initialize() method
Definition: Algorithm.h:180
Gaudi::Hive::FetchDataFromFile
Definition: FetchDataFromFile.cpp:5
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
Gaudi::Hive::FetchDataFromFile::FetchDataFromFile
FetchDataFromFile(const std::string &name, ISvcLocator *pSvcLocator)
Definition: FetchDataFromFile.cpp:7
Gaudi::Hive::FetchDataFromFile::initialize
StatusCode initialize() override
Definition: FetchDataFromFile.cpp:11
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:107
DataHandleHolderBase< CounterHolder< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > > > >::addDependency
void addDependency(const DataObjID &id, const Gaudi::DataHandle::Mode &mode) override
Definition: DataHandleHolderBase.h:58
DataHandleHolderBase< CounterHolder< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > > > >::outputDataObjs
const DataObjIDColl & outputDataObjs() const override
Definition: DataHandleHolderBase.h:56
Gaudi::Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:79
Gaudi::DataHandle::Writer
Definition: DataHandle.h:29
Gaudi
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
Gaudi::Algorithm::name
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:645
Gaudi::Hive::FetchDataFromFile::start
StatusCode start() override
Definition: FetchDataFromFile.cpp:19
Gaudi::Hive::FetchDataFromFile::execute
StatusCode execute() override
Definition: FetchDataFromFile.cpp:29