The Gaudi Framework  v30r4 (9b837755)
FetchDataFromFile.cpp
Go to the documentation of this file.
2 
3 namespace Gaudi
4 {
5  namespace Hive
6  {
7  class FetchDataFromFile final : public Algorithm
8  {
10 
11  public:
12  FetchDataFromFile( const std::string& name, ISvcLocator* pSvcLocator ) : Algorithm( name, pSvcLocator )
13  {
14  // make sure this algorithm is seen as reentrant by Gaudi
15  this->setProperty( "Cardinality", 0 );
16  }
18  {
20  if ( sc ) {
21  // this is a hack to reuse the automatic dependencies declaration
22  for ( auto k : m_dataKeys ) {
23  addDataDependency( k, AccessMode::Write );
24  }
25  }
26  return sc;
27  }
28 
29  StatusCode start() override
30  {
32  if ( sc ) {
33  for ( const auto& k : dataDependencies( AccessMode::Write ) ) {
34  if ( UNLIKELY( msgLevel( MSG::DEBUG ) ) ) debug() << "adding data key " << k << endmsg;
35  evtSvc()->addPreLoadItem( k.key() );
36  }
37  }
38  return sc;
39  }
40 
41  StatusCode execute() override { return evtSvc()->preLoad(); }
42 
43  private:
45  this, "DataKeys", {}, "list of objects to be read from file"};
46  };
47  }
48 }
#define UNLIKELY(x)
Definition: Kernel.h:89
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:747
Implementation of property with value of concrete type.
Definition: Property.h:383
StatusCode setProperty(const Gaudi::Details::PropertyBase &p) override
set the property form another property
virtual StatusCode addPreLoadItem(const DataStoreItem &item)=0
Add an item to the preload list.
IDataHandleMetadata::AccessMode AccessMode
Definition: DataHandle.h:115
void addDataDependency(const DataObjID &key, AccessMode access) final override
Add a data dependency, even after initialization.
Header file for class GaudiAlgorithm.
virtual StatusCode preLoad()=0
Load all preload items of the list.
Gaudi::Property< std::vector< std::string > > m_dataKeys
STL class.
#define DECLARE_COMPONENT(type)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
FetchDataFromFile(const std::string &name, ISvcLocator *pSvcLocator)
StatusCode initialize() override
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:79
SmartIF< IDataProviderSvc > & evtSvc() const
shortcut for method eventSvc
Definition: Algorithm.h:281
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
StatusCode initialize() override
the default (empty) implementation of IStateful::initialize() method
Definition: Algorithm.h:180
StatusCode start() override
the default (empty) implementation of IStateful::start() method
Definition: Algorithm.h:182
const DataObjIDColl & dataDependencies(AccessMode access) const final override
Tell which whiteboard keys the algorithm will be reading or writing.
Helper functions to set/get the application return code.
Definition: __init__.py:1
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
Gaudi::v2::DataHandle::AccessMode AccessMode
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)