| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Private Attributes | List of all members
AlgorithmManager Class Reference

The AlgorithmManager class is in charge of the creation of concrete instances of Algorithms. More...

`#include <AlgorithmManager.h>`

Inheritance diagram for AlgorithmManager:
[legend]
Collaboration diagram for AlgorithmManager:
[legend]

## Classes
struct | AlgorithmItem

## Public Types
typedef std::list< AlgorithmItem > | ListAlg
| typedefs and classes
typedef std::map< std::string, std::string > | AlgTypeAliasesMap
Public Types inherited from extends1< ComponentManager, IAlgManager >
typedef extends1 | base_class
| Typedef to this class.
typedef extend_interfaces1 < IAlgManager > | extend_interfaces_base
| Typedef to the base of this class.
typedef extend_interfaces_base::ext_iids | interfaces
| MPL set of all the implemented interfaces.
Public Types inherited from extend_interfaces1< IAlgManager >
typedef IAlgManager::iid::iids::type | ext_iids
| MPL set of interfaces extended by this one.

## 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.
AlgTypeAliasesMap & | typeAliases ()
const AlgTypeAliasesMap & | typeAliases () const
Public Member Functions inherited from extends1< ComponentManager, IAlgManager >
| extends1 (A1 a1, A2 a2, A3 a3)
| Templated constructor with 3 arguments.
| extends1 (A1 a1, A2 a2)
| Templated constructor with 2 arguments.
| extends1 (A1 a1)
| Templated constructor with 1 argument.
| extends1 ()
| Default constructor.
virtual void * | i_cast (const InterfaceID &tid) const
| Implementation of IInterface::i_cast.
virtual StatusCode | queryInterface (const InterfaceID &ti, void **pp)
| Implementation of IInterface::queryInterface.
virtual std::vector< std::string > | getInterfaceNames () const
| Implementation of IInterface::getInterfaceNames.
virtual | ~extends1 ()
| Virtual destructor.
Public Member Functions inherited from ComponentManager
| ComponentManager (IInterface *application, const InterfaceID &baseIID)
| Constructor.
virtual const InterfaceID & | componentBaseInterface () const
| Basic interface id of the managed components.
virtual | ~ComponentManager ()
| Virtual destructor.
virtual SmartIF< ISvcLocator > & | serviceLocator () const
| Needed to locate the message service.
virtual StatusCode | configure ()
| Configuration (from OFFLINE to CONFIGURED).
virtual StatusCode | terminate ()
| Initialization (from CONFIGURED to OFFLINE).
virtual Gaudi::StateMachine::State | FSMState () const
| Get the current state.
virtual Gaudi::StateMachine::State | targetFSMState () const
| When we are in the middle of a transition, get the state where the transition is leading us.
Public Member Functions inherited from CommonMessaging< implements1< IComponentManager > >
| CommonMessaging (const A1 &a1, const A2 &a2, const A3 &a3)
| Templated constructor with 3 arguments.
| CommonMessaging (const A1 &a1, const A2 &a2)
| Templated constructor with 2 arguments.
| CommonMessaging (const A1 &a1)
| Templated constructor with 1 argument.
| CommonMessaging ()
| Default constructor.
virtual | ~CommonMessaging ()
| Virtual destructor.
SmartIF< IMessageSvc > & | msgSvc () const
| The standard message service.
MsgStream & | msgStream () const
| Return an uninitialized MsgStream.
MsgStream & | msgStream (const MSG::Level level) const
| Predefined configurable message stream for the efficient printouts.
MsgStream & | always () const
| shortcut for the method msgStream(MSG::ALWAYS)
MsgStream & | fatal () const
| shortcut for the method msgStream(MSG::FATAL)
MsgStream & | err () const
| shortcut for the method msgStream(MSG::ERROR)
MsgStream & | error () const
| shortcut for the method msgStream(MSG::ERROR)
MsgStream & | warning () const
| shortcut for the method msgStream(MSG::WARNING)
MsgStream & | info () const
| shortcut for the method msgStream(MSG::INFO)
MsgStream & | debug () const
| shortcut for the method msgStream(MSG::DEBUG)
MsgStream & | verbose () const
| shortcut for the method msgStream(MSG::VERBOSE)
MsgStream & | msg () const
| shortcut for the method msgStream(MSG::INFO)
MSG::Level | msgLevel () const
| get the output level from the embedded MsgStream
bool | msgLevel (MSG::Level lvl) const
| get the output level from the embedded MsgStream
Public Member Functions inherited from extend_interfaces1< IAlgManager >
virtual | ~extend_interfaces1 ()
| Virtual destructor.
Public Member Functions inherited from IAlgManager
| DeclareInterfaceID (IAlgManager, 5, 0)
| InterfaceID.
virtual StatusCode | getAlgorithm (const std::string &name, IAlgorithm *&alg) const
| Find an algorithm with given name in the list of known algorithms.
virtual StatusCode | initializeAlgorithms ()
| Initializes the list of "managed" algorithms.
virtual StatusCode | startAlgorithms ()
| Starts the list of "managed" algorithms.
virtual StatusCode | stopAlgorithms ()
| Stops the list of "managed" algorithms.
virtual StatusCode | finalizeAlgorithms ()
| Finalizes the list of "managed" algorithms.
virtual StatusCode | reinitializeAlgorithms ()
| Initializes the list of "managed" algorithms.
virtual StatusCode | restartAlgorithms ()
| Starts the list of "managed" algorithms.
template<typename T >
SmartIF< T > | algorithm (const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true)
| Returns a smart pointer to the requested interface of a service.
Public Member Functions inherited from IComponentManager
| DeclareInterfaceID (IComponentManager, 1, 0)
| InterfaceID.
virtual | ~IComponentManager ()
| Virtual destructor.
Public Member Functions inherited from IStateful
| DeclareInterfaceID (IStateful, 1, 0)
| InterfaceID.
virtual | ~IStateful ()
Public Member Functions inherited from IInterface
virtual unsigned long | addRef ()=0
| Increment the reference count of Interface instance.
virtual unsigned long | release ()=0
| Release Interface instance.
virtual unsigned long | refCount () const =0
| Current reference count.
virtual | ~IInterface ()
| Virtual destructor.

