The Gaudi Framework  v38r1p1 (ae26267b)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
HiveDataBroker.h
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 #pragma once
13 #include "GaudiKernel/Service.h"
14 #include <Gaudi/Algorithm.h>
15 #include <stdexcept>
16 
17 class HiveDataBrokerSvc final : public extends<Service, IDataBroker> {
18 public:
19  using extends::extends;
20 
22  const std::vector<std::string>& stoppers = {} ) const override;
24  const std::vector<std::string>& stoppers = {} ) const override;
25 
26  StatusCode initialize() override;
27  StatusCode start() override;
28  StatusCode stop() override;
29  StatusCode finalize() override;
30 
31 private:
32  Gaudi::Property<std::string> m_dataLoader{ this, "DataLoader", "",
33  "Attribute any unmet input dependencies to this Algorithm" };
35  this, "DataProducers", {}, "List of algorithms to be used to resolve data dependencies" };
36 
37  struct AlgEntry {
38  size_t index;
42 
43  AlgEntry( size_t i, SmartIF<IAlgorithm>&& p )
44  : index{ i }, ialg{ std::move( p ) }, alg{ dynamic_cast<Gaudi::Algorithm*>( ialg.get() ) } {
45  if ( !alg ) throw std::runtime_error( "algorithm pointer == nullptr???" );
46  }
47  };
48 
50  instantiateAndInitializeAlgorithms( const std::vector<std::string>& names ) const; // algorithms must be fully
51  // initialized first, as
52  // doing so may create
53  // additional data
54  // dependencies...
55 
57 
59 
61 
62  void visit( AlgEntry const& alg, std::vector<std::string> const& stoppers, std::vector<Gaudi::Algorithm*>& sorted,
63  std::vector<bool>& visited, std::vector<bool>& visiting ) const;
64 };
Histograms_with_global.algorithms
algorithms
Definition: Histograms_with_global.py:19
HiveDataBrokerSvc::initialize
StatusCode initialize() override
Definition: HiveDataBroker.cpp:72
HiveDataBrokerSvc::m_producers
Gaudi::Property< std::vector< std::string > > m_producers
Definition: HiveDataBroker.h:34
HiveDataBrokerSvc::AlgEntry::index
size_t index
Definition: HiveDataBroker.h:38
std::move
T move(T... args)
std::unordered_set< DataObjID, DataObjID_Hasher >
std::vector< Gaudi::Algorithm * >
HiveDataBrokerSvc::AlgEntry::AlgEntry
AlgEntry(size_t i, SmartIF< IAlgorithm > &&p)
Definition: HiveDataBroker.h:43
HiveDataBrokerSvc::m_dependencies
std::map< DataObjID, AlgEntry * > m_dependencies
Definition: HiveDataBroker.h:60
HiveDataBrokerSvc::stop
StatusCode stop() override
Definition: HiveDataBroker.cpp:115
HiveDataBrokerSvc::mapProducers
std::map< DataObjID, AlgEntry * > mapProducers(std::map< std::string, AlgEntry > &algorithms) const
Definition: HiveDataBroker.cpp:178
HiveDataBrokerSvc::m_dataLoader
Gaudi::Property< std::string > m_dataLoader
Definition: HiveDataBroker.h:32
ManySmallAlgs.alg
alg
Definition: ManySmallAlgs.py:80
Gaudi::Utils::TypeNameString
Helper class to parse a string of format "type/name".
Definition: TypeNameString.h:20
StatusCode
Definition: StatusCode.h:65
HiveDataBrokerSvc::start
StatusCode start() override
Definition: HiveDataBroker.cpp:99
HiveDataBrokerSvc::m_algorithms
std::map< std::string, AlgEntry > m_algorithms
Definition: HiveDataBroker.h:56
HiveDataBrokerSvc::algorithmsRequiredFor
std::vector< Gaudi::Algorithm * > algorithmsRequiredFor(const DataObjIDColl &requested, const std::vector< std::string > &stoppers={}) const override
Definition: HiveDataBroker.cpp:254
Gaudi::Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:90
HiveDataBrokerSvc::instantiateAndInitializeAlgorithms
std::map< std::string, AlgEntry > instantiateAndInitializeAlgorithms(const std::vector< std::string > &names) const
Definition: HiveDataBroker.cpp:139
Algorithm.h
std::runtime_error
STL class.
SmartIF< IAlgorithm >
std::map
STL class.
extends
Base class used to extend a class implementing other interfaces.
Definition: extends.h:20
IDataBroker.h
Service.h
HiveDataBrokerSvc
Definition: HiveDataBroker.h:17
SmartIF::get
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:86
HiveDataBrokerSvc::AlgEntry::ialg
SmartIF< IAlgorithm > ialg
Definition: HiveDataBroker.h:39
HiveDataBrokerSvc::AlgEntry
Definition: HiveDataBroker.h:37
HiveDataBrokerSvc::AlgEntry::alg
Gaudi::Algorithm * alg
Definition: HiveDataBroker.h:40
HiveDataBrokerSvc::visit
void visit(AlgEntry const &alg, std::vector< std::string > const &stoppers, std::vector< Gaudi::Algorithm * > &sorted, std::vector< bool > &visited, std::vector< bool > &visiting) const
Implements DFS topological sorting.
Definition: HiveDataBroker.cpp:234
HiveDataBrokerSvc::finalize
StatusCode finalize() override
Definition: HiveDataBroker.cpp:130
std::set
STL class.
Gaudi::Property< std::string >
HiveDataBrokerSvc::AlgEntry::dependsOn
std::set< AlgEntry * > dependsOn
Definition: HiveDataBroker.h:41