All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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/Kernel.h"
9 #include "GaudiKernel/SmartIF.h"
10 #include "GaudiKernel/IAlgorithm.h"
11 #include <string>
12 #include <vector>
13 #include <map>
14 
15 // Forward declarations
16 class ISvcLocator;
17 class IMessageSvc;
18 
31 class AlgorithmManager : public extends<ComponentManager,
32  IAlgManager> {
33 public:
34 
35  struct AlgorithmItem final {
36  AlgorithmItem(IAlgorithm *s, bool managed = false):
37  algorithm(s), managed(managed) {}
39  bool managed;
40  inline bool operator==(const std::string &name) const {
41  return algorithm->name() == name;
42  }
43  inline bool operator==(const IAlgorithm *ptr) const {
44  return algorithm.get() == ptr;
45  }
46  };
47 
50 
52  AlgorithmManager( IInterface* iface );
54  ~AlgorithmManager() override = default;
55 
57  StatusCode addAlgorithm(IAlgorithm* alg) override;
59  StatusCode removeAlgorithm(IAlgorithm* alg) override;
61  StatusCode createAlgorithm(const std::string& algtype, const std::string& algname,
62  IAlgorithm*& algorithm, bool managed = false, bool checkIfExists = true) override;
63 
65  bool existsAlgorithm(const std::string& name) const override;
67  const std::vector<IAlgorithm*>& getAlgorithms() const override;
68 
70  StatusCode initialize() override;
72  StatusCode start() override;
74  StatusCode stop() override;
76  StatusCode finalize() override;
77 
79  StatusCode reinitialize() override;
81  StatusCode restart() override;
82 
84  const std::string &name() const override {
85  static const std::string _name = "AlgorithmManager";
86  return _name;
87  }
88 
89  SmartIF<IAlgorithm> &algorithm(const Gaudi::Utils::TypeNameString &typeName, const bool createIf = true) override;
90 
91  AlgTypeAliasesMap& typeAliases() { return m_algTypeAliases; }
92  const AlgTypeAliasesMap& typeAliases() const { return m_algTypeAliases; }
93 
94 private:
96 
99 
100  AlgTypeAliasesMap m_algTypeAliases;
101 
102 };
103 #endif // GAUDISVC_ALGORITHMFACTORY_H
The AlgorithmManager class is in charge of the creation of concrete instances of Algorithms.
StatusCode initialize() override
Initialization (from CONFIGURED to INITIALIZED).
AlgorithmItem(IAlgorithm *s, bool managed=false)
StatusCode addAlgorithm(IAlgorithm *alg) override
implementation of IAlgManager::addAlgorithm
StatusCode start() override
Start (from INITIALIZED to RUNNING).
const AlgTypeAliasesMap & typeAliases() const
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
const std::string & name() const override
Return the name of the manager (implementation of INamedInterface)
const std::vector< IAlgorithm * > & getAlgorithms() const override
implementation of IAlgManager::getAlgorithms
AlgTypeAliasesMap m_algTypeAliases
std::vector< AlgorithmItem > m_algs
algorithms maintained by AlgorithmManager
std::vector< IAlgorithm * > m_listOfPtrs
List of pointers to the know services used to implement getAlgorithms()
StatusCode reinitialize() override
Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED).
AlgTypeAliasesMap & typeAliases()
StatusCode stop() override
Stop (from RUNNING to INITIALIZED).
StatusCode finalize() override
Finalize (from INITIALIZED to CONFIGURED).
STL class.
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:76
Helper class to parse a string of format "type/name".
bool existsAlgorithm(const std::string &name) const override
implementation of IAlgManager::existsAlgorithm
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
Definition of the basic interface.
Definition: IInterface.h:234
StatusCode removeAlgorithm(IAlgorithm *alg) override
implementation of IAlgManager::removeAlgorithm
The IMessage is the interface implemented by the message service.
Definition: IMessageSvc.h:57
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:27
std::map< std::string, std::string > AlgTypeAliasesMap
typedefs and classes
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
string s
Definition: gaudirun.py:245
bool operator==(const std::string &name) const
AlgorithmManager(IInterface *iface)
default creator
std::string typeName(const std::type_info &typ)
Definition: Dictionary.cpp:21
bool operator==(const IAlgorithm *ptr) const
~AlgorithmManager() override=default
virtual destructor
StatusCode createAlgorithm(const std::string &algtype, const std::string &algname, IAlgorithm *&algorithm, bool managed=false, bool checkIfExists=true) override
implementation of IAlgManager::createAlgorithm
SmartIF< IAlgorithm > algorithm
StatusCode restart() override
Initialization (from RUNNING to RUNNING, via INITIALIZED).