3 #include "GaudiKernel/IAlgorithm.h"
4 #include "GaudiKernel/Algorithm.h"
5 #include "GaudiKernel/ISvcLocator.h"
6 #include "GaudiKernel/System.h"
7 #include "GaudiKernel/MsgStream.h"
8 #include "GaudiKernel/TypeNameString.h"
42 const std::string& algname,
54 std::string actualalgtype(algtype);
56 if ((actualalgtype.size() > 8) && (actualalgtype.compare(0, 8,
"unalias:") == 0)) {
57 actualalgtype = actualalgtype.substr(8);
61 actualalgtype = typeAlias->second;
64 algorithm = Algorithm::Factory::create(actualalgtype, algname, serviceLocator().
get());
66 this->error() <<
"Algorithm of type " << actualalgtype
67 <<
" is unknown (No factory available)." <<
endmsg;
72 if (! err.empty()) this->error() << err <<
endmsg;
73 this->error() <<
"More information may be available by setting the global jobOpt \"PluginDebugLevel\" to 1" <<
endmsg;
78 fatal() <<
"Incompatible interface IAlgorithm version for " << actualalgtype <<
endmsg;
81 m_algs.emplace_back(algorithm, managed);
97 this->error() <<
"Failed to initialize algorithm: [" << algname <<
"]" <<
endmsg;
106 return it->algorithm;
137 for (
auto& it :
m_algs ) {
138 if (!it.managed)
continue;
139 rc = it.algorithm->sysInitialize();
147 for (
auto& it :
m_algs ) {
148 if (!it.managed)
continue;
149 rc = it.algorithm->sysStart();
158 if (!it.managed)
continue;
159 rc = it.algorithm->sysStop();
168 while (it !=
m_algs.end()){
170 rc = it->algorithm->sysFinalize();
182 for (
auto& it :
m_algs ) {
183 if (!it.managed)
continue;
184 rc = it.algorithm->sysReinitialize();
186 this->error() <<
"Unable to re-initialize algorithm: " << it.algorithm->name() <<
endmsg;
195 for (
auto& it :
m_algs ) {
196 if (!it.managed)
continue;
197 rc = it.algorithm->sysRestart();
199 this->error() <<
"Unable to re-initialize algorithm: " << it.algorithm->name() <<
endmsg;
StatusCode initialize() override
Initialization (from CONFIGURED to INITIALIZED).
StatusCode addAlgorithm(IAlgorithm *alg) override
implementation of IAlgManager::addAlgorithm
StatusCode start() override
Start (from INITIALIZED to RUNNING).
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
virtual StatusCode sysStart()=0
Startup method invoked by the framework.
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)
bool isSuccess() const
Test for a status code of SUCCESS.
auto begin(reverse_wrapper< T > &w)
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).
bool existsAlgorithm(const std::string &name) const override
implementation of IAlgManager::existsAlgorithm
bool isFailure() const
Test for a status code of FAILURE.
StatusCode stop() override
Stop (from RUNNING to INITIALIZED).
StatusCode finalize() override
Finalize (from INITIALIZED to CONFIGURED).
virtual StatusCode sysInitialize()=0
Initialization method invoked by the framework.
TYPE * get() const
Get interface pointer.
Helper class to parse a string of format "type/name".
const std::vector< IAlgorithm * > & getAlgorithms() const override
implementation of IAlgManager::getAlgorithms
auto end(reverse_wrapper< T > &w)
This class is used for returning status codes from appropriate routines.
Definition of the basic interface.
StatusCode removeAlgorithm(IAlgorithm *alg) override
implementation of IAlgManager::removeAlgorithm
The IAlgorithm is the interface implemented by the Algorithm base class.
virtual void setType(const std::string &)=0
Base class used to extend a class implementing other interfaces.
const std::string & type() const
GAUDI_API const std::string getLastErrorString()
Get last system error as string.
AlgorithmManager(IInterface *iface)
default creator
SmartIF< IAlgorithm > & algorithm(const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true) override
bool isValidInterface(I *i)
Templated function that throws an exception if the version if the interface implemented by the object...
const std::string & name() const
std::string typeName(const std::type_info &typ)
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).