Skip to content
Snippets Groups Projects
Commit 44bbb221 authored by Charles Leggett's avatar Charles Leggett
Browse files

updated FetchDataFromFile algorithm

See merge request !300
parents 865caee8 2627900c
No related branches found
No related tags found
1 merge request!300updated FetchDataFromFile algorithm
Pipeline #
...@@ -3,23 +3,25 @@ ...@@ -3,23 +3,25 @@
namespace Gaudi { namespace Gaudi {
namespace Hive { namespace Hive {
class FetchDataFromFile final: public GaudiAlgorithm { class FetchDataFromFile final: public GaudiAlgorithm {
StringArrayProperty m_dataKeys;
std::vector<DataObjectHandle<DataObject>> m_outputHandles;
public: public:
FetchDataFromFile(const std::string& name, ISvcLocator* svcLoc): using GaudiAlgorithm::GaudiAlgorithm;
GaudiAlgorithm(name, svcLoc)
{
declareProperty("DataKeys", m_dataKeys, "list of objects to be read from file");
}
StatusCode initialize() override { StatusCode initialize() override {
StatusCode sc = GaudiAlgorithm::initialize(); StatusCode sc = GaudiAlgorithm::initialize();
if (sc) { if (sc) {
// this is a hack to reuse the automatic dependencies declaration // this is a hack to reuse the automatic dependencies declaration
for (auto k: m_dataKeys.value()) { for (auto k: m_dataKeys) {
debug() << "adding data key " << k << endmsg; addDependency(k, Gaudi::DataHandle::Writer);
evtSvc()->addPreLoadItem(k); }
// note: the DataObjectHandleBase constructor will 'declare' the handle }
m_outputHandles.emplace_back( k, Gaudi::DataHandle::Writer, this ); return sc;
}
StatusCode start() override {
StatusCode sc = GaudiAlgorithm::start();
if ( sc ) {
for( const auto& k: outputDataObjs() ) {
if ( UNLIKELY( msgLevel( MSG::DEBUG ) ) )
debug() << "adding data key " << k << endmsg;
evtSvc()->addPreLoadItem( k.key() );
} }
} }
return sc; return sc;
...@@ -27,8 +29,11 @@ namespace Gaudi { ...@@ -27,8 +29,11 @@ namespace Gaudi {
StatusCode execute() override { StatusCode execute() override {
return evtSvc()->preLoad(); return evtSvc()->preLoad();
} }
private:
Gaudi::Property<std::vector<std::string>> m_dataKeys{ this, "DataKeys", {},
"list of objects to be read from file" };
}; };
} }
} }
using Gaudi::Hive::FetchDataFromFile; using Gaudi::Hive::FetchDataFromFile;
DECLARE_COMPONENT(FetchDataFromFile) DECLARE_COMPONENT( FetchDataFromFile )
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment