Gaudi Framework, version v23r5

Home   Generated: Wed Nov 28 2012
 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:
Inheritance graph
[legend]
Collaboration diagram for AlgorithmManager:
Collaboration graph
[legend]

Classes

struct  AlgorithmItem
 

Public Types

typedef std::list< AlgorithmItemListAlg
 typedefs and classes
 
- 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::stringname () 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.
 
- 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::stringgetInterfaceNames () const
 Implementation of IInterface::getInterfaceNames.
 
virtual ~extends1 ()
 Virtual destructor.
 
- Public Member Functions inherited from ComponentManager
 ComponentManager (IInterface *application, const InterfaceID &baseIID)
 Constructor.
 
virtual const InterfaceIDcomponentBaseInterface () 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.
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream.
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts.
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS)
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL)
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING)
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO)
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG)
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE)
 
MsgStreammsg () 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()
 

Additional Inherited Members

- Static Public Member Functions inherited from IInterface
static const InterfaceIDinterfaceID ()
 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< IInterfacem_application
 Pointer to the owner of the manager.
 
SmartIF< IStatefulm_stateful
 Pointer to the IStateful interface of the owner.
 
InterfaceID m_basicInterfaceId
 Basic interface id of the managed components.
 
SmartIF< ISvcLocatorm_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 32 of file AlgorithmManager.h.

Member Typedef Documentation

typedefs and classes

Definition at line 49 of file AlgorithmManager.h.

Constructor & Destructor Documentation

AlgorithmManager::AlgorithmManager ( IInterface iface)

default creator

Definition at line 22 of file AlgorithmManager.cpp.

:
{
addRef(); // Initial count set to 1
}
AlgorithmManager::~AlgorithmManager ( )
virtual

virtual destructor

Definition at line 29 of file AlgorithmManager.cpp.

{
}

Member Function Documentation

StatusCode AlgorithmManager::addAlgorithm ( IAlgorithm alg)
virtual

implementation of IAlgManager::addAlgorithm

Implements IAlgManager.

Definition at line 33 of file AlgorithmManager.cpp.

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.

{
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
}
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;
}
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
rc = algorithm->sysInitialize();
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
if (! err.empty()) {
this->error() << err << endmsg;
}
this->error() << "More information may be available by setting the global jobOpt \"ReflexPluginDebugLevel\" to 1" << endmsg;
}
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.

{
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 123 of file AlgorithmManager.cpp.

{
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.

{
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
inlinevirtual

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.

{
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.

StatusCode AlgorithmManager::restart ( )
virtual

Initialization (from RUNNING to RUNNING, via INITIALIZED).

Reimplemented from ComponentManager.

Definition at line 194 of file AlgorithmManager.cpp.

{
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.

{
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.

{
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;
}

Member Data Documentation

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
mutableprivate

List of pointers to the know services used to implement getAlgorithms()

Definition at line 95 of file AlgorithmManager.h.


The documentation for this class was generated from the following files:
Generated at Wed Nov 28 2012 12:17:24 for Gaudi Framework, version v23r5 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004