The Gaudi Framework  v29r0 (ff2e7097)
AlgorithmManager.h
Go to the documentation of this file.
1 #ifndef GAUDISVC_ALGORITHMMANAGER_H
2 #define GAUDISVC_ALGORITHMMANAGER_H
3 
4 // Include files
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 {
33 public:
34  struct AlgorithmItem final {
35  AlgorithmItem( IAlgorithm* s, bool managed = false ) : algorithm( s ), managed( managed ) {}
37  bool managed;
38  inline bool operator==( const std::string& name ) const { return algorithm->name() == name; }
39  inline bool operator==( const IAlgorithm* ptr ) const { return algorithm.get() == ptr; }
40  };
41 
44 
46  AlgorithmManager( IInterface* iface );
48  ~AlgorithmManager() override = default;
49 
51  StatusCode addAlgorithm( IAlgorithm* alg ) override;
53  StatusCode removeAlgorithm( IAlgorithm* alg ) override;
55  StatusCode createAlgorithm( const std::string& algtype, const std::string& algname, IAlgorithm*& algorithm,
56  bool managed = false, bool checkIfExists = true ) override;
57 
59  bool existsAlgorithm( const std::string& name ) const override;
61  const std::vector<IAlgorithm*>& getAlgorithms() const override;
62 
64  StatusCode initialize() override;
66  StatusCode start() override;
68  StatusCode stop() override;
70  StatusCode finalize() override;
71 
73  StatusCode reinitialize() override;
75  StatusCode restart() override;
76 
78  const std::string& name() const override
79  {
80  static const std::string _name = "AlgorithmManager";
81  return _name;
82  }
83 
84  SmartIF<IAlgorithm>& algorithm( const Gaudi::Utils::TypeNameString& typeName, const bool createIf = true ) override;
85 
86  AlgTypeAliasesMap& typeAliases() { return m_algTypeAliases; }
87  const AlgTypeAliasesMap& typeAliases() const { return m_algTypeAliases; }
88 
89 private:
91 
94 
95  AlgTypeAliasesMap m_algTypeAliases;
96 };
97 #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:82
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:28
Definition of the basic interface.
Definition: IInterface.h:277
StatusCode removeAlgorithm(IAlgorithm *alg) override
implementation of IAlgManager::removeAlgorithm
The IMessage is the interface implemented by the message service.
Definition: IMessageSvc.h:38
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:28
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:253
bool operator==(const std::string &name) const
AlgorithmManager(IInterface *iface)
default creator
std::string typeName(const std::type_info &typ)
Definition: Dictionary.cpp:23
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).