## 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()
AlgTypeAliasesMap | m_algTypeAliases

## Additional Inherited Members
Static Public Member Functions inherited from IInterface
static const InterfaceID & | interfaceID ()
| Return an instance of InterfaceID identifying the interface.
Protected Member Functions inherited from CommonMessaging< implements1< IComponentManager > >
void | updateMsgStreamOutputLevel (int level)
| Update the output level of the cached MsgStream.
Protected Attributes inherited from ComponentManager
SmartIF< IInterface > | m_application
| Pointer to the owner of the manager.
SmartIF< IStateful > | m_stateful
| Pointer to the IStateful interface of the owner.
InterfaceID | m_basicInterfaceId
| Basic interface id of the managed components.
SmartIF< ISvcLocator > | m_svcLocator
| Service locator (needed to access the MessageSvc)

## Detailed Description

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.

Author
  Pere Mato

Definition at line 31 of file AlgorithmManager.h.

## Member Typedef Documentation

typedef std::map<std::string, std::string> AlgorithmManager::AlgTypeAliasesMap

Definition at line 49 of file AlgorithmManager.h.

typedef std::list<AlgorithmItem> AlgorithmManager::ListAlg

typedefs and classes

Definition at line 48 of file AlgorithmManager.h.

## Constructor & Destructor Documentation

AlgorithmManager::AlgorithmManager | ( | IInterface * | iface | ) |

default creator

Definition at line 18 of file AlgorithmManager.cpp.

:
base_class(application, IAlgorithm::interfaceID())
{
addRef(); // Initial count set to 1
}

AlgorithmManager::~AlgorithmManager | ( |  | ) |
| virtual

virtual destructor

Definition at line 25 of file AlgorithmManager.cpp.

{
}

## Member Function Documentation

StatusCode AlgorithmManager::addAlgorithm | ( | IAlgorithm * | alg | ) |
| virtual

implementation of IAlgManager::addAlgorithm

Implements IAlgManager.

Definition at line 29 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 105 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 45 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;
}
std::string actualalgtype(algtype);
// a '\' in front of the type name prevents alias replacement
if ((actualalgtype.size() > 8) && (actualalgtype.substr(0, 8) == "unalias:")) {
actualalgtype = actualalgtype.substr(8);
} else {
AlgTypeAliasesMap::iterator typeAlias = m_algTypeAliases.find(algtype);
if (typeAlias != m_algTypeAliases.end()) {
actualalgtype = typeAlias->second;
}
}
algorithm = Algorithm::Factory::create(actualalgtype, algname, serviceLocator().get());
if ( algorithm ) {
// Check the compatibility of the version of the interface obtained
if( !isValidInterface(algorithm) ) {
fatal() << "Incompatible interface IAlgorithm version for " << actualalgtype << 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 " << actualalgtype
<< " 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 \"PluginDebugLevel\" to 1" << endmsg;
return StatusCode::FAILURE;
}

bool AlgorithmManager::existsAlgorithm | ( | const std::string & | name | ) | const
| virtual

implementation of IAlgManager::existsAlgorithm

Implements IAlgManager.

Definition at line 120 of file AlgorithmManager.cpp.

{
ListAlg::const_iterator it = std::find(m_listalg.begin(), m_listalg.end(), name);
return it != m_listalg.end();
}

StatusCode AlgorithmManager::finalize | ( |  | ) |
| virtual

Finalize (from INITIALIZED to CONFIGURED).

Reimplemented from ComponentManager.

Definition at line 168 of file AlgorithmManager.cpp.

{
StatusCode rc;
ListAlg::iterator it = m_listalg.begin();
while (it != m_listalg.end()){ // finalize and remove from the list the managed algorithms
if (it->managed) {
rc = it->algorithm->sysFinalize();
if( rc.isFailure() ) return rc;
it = m_listalg.erase(it);
} else {
++it;
}
}
return rc;
}

const std::list< IAlgorithm * > & AlgorithmManager::getAlgorithms | ( |  | ) | const
| virtual

implementation of IAlgManager::getAlgorithms

Implements IAlgManager.

Definition at line 126 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 135 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 183 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 35 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 197 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 146 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 157 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;
}

AlgTypeAliasesMap& AlgorithmManager::typeAliases | ( |  | ) |
| inline

Definition at line 91 of file AlgorithmManager.h.

{ return m_algTypeAliases; }

const AlgTypeAliasesMap& AlgorithmManager::typeAliases | ( |  | ) | const
| inline

Definition at line 92 of file AlgorithmManager.h.

{ return m_algTypeAliases; }

## Member Data Documentation

AlgTypeAliasesMap AlgorithmManager::m_algTypeAliases
| private

Definition at line 100 of file AlgorithmManager.h.

ListAlg AlgorithmManager::m_listalg
| private

List of algorithms maintained by AlgorithmManager.

Definition at line 95 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 98 of file AlgorithmManager.h.

The documentation for this class was generated from the following files:

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v25r0/GaudiCoreSvc/src/ApplicationMgr/AlgorithmManager.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v25r0/GaudiCoreSvc/src/ApplicationMgr/AlgorithmManager.cpp