The Gaudi Framework  master (37c0b60a)
FetchDataFromFile.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #include <GaudiKernel/Algorithm.h>
12 
13 namespace Gaudi {
14  namespace Hive {
15  class FetchDataFromFile final : public ::Algorithm {
16  public:
17  FetchDataFromFile( const std::string& name, ISvcLocator* pSvcLocator ) : Algorithm( name, pSvcLocator ) {
18  // make sure this algorithm is seen as reentrant by Gaudi
19  this->setProperty( "Cardinality", 0 ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ );
20  }
21  StatusCode initialize() override {
23  if ( sc ) {
24  // this is a hack to reuse the automatic dependencies declaration
25  for ( auto k : m_dataKeys ) { addDependency( k, Gaudi::DataHandle::Writer ); }
26  }
27  return sc;
28  }
29  StatusCode start() override {
31  if ( sc ) {
32  for ( const auto& k : outputDataObjs() ) {
33  if ( msgLevel( MSG::DEBUG ) ) debug() << "adding data key " << k << endmsg;
34  if ( sc = evtSvc()->addPreLoadItem( k.key() ); !sc ) return sc;
35  }
36  }
37  return sc;
38  }
39  StatusCode execute() override { return evtSvc()->preLoad(); }
40 
41  private:
43  this, "DataKeys", {}, "list of objects to be read from file" };
44  };
45  } // namespace Hive
46 } // namespace Gaudi
Gaudi::Hive::FetchDataFromFile::execute
StatusCode execute() override
Definition: FetchDataFromFile.cpp:39
MSG::DEBUG
@ DEBUG
Definition: IMessageSvc.h:25
std::string
STL class.
Gaudi::Algorithm::name
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:526
PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >::setProperty
StatusCode setProperty(const Gaudi::Details::PropertyBase &p)
Set the property from a property.
Definition: IProperty.h:39
ISvcLocator
Definition: ISvcLocator.h:46
Gaudi::Algorithm::initialize
StatusCode initialize() override
the default (empty) implementation of IStateful::initialize() method
Definition: Algorithm.h:178
DataHandleHolderBase< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > > >::addDependency
void addDependency(const DataObjID &id, const Gaudi::DataHandle::Mode &mode) override
Definition: DataHandleHolderBase.h:86
Algorithm.h
Gaudi::Algorithm::start
StatusCode start() override
the default (empty) implementation of IStateful::start() method
Definition: Algorithm.h:180
CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > >::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:148
Gaudi::DataHandle::Writer
@ Writer
Definition: DataHandle.h:40
Gaudi::Hive::FetchDataFromFile::m_dataKeys
Gaudi::Property< std::vector< std::string > > m_dataKeys
Definition: FetchDataFromFile.cpp:42
StatusCode
Definition: StatusCode.h:65
Gaudi::Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:90
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
Gaudi::Hive::FetchDataFromFile::initialize
StatusCode initialize() override
Definition: FetchDataFromFile.cpp:21
Gaudi
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition: __init__.py:1
Gaudi::Hive::FetchDataFromFile
Definition: FetchDataFromFile.cpp:15
StatusCode::ignore
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
Definition: StatusCode.h:139
Gaudi::Algorithm::evtSvc
SmartIF< IDataProviderSvc > & evtSvc() const
shortcut for method eventSvc
Definition: Algorithm.h:250
DataHandleHolderBase< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > > >::outputDataObjs
const DataObjIDColl & outputDataObjs() const override
Definition: DataHandleHolderBase.h:84
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginServiceV1.h:46
Gaudi::Hive::FetchDataFromFile::start
StatusCode start() override
Definition: FetchDataFromFile.cpp:29
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:37
Gaudi::Hive::FetchDataFromFile::FetchDataFromFile
FetchDataFromFile(const std::string &name, ISvcLocator *pSvcLocator)
Definition: FetchDataFromFile.cpp:17