| The Gaudi Framework v32r1 (f65d50dc)

AlgorithmManager.h
Go to the documentation of this file.
1 #ifndef GAUDISVC_ALGORITHMMANAGER_H
2 #define GAUDISVC_ALGORITHMMANAGER_H
3
4 // Include files
5 #include "GaudiKernel/ComponentManager.h"
6 #include "GaudiKernel/IAlgManager.h"
7 #include "GaudiKernel/IAlgorithm.h"
8 #include "GaudiKernel/IStateful.h"
9 #include "GaudiKernel/Kernel.h"
10 #include "GaudiKernel/SmartIF.h"
11 #include <map>
12 #include <string>
13 #include <vector>
14
15 // Forward declarations
16 class ISvcLocator;
17 class IMessageSvc;
18
31 class AlgorithmManager : public extends<ComponentManager, IAlgManager> {
32 public:
33 struct AlgorithmItem final {
34 AlgorithmItem( IAlgorithm* s, bool managed = false ) : algorithm( s ), managed( managed ) {}
35 SmartIF<IAlgorithm> algorithm;
36 bool managed;
37 inline bool operator==( const std::string& name ) const { return algorithm->name() == name; }
38 inline bool operator==( const IAlgorithm* ptr ) const { return algorithm.get() == ptr; }
39 };
40
42 typedef std::map<std::string, std::string> AlgTypeAliasesMap;
43
45 AlgorithmManager( IInterface* iface );
46
48 StatusCode addAlgorithm( IAlgorithm* alg ) override;
50 StatusCode removeAlgorithm( IAlgorithm* alg ) override;
52 StatusCode createAlgorithm( const std::string& algtype, const std::string& algname, IAlgorithm*& algorithm,
53 bool managed = false, bool checkIfExists = true ) override;
54
56 bool existsAlgorithm( const std::string& name ) const override;
58 const std::vector<IAlgorithm*>& getAlgorithms() const override;
59
61 StatusCode initialize() override;
63 StatusCode start() override;
65 StatusCode stop() override;
67 StatusCode finalize() override;
68
70 StatusCode reinitialize() override;
72 StatusCode restart() override;
73
75 const std::string& name() const override {
76 static const std::string _name = "AlgorithmManager";
77 return _name;
78 }
79
80 SmartIF<IAlgorithm>& algorithm( const Gaudi::Utils::TypeNameString& typeName, const bool createIf = true ) override;
81
82 AlgTypeAliasesMap& typeAliases() { return m_algTypeAliases; }
83 const AlgTypeAliasesMap& typeAliases() const { return m_algTypeAliases; }
84
86 void outputLevelUpdate() override;
87
88 private:
89 std::vector<AlgorithmItem> m_algs;
90
92 mutable std::vector<IAlgorithm*> m_listOfPtrs;
93
94 AlgTypeAliasesMap m_algTypeAliases;
95 };
96 #endif // GAUDISVC_ALGORITHMFACTORY_H
AlgorithmManager
The AlgorithmManager class is in charge of the creation of concrete instances of Algorithms.
Definition: AlgorithmManager.h:31
AlgorithmManager::outputLevelUpdate
void outputLevelUpdate() override
Function to call to update the outputLevel of the components (after a change in MessageSvc).
Definition: AlgorithmManager.cpp:201
AlgorithmManager::initialize
StatusCode initialize() override
Initialization (from CONFIGURED to INITIALIZED).
Definition: AlgorithmManager.cpp:121
AlgorithmManager::AlgorithmItem::AlgorithmItem
AlgorithmItem(IAlgorithm *s, bool managed=false)
Definition: AlgorithmManager.h:34
SmartIF< IAlgorithm >
Kernel.h
AlgorithmManager::addAlgorithm
StatusCode addAlgorithm(IAlgorithm *alg) override
implementation of IAlgManager::addAlgorithm
Definition: AlgorithmManager.cpp:24
AlgorithmManager::start
StatusCode start() override
Start (from INITIALIZED to RUNNING).
Definition: AlgorithmManager.cpp:131
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
ManySmallAlgs.alg
alg
Definition: ManySmallAlgs.py:69
AlgorithmManager::m_algTypeAliases
AlgTypeAliasesMap m_algTypeAliases
Definition: AlgorithmManager.h:94
AlgorithmManager::m_algs
std::vector< AlgorithmItem > m_algs
algorithms maintained by AlgorithmManager
Definition: AlgorithmManager.h:89
AlgorithmManager::name
const std::string & name() const override
Return the name of the manager (implementation of INamedInterface)
Definition: AlgorithmManager.h:75
IAlgorithm.h
AlgorithmManager::AlgorithmItem::managed
bool managed
Definition: AlgorithmManager.h:36
AlgorithmManager::m_listOfPtrs
std::vector< IAlgorithm * > m_listOfPtrs
List of pointers to the know services used to implement getAlgorithms()
Definition: AlgorithmManager.h:92
AlgorithmManager::AlgorithmItem
Definition: AlgorithmManager.h:33
AlgorithmManager::reinitialize
StatusCode reinitialize() override
Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED).
Definition: AlgorithmManager.cpp:166
AlgorithmManager::typeAliases
AlgTypeAliasesMap & typeAliases()
Definition: AlgorithmManager.h:82
AlgorithmManager::existsAlgorithm
bool existsAlgorithm(const std::string &name) const override
implementation of IAlgManager::existsAlgorithm
Definition: AlgorithmManager.cpp:108
SmartIF::get
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:76
std::map< std::string, std::string >
AlgorithmManager::stop
StatusCode stop() override
Stop (from RUNNING to INITIALIZED).
Definition: AlgorithmManager.cpp:141
AlgorithmManager::finalize
StatusCode finalize() override
Finalize (from INITIALIZED to CONFIGURED).
Definition: AlgorithmManager.cpp:151
std::string
STL class.
Gaudi::Utils::TypeNameString
Helper class to parse a string of format "type/name".
Definition: TypeNameString.h:10
AlgorithmManager::getAlgorithms
const std::vector< IAlgorithm * > & getAlgorithms() const override
implementation of IAlgManager::getAlgorithms
Definition: AlgorithmManager.cpp:113
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
IInterface
Definition of the basic interface.
Definition: IInterface.h:244
AlgorithmManager::removeAlgorithm
StatusCode removeAlgorithm(IAlgorithm *alg) override
implementation of IAlgManager::removeAlgorithm
Definition: AlgorithmManager.cpp:30
SmartIF.h
IMessageSvc
The IMessage is the interface implemented by the message service.
Definition: IMessageSvc.h:37
IStateful.h
IAlgorithm
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:28
AlgorithmManager::AlgTypeAliasesMap
std::map< std::string, std::string > AlgTypeAliasesMap
typedefs and classes
Definition: AlgorithmManager.h:42
std::vector< IAlgorithm * >
extends
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
AlgorithmManager::AlgorithmItem::operator==
bool operator==(const std::string &name) const
Definition: AlgorithmManager.h:37
gaudirun.s
string s
Definition: gaudirun.py:316
IAlgManager.h
AlgorithmManager::AlgorithmManager
AlgorithmManager(IInterface *iface)
default creator
Definition: AlgorithmManager.cpp:19
AlgorithmManager::algorithm
SmartIF< IAlgorithm > & algorithm(const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true) override
Definition: AlgorithmManager.cpp:93
ComponentManager.h
GaudiDict::typeName
std::string typeName(const std::type_info &typ)
Definition: Dictionary.cpp:21
AlgorithmManager::typeAliases
const AlgTypeAliasesMap & typeAliases() const
Definition: AlgorithmManager.h:83
AlgorithmManager::AlgorithmItem::operator==
bool operator==(const IAlgorithm *ptr) const
Definition: AlgorithmManager.h:38
AlgorithmManager::createAlgorithm
StatusCode createAlgorithm(const std::string &algtype, const std::string &algname, IAlgorithm *&algorithm, bool managed=false, bool checkIfExists=true) override
implementation of IAlgManager::createAlgorithm
Definition: AlgorithmManager.cpp:40
AlgorithmManager::AlgorithmItem::algorithm
SmartIF< IAlgorithm > algorithm
Definition: AlgorithmManager.h:35
AlgorithmManager::restart
StatusCode restart() override
Initialization (from RUNNING to RUNNING, via INITIALIZED).
Definition: AlgorithmManager.cpp:179