36 auto it = std::find(
m_algs.begin(),
m_algs.end(), alg );
39 auto range =
m_algsMap.equal_range( alg->name() );
40 auto itm = std::find_if( range.first, range.second, [&](
auto const& p ) { return p.second == alg; } );
51 if ( checkIfExists ) {
57 std::string actualalgtype( algtype );
59 if ( ( actualalgtype.size() > 8 ) && ( actualalgtype.compare( 0, 8,
"unalias:" ) == 0 ) ) {
60 actualalgtype = actualalgtype.substr( 8 );
63 if ( typeAlias !=
m_algTypeAliases.end() ) { actualalgtype = typeAlias->second; }
67 this->
error() <<
"Algorithm of type " << actualalgtype <<
" is unknown (No factory available)." <<
endmsg;
72 this->
error() <<
"More information may be available by setting the global jobOpt \"PluginDebugLevel\" to 1"
78 fatal() <<
"Incompatible interface IAlgorithm version for " << actualalgtype <<
endmsg;
84 algorithm->setType( std::move( actualalgtype ) );
95 if ( !rc.isSuccess() ) { this->
error() <<
"Failed to initialize algorithm: [" << algname <<
"]" <<
endmsg; }
101 auto it =
m_algsMap.find( typeName.name() );
119 std::vector<IAlgorithm*> listOfPtrs;
120 listOfPtrs.reserve(
m_algs.size() );
121 std::transform( std::begin(
m_algs ), std::end(
m_algs ), std::back_inserter( listOfPtrs ),
128 for (
auto& it :
m_algs ) {
130 rc = it.algorithm->sysInitialize();
131 if ( rc.isFailure() )
return rc;
138 for (
auto& it :
m_algs ) {
140 rc = it.algorithm->sysStart();
141 if ( rc.isFailure() )
return rc;
148 for (
auto& it :
m_algs ) {
149 if ( !it.managed )
continue;
150 rc = it.algorithm->sysStop();
151 if ( rc.isFailure() )
return rc;
159 while ( it !=
m_algs.end() ) {
161 auto range =
m_algsMap.equal_range( it->algorithm->name() );
162 auto itm = std::find_if( range.first, range.second, [&](
auto const& p ) { return p.second == it->algorithm; } );
165 rc = it->algorithm->sysFinalize();
166 if ( rc.isFailure() )
return rc;
179 for (
auto& it :
m_algs ) {
180 if ( !it.managed )
continue;
181 rc = it.algorithm->sysReinitialize();
182 if ( rc.isFailure() ) {
183 this->
error() <<
"Unable to re-initialize algorithm: " << it.algorithm->name() <<
endmsg;
194 fatal() <<
"Error retrieving AlgExecStateSvc" <<
endmsg;
200 for (
auto& it :
m_algs ) {
201 if ( !it.managed )
continue;
202 rc = it.algorithm->sysRestart();
203 m_aess->resetErrorCount( it.algorithm );
204 if ( rc.isFailure() ) {
205 this->
error() <<
"Unable to re-initialize algorithm: " << it.algorithm->name() <<
endmsg;
214 for (
auto& algItem :
m_algs ) {
216 if ( alg ) alg->resetMessaging();
bool isValidInterface(IFace *i)
Templated function that throws an exception if the version if the interface implemented by the object...
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
SmartIF< IAlgorithm > & algorithm(const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true) override
AlgorithmManager(IInterface *iface)
default creator
std::vector< IAlgorithm * > getAlgorithms() const override
implementation of IAlgManager::getAlgorithms
AlgTypeAliasesMap m_algTypeAliases
StatusCode start() override
Start (from INITIALIZED to RUNNING).
StatusCode finalize() override
Finalize (from INITIALIZED to CONFIGURED).
StatusCode stop() override
Stop (from RUNNING to INITIALIZED).
StatusCode addAlgorithm(IAlgorithm *alg) override
implementation of IAlgManager::addAlgorithm
bool existsAlgorithm(std::string_view name) const override
implementation of IAlgManager::existsAlgorithm
std::vector< AlgorithmItem > m_algs
algorithms maintained by AlgorithmManager
StatusCode removeAlgorithm(IAlgorithm *alg) override
implementation of IAlgManager::removeAlgorithm
StatusCode reinitialize() override
Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED).
StatusCode createAlgorithm(const std::string &algtype, const std::string &algname, IAlgorithm *&algorithm, bool managed=false, bool checkIfExists=true) override
implementation of IAlgManager::createAlgorithm
StatusCode initialize() override
Initialization (from CONFIGURED to INITIALIZED).
StatusCode restart() override
Initialization (from RUNNING to RUNNING, via INITIALIZED).
std::unordered_multimap< std::string, SmartIF< IAlgorithm > > m_algsMap
algorithms maintained by AlgorithmManager
const std::string & name() const override
Return the name of the manager (implementation of INamedInterface)
void outputLevelUpdate() override
Function to call to update the outputLevel of the components (after a change in MessageSvc).
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
MsgStream & err() const
shortcut for the method msgStream(MSG::ERROR)
MSG::Level resetMessaging()
Gaudi::StateMachine::State targetFSMState() const override
When we are in the middle of a transition, get the state where the transition is leading us.
SmartIF< ISvcLocator > & serviceLocator() const override
Base class from which all concrete algorithm classes should be derived.
Helper class to parse a string of format "type/name".
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition of the basic interface.
virtual SmartIF< IService > & service(const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true)=0
Returns a smart pointer to a service.
Small smart pointer class with automatic reference counting for IInterface.
bool isValid() const
Allow for check if smart pointer is valid.
This class is used for returning status codes from appropriate routines.
constexpr static const auto SUCCESS
constexpr static const auto FAILURE
GAUDI_API const std::string getLastErrorString()
Get last system error as string.
static const InterfaceID & interfaceID()