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