The Gaudi Framework  master (37c0b60a)
AlgorithmManager.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 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 #ifndef GAUDISVC_ALGORITHMMANAGER_H
12 #define GAUDISVC_ALGORITHMMANAGER_H
13 
14 // Include files
17 #include <GaudiKernel/IAlgorithm.h>
18 #include <GaudiKernel/IStateful.h>
19 #include <GaudiKernel/Kernel.h>
20 #include <GaudiKernel/SmartIF.h>
21 #include <map>
22 #include <string>
23 #include <unordered_map>
24 #include <vector>
25 
26 // Forward declarations
27 class ISvcLocator;
28 class IMessageSvc;
29 
42 class AlgorithmManager : public extends<ComponentManager, IAlgManager> {
43 public:
44  struct AlgorithmItem final {
45  AlgorithmItem( IAlgorithm* s, bool managed = false ) : algorithm( s ), managed( managed ) {}
47  bool managed;
48  bool operator==( const IAlgorithm* ptr ) const { return algorithm == ptr; }
49  };
50 
53 
55  AlgorithmManager( IInterface* iface );
56 
62  StatusCode createAlgorithm( std::string algtype, std::string algname, IAlgorithm*& algorithm, bool managed = false,
63  bool checkIfExists = true ) override;
64 
66  bool existsAlgorithm( std::string_view name ) const override;
68  const std::vector<IAlgorithm*>& getAlgorithms() const override;
69 
71  StatusCode initialize() override;
73  StatusCode start() override;
75  StatusCode stop() override;
77  StatusCode finalize() override;
78 
80  StatusCode reinitialize() override;
82  StatusCode restart() override;
83 
85  const std::string& name() const override {
86  static const std::string _name = "AlgorithmManager";
87  return _name;
88  }
89 
90  SmartIF<IAlgorithm>& algorithm( const Gaudi::Utils::TypeNameString& typeName, const bool createIf = true ) override;
91 
93  const AlgTypeAliasesMap& typeAliases() const { return m_algTypeAliases; }
94 
96  void outputLevelUpdate() override;
97 
98 private:
101 
105 
107 };
108 #endif // GAUDISVC_ALGORITHMFACTORY_H
AlgorithmManager::AlgorithmItem::managed
bool managed
Definition: AlgorithmManager.h:47
AlgorithmManager::m_algTypeAliases
AlgTypeAliasesMap m_algTypeAliases
Definition: AlgorithmManager.h:106
IAlgManager.h
ComponentManager.h
std::string
STL class.
IMessageSvc
Definition: IMessageSvc.h:47
AlgorithmManager::existsAlgorithm
bool existsAlgorithm(std::string_view name) const override
implementation of IAlgManager::existsAlgorithm
Definition: AlgorithmManager.cpp:123
AlgorithmManager::restart
StatusCode restart() override
Initialization (from RUNNING to RUNNING, via INITIALIZED).
Definition: AlgorithmManager.cpp:200
gaudirun.s
string s
Definition: gaudirun.py:346
std::vector< IAlgorithm * >
AlgorithmManager::AlgorithmItem::AlgorithmItem
AlgorithmItem(IAlgorithm *s, bool managed=false)
Definition: AlgorithmManager.h:45
AlgorithmManager::AlgorithmItem::algorithm
IAlgorithm * algorithm
Definition: AlgorithmManager.h:46
AlgorithmManager::AlgTypeAliasesMap
std::map< std::string, std::string, std::less<> > AlgTypeAliasesMap
typedefs and classes
Definition: AlgorithmManager.h:52
ISvcLocator
Definition: ISvcLocator.h:46
AlgorithmManager::outputLevelUpdate
void outputLevelUpdate() override
Function to call to update the outputLevel of the components (after a change in MessageSvc).
Definition: AlgorithmManager.cpp:222
std::unordered_multimap
STL class.
AlgorithmManager
Definition: AlgorithmManager.h:42
AlgorithmManager::finalize
StatusCode finalize() override
Finalize (from INITIALIZED to CONFIGURED).
Definition: AlgorithmManager.cpp:166
ManySmallAlgs.alg
alg
Definition: ManySmallAlgs.py:81
AlgorithmManager::m_listOfPtrs
std::vector< IAlgorithm * > m_listOfPtrs
List of pointers to the know services used to implement getAlgorithms()
Definition: AlgorithmManager.h:104
SmartIF.h
Gaudi::Utils::TypeNameString
Helper class to parse a string of format "type/name".
Definition: TypeNameString.h:20
StatusCode
Definition: StatusCode.h:65
IAlgorithm
Definition: IAlgorithm.h:38
AlgorithmManager::createAlgorithm
StatusCode createAlgorithm(std::string algtype, std::string algname, IAlgorithm *&algorithm, bool managed=false, bool checkIfExists=true) override
implementation of IAlgManager::createAlgorithm
Definition: AlgorithmManager.cpp:54
AlgorithmManager::initialize
StatusCode initialize() override
Initialization (from CONFIGURED to INITIALIZED).
Definition: AlgorithmManager.cpp:136
AlgorithmManager::removeAlgorithm
StatusCode removeAlgorithm(IAlgorithm *alg) override
implementation of IAlgManager::removeAlgorithm
Definition: AlgorithmManager.cpp:40
IStateful.h
SmartIF< IAlgorithm >
AlgorithmManager::start
StatusCode start() override
Start (from INITIALIZED to RUNNING).
Definition: AlgorithmManager.cpp:146
std::map
STL class.
extends
Base class used to extend a class implementing other interfaces.
Definition: extends.h:20
AlgorithmManager::m_algs
std::vector< AlgorithmItem > m_algs
algorithms maintained by AlgorithmManager
Definition: AlgorithmManager.h:99
AlgorithmManager::name
const std::string & name() const override
Return the name of the manager (implementation of INamedInterface)
Definition: AlgorithmManager.h:85
AlgorithmManager::algorithm
SmartIF< IAlgorithm > & algorithm(const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true) override
Definition: AlgorithmManager.cpp:108
AlgorithmManager::AlgorithmItem
Definition: AlgorithmManager.h:44
AlgorithmManager::addAlgorithm
StatusCode addAlgorithm(IAlgorithm *alg) override
implementation of IAlgManager::addAlgorithm
Definition: AlgorithmManager.cpp:33
AlgorithmManager::m_algsMap
std::unordered_multimap< std::string_view, SmartIF< IAlgorithm > > m_algsMap
algorithms maintained by AlgorithmManager
Definition: AlgorithmManager.h:100
GaudiDict::typeName
std::string typeName(const std::type_info &typ)
Definition: Dictionary.cpp:31
AlgorithmManager::AlgorithmItem::operator==
bool operator==(const IAlgorithm *ptr) const
Definition: AlgorithmManager.h:48
Kernel.h
IInterface
Definition: IInterface.h:239
AlgorithmManager::AlgorithmManager
AlgorithmManager(IInterface *iface)
default creator
Definition: AlgorithmManager.cpp:28
AlgorithmManager::typeAliases
const AlgTypeAliasesMap & typeAliases() const
Definition: AlgorithmManager.h:93
IAlgorithm.h
AlgorithmManager::typeAliases
AlgTypeAliasesMap & typeAliases()
Definition: AlgorithmManager.h:92
AlgorithmManager::reinitialize
StatusCode reinitialize() override
Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED).
Definition: AlgorithmManager.cpp:187
AlgorithmManager::getAlgorithms
const std::vector< IAlgorithm * > & getAlgorithms() const override
implementation of IAlgManager::getAlgorithms
Definition: AlgorithmManager.cpp:128
AlgorithmManager::stop
StatusCode stop() override
Stop (from RUNNING to INITIALIZED).
Definition: AlgorithmManager.cpp:156