The Gaudi Framework  v33r0 (d5ea422b)
AlgorithmManager.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 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 #ifndef GAUDISVC_ALGORITHMMANAGER_H
12 #define GAUDISVC_ALGORITHMMANAGER_H
13 
14 // Include files
17 #include "GaudiKernel/IAlgorithm.h"
18 #include "GaudiKernel/IStateful.h"
19 #include "GaudiKernel/Kernel.h"
20 #include "GaudiKernel/SmartIF.h"
21 #include <map>
22 #include <string>
23 #include <vector>
24 
25 // Forward declarations
26 class ISvcLocator;
27 class IMessageSvc;
28 
41 class AlgorithmManager : public extends<ComponentManager, IAlgManager> {
42 public:
43  struct AlgorithmItem final {
44  AlgorithmItem( IAlgorithm* s, bool managed = false ) : algorithm( s ), managed( managed ) {}
46  bool managed;
47  inline bool operator==( const std::string& name ) const { return algorithm->name() == name; }
48  inline bool operator==( const IAlgorithm* ptr ) const { return algorithm.get() == ptr; }
49  };
50 
53 
55  AlgorithmManager( IInterface* iface );
56 
62  StatusCode createAlgorithm( const std::string& algtype, const std::string& algname, IAlgorithm*& algorithm,
63  bool managed = false, bool checkIfExists = true ) override;
64 
66  bool existsAlgorithm( const std::string& name ) const override;
68  const std::vector<IAlgorithm*>& getAlgorithms() const override;
69 
71  StatusCode initialize() override;
73  StatusCode start() override;
75  StatusCode stop() override;
77  StatusCode finalize() override;
78 
80  StatusCode reinitialize() override;
82  StatusCode restart() override;
83 
85  const std::string& name() const override {
86  static const std::string _name = "AlgorithmManager";
87  return _name;
88  }
89 
90  SmartIF<IAlgorithm>& algorithm( const Gaudi::Utils::TypeNameString& typeName, const bool createIf = true ) override;
91 
93  const AlgTypeAliasesMap& typeAliases() const { return m_algTypeAliases; }
94 
96  void outputLevelUpdate() override;
97 
98 private:
100 
103 
105 };
106 #endif // GAUDISVC_ALGORITHMFACTORY_H
The AlgorithmManager class is in charge of the creation of concrete instances of Algorithms.
void outputLevelUpdate() override
Function to call to update the outputLevel of the components (after a change in MessageSvc).
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).
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:35
AlgTypeAliasesMap m_algTypeAliases
std::vector< AlgorithmItem > m_algs
algorithms maintained by AlgorithmManager
const std::string & name() const override
Return the name of the manager (implementation of INamedInterface)
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()
bool existsAlgorithm(const std::string &name) const override
implementation of IAlgManager::existsAlgorithm
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:86
StatusCode stop() override
Stop (from RUNNING to INITIALIZED).
StatusCode finalize() override
Finalize (from INITIALIZED to CONFIGURED).
STL class.
Helper class to parse a string of format "type/name".
const std::vector< IAlgorithm * > & getAlgorithms() const override
implementation of IAlgManager::getAlgorithms
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
Definition of the basic interface.
Definition: IInterface.h:254
StatusCode removeAlgorithm(IAlgorithm *alg) override
implementation of IAlgManager::removeAlgorithm
The IMessage is the interface implemented by the message service.
Definition: IMessageSvc.h:47
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:38
std::map< std::string, std::string > AlgTypeAliasesMap
typedefs and classes
Base class used to extend a class implementing other interfaces.
Definition: extends.h:20
bool operator==(const std::string &name) const
string s
Definition: gaudirun.py:328
AlgorithmManager(IInterface *iface)
default creator
SmartIF< IAlgorithm > & algorithm(const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true) override
std::string typeName(const std::type_info &typ)
Definition: Dictionary.cpp:31
const AlgTypeAliasesMap & typeAliases() const
bool operator==(const IAlgorithm *ptr) const
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).