![]() |
|
|
Generated: 18 Jul 2008 |
#include <AlgorithmManager.h>
Inheritance diagram for AlgorithmManager:


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 31 of file AlgorithmManager.h.
| typedef std::list<IAlgorithm*> AlgorithmManager::ListAlg |
| AlgorithmManager::AlgorithmManager | ( | IInterface * | iface | ) |
default creator
Definition at line 15 of file AlgorithmManager.cpp.
References StatusCode::ignore(), IID_ISvcLocator, m_listalg, m_listmgralg, m_msgsvc, m_pOuter, m_refcount, m_svclocator, and IInterface::queryInterface().
00015 : 00016 m_statemgr(iface) 00017 { 00018 m_pOuter = iface; 00019 m_pOuter->queryInterface(IID_ISvcLocator, pp_cast<void>(&m_svclocator)).ignore(); 00020 m_msgsvc = 0; 00021 m_refcount = 1; 00022 m_listalg = new ListAlg(); 00023 m_listmgralg = new ListAlg(); 00024 }
| AlgorithmManager::~AlgorithmManager | ( | ) | [virtual] |
virtual destructor
Definition at line 27 of file AlgorithmManager.cpp.
References m_listalg, m_listmgralg, m_msgsvc, m_svclocator, and IInterface::release().
00027 { 00028 delete m_listalg; 00029 delete m_listmgralg; 00030 if( m_msgsvc ) m_msgsvc->release(); 00031 if( m_svclocator ) m_svclocator->release(); 00032 }
| unsigned long AlgorithmManager::addRef | ( | ) | [virtual] |
implmentation of IInterface::addRef
Implements IInterface.
Definition at line 35 of file AlgorithmManager.cpp.
References m_refcount.
Referenced by queryInterface().
00035 { 00036 m_refcount++; 00037 return m_refcount; 00038 }
| unsigned long AlgorithmManager::release | ( | ) | [virtual] |
implmentation of IInterface::release
Implements IInterface.
Definition at line 41 of file AlgorithmManager.cpp.
References count(), and m_refcount.
Referenced by ApplicationMgr::~ApplicationMgr().
00041 { 00042 unsigned long count = --m_refcount; 00043 if( count <= 0) { 00044 delete this; 00045 } 00046 return count; 00047 }
| StatusCode AlgorithmManager::queryInterface | ( | const InterfaceID & | iid, | |
| void ** | pinterface | |||
| ) | [virtual] |
implementation of IInterface::queryInterface
Implements IInterface.
Definition at line 50 of file AlgorithmManager.cpp.
References addRef(), IID_IAlgManager, IID_IInterface, m_pOuter, IInterface::queryInterface(), and StatusCode::SUCCESS.
00050 { 00051 if( iid == IID_IInterface ) { 00052 *pinterface = (IInterface*)this; 00053 addRef(); 00054 return StatusCode::SUCCESS; 00055 } 00056 else if ( iid == IID_IAlgManager ) { 00057 *pinterface = (IAlgManager*)this; 00058 addRef(); 00059 return StatusCode::SUCCESS; 00060 } 00061 else { 00062 return m_pOuter->queryInterface(iid, pinterface); 00063 } 00064 return StatusCode::SUCCESS; 00065 }
| StatusCode AlgorithmManager::addAlgorithm | ( | IAlgorithm * | alg | ) | [virtual] |
implementation of IAlgManager::addAlgorithm
Implements IAlgManager.
Definition at line 68 of file AlgorithmManager.cpp.
References m_listalg, std::list< _Tp, _Alloc >::push_back(), and StatusCode::SUCCESS.
00068 { 00069 m_listalg->push_back( alg ); 00070 return StatusCode::SUCCESS; 00071 }
| StatusCode AlgorithmManager::removeAlgorithm | ( | IAlgorithm * | alg | ) | [virtual] |
implementation of IAlgManager::removeAlgorithm
Implements IAlgManager.
Definition at line 74 of file AlgorithmManager.cpp.
References std::list< _Tp, _Alloc >::begin(), std::list< _Tp, _Alloc >::end(), std::list< _Tp, _Alloc >::erase(), m_listalg, and StatusCode::SUCCESS.
00074 { 00075 ListAlg::iterator it; 00076 for (it = m_listalg->begin(); it != m_listalg->end(); it++ ) { 00077 if( *it == alg ) { 00078 m_listalg->erase(it); 00079 break; 00080 } 00081 } 00082 return StatusCode::SUCCESS; 00083 }
| 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 86 of file AlgorithmManager.cpp.
References IInterface::addRef(), endmsg(), endreq(), MSG::ERROR, existsAlgorithm(), StatusCode::FAILURE, MSG::FATAL, Gaudi::StateMachine::INITIALIZED, StatusCode::isSuccess(), isValidInterface(), m_listalg, m_listmgralg, m_statemgr, m_svclocator, msgSvc(), std::list< _Tp, _Alloc >::push_back(), Gaudi::StateMachine::RUNNING, IAlgorithm::sysInitialize(), and IAlgorithm::sysStart().
00090 { 00091 MsgStream log(msgSvc(), "AlgorithmManager"); 00092 // Check is the algorithm is already existing 00093 if( existsAlgorithm( algname ) ) { 00094 // return an error because an algorithm with that name already exists 00095 return StatusCode::FAILURE; 00096 } 00097 algorithm = PluginService::Create<IAlgorithm*>(algtype, algname, m_svclocator); 00098 if ( algorithm ) { 00099 // Check the compatibility of the version of the interface obtained 00100 if( !isValidInterface(algorithm) ) { 00101 log << MSG::FATAL << "Incompatible interface IAlgorithm version for " << algtype << endreq; 00102 return StatusCode::FAILURE; 00103 } 00104 StatusCode rc; 00105 m_listalg->push_back( algorithm ); 00106 if ( managed ) { 00107 algorithm->addRef(); 00108 m_listmgralg->push_back( algorithm ); 00109 00110 // Bring the created service to the same state of the ApplicationMgr 00111 if (m_statemgr->FSMState() >= Gaudi::StateMachine::INITIALIZED) { 00112 rc = algorithm->sysInitialize(); 00113 if (rc.isSuccess() && m_statemgr->FSMState() >= Gaudi::StateMachine::RUNNING) { 00114 rc = algorithm->sysStart(); 00115 } 00116 } 00117 if ( !rc.isSuccess() ) { 00118 log << MSG::ERROR << "Failed to initialize algorithm: " 00119 << "[" << algname << "]" << endmsg; 00120 } 00121 } 00122 return rc; 00123 } 00124 log << MSG::ERROR << "Algorithm of type " << algtype 00125 << " is unknown (No factory available)." << endmsg; 00126 return StatusCode::FAILURE; 00127 }
| StatusCode AlgorithmManager::getAlgorithm | ( | const std::string & | name, | |
| IAlgorithm *& | alg | |||
| ) | const [virtual] |
implementation of IAlgManager::getAlgorithm
Implements IAlgManager.
Definition at line 130 of file AlgorithmManager.cpp.
References std::list< _Tp, _Alloc >::begin(), std::list< _Tp, _Alloc >::end(), StatusCode::FAILURE, m_listalg, name, and StatusCode::SUCCESS.
00130 { 00131 ListAlg::const_iterator it; 00132 for (it = m_listalg->begin(); it != m_listalg->end(); it++ ) { 00133 if( (*it)->name() == name ) { 00134 alg = *it; 00135 return StatusCode::SUCCESS; 00136 } 00137 } 00138 return StatusCode::FAILURE; 00139 }
| bool AlgorithmManager::existsAlgorithm | ( | const std::string & | name | ) | const [virtual] |
implementation of IAlgManager::existsAlgorithm
Implements IAlgManager.
Definition at line 142 of file AlgorithmManager.cpp.
References std::list< _Tp, _Alloc >::begin(), std::list< _Tp, _Alloc >::end(), m_listalg, and name.
Referenced by createAlgorithm().
00142 { 00143 ListAlg::const_iterator it; 00144 for (it = m_listalg->begin(); it != m_listalg->end(); it++ ) { 00145 if( (*it)->name() == name ) { 00146 return true; 00147 } 00148 } 00149 return false; 00150 }
| std::list< IAlgorithm * > & AlgorithmManager::getAlgorithms | ( | ) | const [virtual] |
implementation of IAlgManager::getAlgorithms
Implements IAlgManager.
Definition at line 153 of file AlgorithmManager.cpp.
References m_listalg.
00154 { 00155 return *m_listalg; 00156 }
| StatusCode AlgorithmManager::initializeAlgorithms | ( | ) | [virtual] |
implementation of IAlgManager::initializeAlgorithms
Implements IAlgManager.
Definition at line 158 of file AlgorithmManager.cpp.
References std::list< _Tp, _Alloc >::begin(), std::list< _Tp, _Alloc >::end(), StatusCode::isFailure(), and m_listmgralg.
00158 { 00159 StatusCode rc; 00160 ListAlg::const_iterator it; 00161 for (it = m_listmgralg->begin(); it != m_listmgralg->end(); it++ ) { 00162 rc = (*it)->sysInitialize(); 00163 if ( rc.isFailure() ) return rc; 00164 } 00165 return rc; 00166 }
| StatusCode AlgorithmManager::startAlgorithms | ( | ) | [virtual] |
implementation of IAlgManager::startAlgorithms
Implements IAlgManager.
Definition at line 168 of file AlgorithmManager.cpp.
References std::list< _Tp, _Alloc >::begin(), std::list< _Tp, _Alloc >::end(), StatusCode::isFailure(), and m_listmgralg.
00168 { 00169 StatusCode rc; 00170 ListAlg::const_iterator it; 00171 for (it = m_listmgralg->begin(); it != m_listmgralg->end(); it++ ) { 00172 rc = (*it)->sysStart(); 00173 if ( rc.isFailure() ) return rc; 00174 } 00175 return rc; 00176 }
| StatusCode AlgorithmManager::stopAlgorithms | ( | ) | [virtual] |
implementation of IAlgManager::stopAlgorithms
Implements IAlgManager.
Definition at line 178 of file AlgorithmManager.cpp.
References std::list< _Tp, _Alloc >::begin(), std::list< _Tp, _Alloc >::end(), StatusCode::isFailure(), and m_listmgralg.
Referenced by ApplicationMgr::stop().
00178 { 00179 StatusCode rc; 00180 ListAlg::const_iterator it; 00181 for (it = m_listmgralg->begin(); it != m_listmgralg->end(); it++ ) { 00182 rc = (*it)->sysStop(); 00183 if ( rc.isFailure() ) return rc; 00184 } 00185 return rc; 00186 }
| StatusCode AlgorithmManager::finalizeAlgorithms | ( | ) | [virtual] |
implementation of IAlgManager::finalizeAlgorithms
Implements IAlgManager.
Definition at line 188 of file AlgorithmManager.cpp.
References std::list< _Tp, _Alloc >::begin(), std::list< _Tp, _Alloc >::clear(), std::list< _Tp, _Alloc >::end(), StatusCode::isFailure(), and m_listmgralg.
Referenced by ApplicationMgr::finalize().
00188 { 00189 StatusCode rc; 00190 ListAlg::const_iterator it; 00191 for (it = m_listmgralg->begin(); it != m_listmgralg->end(); it++ ) { 00192 rc = (*it)->sysFinalize(); 00193 if( rc.isFailure() ) return rc; 00194 (*it)->release(); 00195 } 00196 m_listmgralg->clear(); 00197 return rc; 00198 }
| StatusCode AlgorithmManager::reinitializeAlgorithms | ( | ) | [virtual] |
implementation of IAlgManager::initializeAlgorithms
Implements IAlgManager.
Definition at line 200 of file AlgorithmManager.cpp.
References std::list< _Tp, _Alloc >::begin(), std::list< _Tp, _Alloc >::end(), endreq(), MSG::ERROR, StatusCode::isFailure(), m_listmgralg, and msgSvc().
Referenced by ApplicationMgr::reinitialize().
00200 { 00201 StatusCode rc; 00202 ListAlg::const_iterator it; 00203 for (it = m_listmgralg->begin(); it != m_listmgralg->end(); it++ ) { 00204 rc = (*it)->sysReinitialize(); 00205 if( rc.isFailure() ){ 00206 MsgStream log(msgSvc(), "AlgorithmManager"); 00207 log << MSG::ERROR << "Unable to re-initialize Service: " << (*it)->name() << endreq; 00208 return rc; 00209 } 00210 } 00211 return rc; 00212 }
| StatusCode AlgorithmManager::restartAlgorithms | ( | ) | [virtual] |
implementation of IAlgManager::startAlgorithms
Implements IAlgManager.
Definition at line 214 of file AlgorithmManager.cpp.
References std::list< _Tp, _Alloc >::begin(), std::list< _Tp, _Alloc >::end(), endreq(), MSG::ERROR, StatusCode::isFailure(), m_listmgralg, and msgSvc().
Referenced by ApplicationMgr::restart().
00214 { 00215 StatusCode rc; 00216 ListAlg::const_iterator it; 00217 for (it = m_listmgralg->begin(); it != m_listmgralg->end(); it++ ) { 00218 rc = (*it)->sysRestart(); 00219 if( rc.isFailure() ){ 00220 MsgStream log(msgSvc(), "AlgorithmManager"); 00221 log << MSG::ERROR << "Unable to re-initialize Service: " << (*it)->name() << endreq; 00222 return rc; 00223 } 00224 } 00225 return rc; 00226 }
| IMessageSvc * AlgorithmManager::msgSvc | ( | ) | [private] |
Definition at line 229 of file AlgorithmManager.cpp.
References ISvcLocator::getService(), StatusCode::ignore(), IID_IMessageSvc, m_msgsvc, and m_svclocator.
Referenced by createAlgorithm(), reinitializeAlgorithms(), and restartAlgorithms().
00229 { 00230 // Access the message service if not yet done already 00231 if( m_msgsvc == 0 ) { 00232 m_svclocator->getService( "MessageSvc", IID_IMessageSvc, 00233 *pp_cast<IInterface>(&m_msgsvc) ).ignore(); 00234 } 00235 return m_msgsvc; 00236 }
IInterface* AlgorithmManager::m_pOuter [private] |
Interface hub reference (ApplicationMgr).
Definition at line 78 of file AlgorithmManager.h.
Referenced by AlgorithmManager(), and queryInterface().
unsigned long AlgorithmManager::m_refcount [private] |
Reference counter.
Definition at line 79 of file AlgorithmManager.h.
Referenced by addRef(), AlgorithmManager(), and release().
ListAlg* AlgorithmManager::m_listalg [private] |
List of algorithms maintained by AlgorithmManager.
Definition at line 80 of file AlgorithmManager.h.
Referenced by addAlgorithm(), AlgorithmManager(), createAlgorithm(), existsAlgorithm(), getAlgorithm(), getAlgorithms(), removeAlgorithm(), and ~AlgorithmManager().
ListAlg* AlgorithmManager::m_listmgralg [private] |
List of managed algorithms maintained by AlgorithmManager.
Definition at line 81 of file AlgorithmManager.h.
Referenced by AlgorithmManager(), createAlgorithm(), finalizeAlgorithms(), initializeAlgorithms(), reinitializeAlgorithms(), restartAlgorithms(), startAlgorithms(), stopAlgorithms(), and ~AlgorithmManager().
ISvcLocator* AlgorithmManager::m_svclocator [private] |
Service locator reference.
Definition at line 82 of file AlgorithmManager.h.
Referenced by AlgorithmManager(), createAlgorithm(), msgSvc(), and ~AlgorithmManager().
IMessageSvc* AlgorithmManager::m_msgsvc [private] |
Pointer to the message service if it exists.
Definition at line 83 of file AlgorithmManager.h.
Referenced by AlgorithmManager(), msgSvc(), and ~AlgorithmManager().
SmartIF<IStateful> AlgorithmManager::m_statemgr [private] |
Pointer to the state machine.
Definition at line 84 of file AlgorithmManager.h.
Referenced by createAlgorithm().