| The Gaudi Framework v32r1 (f65d50dc)

HiveDataBroker.h
Go to the documentation of this file.
1 #pragma once
2 #include "GaudiKernel/IDataBroker.h"
3 #include "GaudiKernel/Service.h"
4 #include <Gaudi/Algorithm.h>
5 #include <stdexcept>
6
7 class HiveDataBrokerSvc final : public extends<Service, IDataBroker> {
8 public:
9 using extends::extends;
10
11 std::vector<Gaudi::Algorithm*> algorithmsRequiredFor( const DataObjIDColl& requested,
12 const std::vector<std::string>& stoppers = {} ) const override;
13 std::vector<Gaudi::Algorithm*> algorithmsRequiredFor( const Gaudi::Utils::TypeNameString& alg,
14 const std::vector<std::string>& stoppers = {} ) const override;
15
16 StatusCode initialize() override;
17 StatusCode start() override;
18 StatusCode stop() override;
19 StatusCode finalize() override;
20
21 private:
22 Gaudi::Property<std::string> m_dataLoader{this, "DataLoader", "",
23 "Attribute any unmet input dependencies to this Algorithm"};
24 Gaudi::Property<std::vector<std::string>> m_producers{
25 this, "DataProducers", {}, "List of algorithms to be used to resolve data dependencies"};
26
27 struct AlgEntry {
28 SmartIF<IAlgorithm> ialg;
29 Gaudi::Algorithm* alg;
30 std::set<AlgEntry*> dependsOn;
31 int requestCount = 0;
32
33 AlgEntry( SmartIF<IAlgorithm>&& p ) : ialg{std::move( p )}, alg{dynamic_cast<Gaudi::Algorithm*>( ialg.get() )} {
34 if ( !alg ) throw std::runtime_error( "algorithm pointer == nullptr???" );
35 }
36 };
37
38 std::vector<AlgEntry>
39 instantiateAndInitializeAlgorithms( const std::vector<std::string>& names ) const; // algorithms must be fully
40 // initialized first, as
41 // doing so may create
42 // additional data
43 // dependencies...
44
45 std::vector<AlgEntry> m_algorithms;
46
47 mutable std::vector<AlgEntry> m_cfnodes;
48
49 std::map<DataObjID, AlgEntry*> mapProducers( std::vector<AlgEntry>& algorithms ) const;
50
51 std::map<DataObjID, AlgEntry*> m_dependencies;
52 };
SmartIF< IAlgorithm >
ManySmallAlgs.alg
alg
Definition: ManySmallAlgs.py:69
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:352
HiveDataBrokerSvc::m_cfnodes
std::vector< AlgEntry > m_cfnodes
Definition: HiveDataBroker.h:47
HiveDataBrokerSvc::mapProducers
std::map< DataObjID, AlgEntry * > mapProducers(std::vector< AlgEntry > &algorithms) const
Definition: HiveDataBroker.cpp:172
HiveDataBrokerSvc::finalize
StatusCode finalize() override
Definition: HiveDataBroker.cpp:125
HiveDataBrokerSvc::start
StatusCode start() override
Definition: HiveDataBroker.cpp:78
HiveDataBrokerSvc::m_dependencies
std::map< DataObjID, AlgEntry * > m_dependencies
Definition: HiveDataBroker.h:51
SmartIF::get
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:76
std::map
STL class.
HiveDataBrokerSvc::stop
StatusCode stop() override
Definition: HiveDataBroker.cpp:102
Service.h
HiveDataBrokerSvc::AlgEntry::dependsOn
std::set< AlgEntry * > dependsOn
Definition: HiveDataBroker.h:30
Gaudi::Utils::TypeNameString
Helper class to parse a string of format "type/name".
Definition: TypeNameString.h:10
Algorithm.h
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
HiveDataBrokerSvc::m_producers
Gaudi::Property< std::vector< std::string > > m_producers
Definition: HiveDataBroker.h:24
std::runtime_error
STL class.
HiveDataBrokerSvc::m_dataLoader
Gaudi::Property< std::string > m_dataLoader
Definition: HiveDataBroker.h:22
HiveDataBrokerSvc::AlgEntry::AlgEntry
AlgEntry(SmartIF< IAlgorithm > &&p)
Definition: HiveDataBroker.h:33
HiveDataBrokerSvc::AlgEntry::ialg
SmartIF< IAlgorithm > ialg
Definition: HiveDataBroker.h:28
std::unordered_set< DataObjID, DataObjID_Hasher >
HiveDataBrokerSvc
Definition: HiveDataBroker.h:7
HiveDataBrokerSvc::m_algorithms
std::vector< AlgEntry > m_algorithms
Definition: HiveDataBroker.h:45
std::move
T move(T... args)
HiveDataBrokerSvc::AlgEntry
Definition: HiveDataBroker.h:27
HiveDataBrokerSvc::algorithmsRequiredFor
std::vector< Gaudi::Algorithm * > algorithmsRequiredFor(const DataObjIDColl &requested, const std::vector< std::string > &stoppers={}) const override
Definition: HiveDataBroker.cpp:248
IDataBroker.h
std::set
STL class.
std::vector< Gaudi::Algorithm * >
extends
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
Gaudi::Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:79
HiveDataBrokerSvc::instantiateAndInitializeAlgorithms
std::vector< AlgEntry > instantiateAndInitializeAlgorithms(const std::vector< std::string > &names) const
Definition: HiveDataBroker.cpp:134
HiveDataBrokerSvc::initialize
StatusCode initialize() override
Definition: HiveDataBroker.cpp:50
HiveDataBrokerSvc::AlgEntry::requestCount
int requestCount
Definition: HiveDataBroker.h:31
HiveDataBrokerSvc::AlgEntry::alg
Gaudi::Algorithm * alg
Definition: HiveDataBroker.h:29