Gaudi Framework, version v23r0 |
Home | Generated: Mon Jan 30 2012 |
The AlgorithmManager class is in charge of the creation of concrete instances of Algorithms. More...
#include <AlgorithmManager.h>
Classes | |
struct | AlgorithmItem |
Public Types | |
typedef std::list< AlgorithmItem > | ListAlg |
typedefs and classes | |
Public Member Functions | |
AlgorithmManager (IInterface *iface) | |
default creator | |
virtual | ~AlgorithmManager () |
virtual destructor | |
virtual StatusCode | addAlgorithm (IAlgorithm *alg) |
implementation of IAlgManager::addAlgorithm | |
virtual StatusCode | removeAlgorithm (IAlgorithm *alg) |
implementation of IAlgManager::removeAlgorithm | |
virtual StatusCode | createAlgorithm (const std::string &algtype, const std::string &algname, IAlgorithm *&algorithm, bool managed=false) |
implementation of IAlgManager::createAlgorithm | |
virtual bool | existsAlgorithm (const std::string &name) const |
implementation of IAlgManager::existsAlgorithm | |
virtual const std::list < IAlgorithm * > & | getAlgorithms () const |
implementation of IAlgManager::getAlgorithms | |
virtual StatusCode | initialize () |
Initialization (from CONFIGURED to INITIALIZED). | |
virtual StatusCode | start () |
Start (from INITIALIZED to RUNNING). | |
virtual StatusCode | stop () |
Stop (from RUNNING to INITIALIZED). | |
virtual StatusCode | finalize () |
Finalize (from INITIALIZED to CONFIGURED). | |
virtual StatusCode | reinitialize () |
Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED). | |
virtual StatusCode | restart () |
Initialization (from RUNNING to RUNNING, via INITIALIZED). | |
const std::string & | name () const |
Return the name of the manager (implementation of INamedInterface) | |
virtual SmartIF< IAlgorithm > & | algorithm (const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true) |
Returns a smart pointer to a service. | |
Private Attributes | |
ListAlg | m_listalg |
List of algorithms maintained by AlgorithmManager. | |
std::list< IAlgorithm * > | m_listOfPtrs |
List of pointers to the know services used to implement getAlgorithms() |
The AlgorithmManager class is in charge of the creation of concrete instances of Algorithms.
The ApplicationMgr delegates the creation and bookkeeping of algorithms to the algorithm factory. In order to be able to create algorithms from which it does not know the concrete type it requires that the algorithm has been declared in one of 3 possible ways: an abstract static creator function, a dynamic link library or an abstract factory reference.
Definition at line 32 of file AlgorithmManager.h.
typedefs and classes
Definition at line 49 of file AlgorithmManager.h.
AlgorithmManager::AlgorithmManager | ( | IInterface * | iface ) |
default creator
Definition at line 22 of file AlgorithmManager.cpp.
: base_class(application, IAlgorithm::interfaceID()) { addRef(); // Initial count set to 1 }
AlgorithmManager::~AlgorithmManager | ( | ) | [virtual] |
StatusCode AlgorithmManager::addAlgorithm | ( | IAlgorithm * | alg ) | [virtual] |
implementation of IAlgManager::addAlgorithm
Implements IAlgManager.
Definition at line 33 of file AlgorithmManager.cpp.
{ m_listalg.push_back(alg); return StatusCode::SUCCESS; }
SmartIF< IAlgorithm > & AlgorithmManager::algorithm | ( | const Gaudi::Utils::TypeNameString & | typeName, |
const bool | createIf = true |
||
) | [virtual] |
Returns a smart pointer to a service.
Implements IAlgManager.
Definition at line 102 of file AlgorithmManager.cpp.
{ ListAlg::iterator it = std::find(m_listalg.begin(), m_listalg.end(), typeName.name()); if (it != m_listalg.end()) { // found return it->algorithm; } if (createIf) { IAlgorithm* alg; if (createAlgorithm(typeName.type(), typeName.name(), alg, true).isSuccess()) { return algorithm(typeName, false); } } return no_algorithm; }
StatusCode AlgorithmManager::createAlgorithm | ( | const std::string & | algtype, |
const std::string & | algname, | ||
IAlgorithm *& | algorithm, | ||
bool | managed = false |
||
) | [virtual] |
implementation of IAlgManager::createAlgorithm
Implements IAlgManager.
Definition at line 49 of file AlgorithmManager.cpp.
{ // Check is the algorithm is already existing if( existsAlgorithm( algname ) ) { // return an error because an algorithm with that name already exists return StatusCode::FAILURE; } algorithm = PluginService::Create<IAlgorithm*>(algtype, algname, serviceLocator().get()); if ( !algorithm ) { algorithm = PluginService::CreateWithId<IAlgorithm*>(algtype, algname, serviceLocator().get()); } if ( algorithm ) { // Check the compatibility of the version of the interface obtained if( !isValidInterface(algorithm) ) { fatal() << "Incompatible interface IAlgorithm version for " << algtype << endmsg; return StatusCode::FAILURE; } StatusCode rc; m_listalg.push_back(AlgorithmItem(algorithm, managed)); // this is needed to keep the reference count correct, since isValidInterface(algorithm) // implies an increment of the counter by 1 algorithm->release(); if ( managed ) { // Bring the created algorithm to the same state of the ApplicationMgr if (FSMState() >= Gaudi::StateMachine::INITIALIZED) { rc = algorithm->sysInitialize(); if (rc.isSuccess() && FSMState() >= Gaudi::StateMachine::RUNNING) { rc = algorithm->sysStart(); } } if ( !rc.isSuccess() ) { this->error() << "Failed to initialize algorithm: [" << algname << "]" << endmsg; } } return rc; } this->error() << "Algorithm of type " << algtype << " is unknown (No factory available)." << endmsg; #ifndef _WIN32 errno = 0xAFFEDEAD; // code used by Gaudi for library load errors: forces getLastErrorString do use dlerror (on Linux) #endif std::string err = System::getLastErrorString(); if (! err.empty()) { this->error() << err << endmsg; } this->error() << "More information may be available by setting the global jobOpt \"ReflexPluginDebugLevel\" to 1" << endmsg; return StatusCode::FAILURE; }
bool AlgorithmManager::existsAlgorithm | ( | const std::string & | name ) | const [virtual] |
implementation of IAlgManager::existsAlgorithm
Implements IAlgManager.
Definition at line 117 of file AlgorithmManager.cpp.
StatusCode AlgorithmManager::finalize | ( | ) | [virtual] |
Finalize (from INITIALIZED to CONFIGURED).
Reimplemented from ComponentManager.
Definition at line 165 of file AlgorithmManager.cpp.
const std::list< IAlgorithm * > & AlgorithmManager::getAlgorithms | ( | ) | const [virtual] |
implementation of IAlgManager::getAlgorithms
Implements IAlgManager.
Definition at line 123 of file AlgorithmManager.cpp.
{ m_listOfPtrs.clear(); for (ListAlg::const_iterator it = m_listalg.begin(); it != m_listalg.end(); ++it) { m_listOfPtrs.push_back(const_cast<IAlgorithm*>(it->algorithm.get())); } return m_listOfPtrs; }
StatusCode AlgorithmManager::initialize | ( | ) | [virtual] |
Initialization (from CONFIGURED to INITIALIZED).
Reimplemented from ComponentManager.
Definition at line 132 of file AlgorithmManager.cpp.
{ StatusCode rc; ListAlg::iterator it; for (it = m_listalg.begin(); it != m_listalg.end(); ++it) { if (!it->managed) continue; rc = it->algorithm->sysInitialize(); if ( rc.isFailure() ) return rc; } return rc; }
const std::string& AlgorithmManager::name | ( | ) | const [inline, virtual] |
Return the name of the manager (implementation of INamedInterface)
Implements CommonMessaging< implements1< IComponentManager > >.
Definition at line 84 of file AlgorithmManager.h.
{ static std::string _name = "AlgorithmManager"; return _name; }
StatusCode AlgorithmManager::reinitialize | ( | ) | [virtual] |
Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED).
Reimplemented from ComponentManager.
Definition at line 180 of file AlgorithmManager.cpp.
{ StatusCode rc; ListAlg::iterator it; for (it = m_listalg.begin(); it != m_listalg.end(); ++it) { if (!it->managed) continue; rc = it->algorithm->sysReinitialize(); if( rc.isFailure() ){ this->error() << "Unable to re-initialize algorithm: " << it->algorithm->name() << endmsg; return rc; } } return rc; }
StatusCode AlgorithmManager::removeAlgorithm | ( | IAlgorithm * | alg ) | [virtual] |
implementation of IAlgManager::removeAlgorithm
Implements IAlgManager.
Definition at line 39 of file AlgorithmManager.cpp.
{ ListAlg::iterator it = std::find(m_listalg.begin(), m_listalg.end(), alg); if (it != m_listalg.end()) { m_listalg.erase(it); return StatusCode::SUCCESS; } return StatusCode::FAILURE; }
StatusCode AlgorithmManager::restart | ( | ) | [virtual] |
Initialization (from RUNNING to RUNNING, via INITIALIZED).
Reimplemented from ComponentManager.
Definition at line 194 of file AlgorithmManager.cpp.
{ StatusCode rc; ListAlg::iterator it; for (it = m_listalg.begin(); it != m_listalg.end(); ++it) { if (!it->managed) continue; rc = it->algorithm->sysRestart(); if( rc.isFailure() ){ this->error() << "Unable to re-initialize algorithm: " << it->algorithm->name() << endmsg; return rc; } } return rc; }
StatusCode AlgorithmManager::start | ( | ) | [virtual] |
Start (from INITIALIZED to RUNNING).
Reimplemented from ComponentManager.
Definition at line 143 of file AlgorithmManager.cpp.
{ StatusCode rc; ListAlg::iterator it; for (it = m_listalg.begin(); it != m_listalg.end(); ++it) { if (!it->managed) continue; rc = it->algorithm->sysStart(); if ( rc.isFailure() ) return rc; } return rc; }
StatusCode AlgorithmManager::stop | ( | ) | [virtual] |
Stop (from RUNNING to INITIALIZED).
Reimplemented from ComponentManager.
Definition at line 154 of file AlgorithmManager.cpp.
{ StatusCode rc; ListAlg::iterator it; for (it = m_listalg.begin(); it != m_listalg.end(); ++it) { if (!it->managed) continue; rc = it->algorithm->sysStop(); if ( rc.isFailure() ) return rc; } return rc; }
ListAlg AlgorithmManager::m_listalg [private] |
List of algorithms maintained by AlgorithmManager.
Definition at line 92 of file AlgorithmManager.h.
std::list<IAlgorithm*> AlgorithmManager::m_listOfPtrs [mutable, private] |
List of pointers to the know services used to implement getAlgorithms()
Definition at line 95 of file AlgorithmManager.h.