The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
AlgorithmManager.h
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2025 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
12
17#include <GaudiKernel/Kernel.h>
18#include <GaudiKernel/SmartIF.h>
19#include <map>
20#include <string>
21#include <unordered_map>
22#include <vector>
23
24class ISvcLocator;
25class IMessageSvc;
26
39class AlgorithmManager : public extends<ComponentManager, IAlgManager> {
40public:
41 struct AlgorithmItem final {
42 AlgorithmItem( IAlgorithm* s, bool managed = false ) : algorithm( s ), managed( managed ) {}
44 bool managed;
45 bool operator==( const IAlgorithm* ptr ) const { return algorithm == ptr; }
46 };
47
49 typedef std::map<std::string, std::string, std::less<>> AlgTypeAliasesMap;
50
53
55 StatusCode addAlgorithm( IAlgorithm* alg ) override;
57 StatusCode removeAlgorithm( IAlgorithm* alg ) override;
59 StatusCode createAlgorithm( const std::string& algtype, const std::string& algname, IAlgorithm*& algorithm,
60 bool managed = false, bool checkIfExists = true ) override;
61
63 bool existsAlgorithm( std::string_view name ) const override;
65 std::vector<IAlgorithm*> getAlgorithms() const override;
66
68 StatusCode initialize() override;
70 StatusCode start() override;
72 StatusCode stop() override;
74 StatusCode finalize() override;
75
77 StatusCode reinitialize() override;
79 StatusCode restart() override;
80
82 const std::string& name() const override {
83 static const std::string _name = "AlgorithmManager";
84 return _name;
85 }
86
87 SmartIF<IAlgorithm>& algorithm( const Gaudi::Utils::TypeNameString& typeName, const bool createIf = true ) override;
88
91
93 void outputLevelUpdate() override;
94
95private:
96 std::vector<AlgorithmItem> m_algs;
97 std::unordered_multimap<std::string, SmartIF<IAlgorithm>> m_algsMap;
99
101};
std::map< std::string, std::string, std::less<> > AlgTypeAliasesMap
typedefs and classes
SmartIF< IAlgorithm > & algorithm(const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true) override
AlgorithmManager(IInterface *iface)
default creator
std::vector< IAlgorithm * > getAlgorithms() const override
implementation of IAlgManager::getAlgorithms
AlgTypeAliasesMap m_algTypeAliases
const AlgTypeAliasesMap & typeAliases() const
StatusCode start() override
Start (from INITIALIZED to RUNNING).
StatusCode finalize() override
Finalize (from INITIALIZED to CONFIGURED).
StatusCode stop() override
Stop (from RUNNING to INITIALIZED).
StatusCode addAlgorithm(IAlgorithm *alg) override
implementation of IAlgManager::addAlgorithm
AlgTypeAliasesMap & typeAliases()
bool existsAlgorithm(std::string_view name) const override
implementation of IAlgManager::existsAlgorithm
std::vector< AlgorithmItem > m_algs
algorithms maintained by AlgorithmManager
StatusCode removeAlgorithm(IAlgorithm *alg) override
implementation of IAlgManager::removeAlgorithm
StatusCode reinitialize() override
Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED).
StatusCode createAlgorithm(const std::string &algtype, const std::string &algname, IAlgorithm *&algorithm, bool managed=false, bool checkIfExists=true) override
implementation of IAlgManager::createAlgorithm
StatusCode initialize() override
Initialization (from CONFIGURED to INITIALIZED).
StatusCode restart() override
Initialization (from RUNNING to RUNNING, via INITIALIZED).
std::unordered_multimap< std::string, SmartIF< IAlgorithm > > m_algsMap
algorithms maintained by AlgorithmManager
const std::string & name() const override
Return the name of the manager (implementation of INamedInterface)
void outputLevelUpdate() override
Function to call to update the outputLevel of the components (after a change in MessageSvc).
Helper class to parse a string of format "type/name".
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition IAlgorithm.h:36
Definition of the basic interface.
Definition IInterface.h:225
The IMessage is the interface implemented by the message service.
Definition IMessageSvc.h:34
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition ISvcLocator.h:42
Small smart pointer class with automatic reference counting for IInterface.
Definition SmartIF.h:28
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
Base class used to extend a class implementing other interfaces.
Definition extends.h:19
AlgorithmItem(IAlgorithm *s, bool managed=false)
bool operator==(const IAlgorithm *ptr) const