| # Gaudi Framework, version v20r4
Generated: 8 Jan 2009

# MinimalEventLoopMgr.cpp

Go to the documentation of this file.

    00001 // $Id: MinimalEventLoopMgr.cpp,v 1.7 2008/07/15 12:48:18 marcocle Exp $
    00002 #define  GAUDIKERNEL_MINIMALEVENTLOOPMGR_CPP
    00003
    00004 #include "GaudiKernel/SmartIF.h"
    00005 #include "GaudiKernel/MsgStream.h"
    00006 #include "GaudiKernel/IAlgorithm.h"
    00007 #include "GaudiKernel/IAlgManager.h"
    00008 #include "GaudiKernel/ListItem.h"
    00009 #include "GaudiKernel/GaudiException.h"
    00010 #include "GaudiKernel/ThreadGaudi.h"
    00011 #include "GaudiKernel/Incident.h"
    00012 #include "GaudiKernel/IIncidentListener.h"
    00013 #include "GaudiKernel/IIncidentSvc.h"
    00014
    00015 #include "GaudiKernel/MinimalEventLoopMgr.h"
    00016
    00017 namespace {
    00018   class AbortEventListener: public IIncidentListener {
    00019   public:
    00020     AbortEventListener(bool &flag, std::string &source):m_flag(flag),
    00021                                                         m_source(source),
    00022                                                         m_refCount(1) {}
    00023     virtual ~AbortEventListener() {}
    00025     virtual void handle(const Incident& i) {
    00026       if (i.type() == IncidentType::AbortEvent) {
    00027         m_flag = true;
    00028         m_source = i.source();
    00029       }
    00030     }
    00031
    00032     // --- These are needed because we do not inherit from any actual class.
    00037     virtual StatusCode queryInterface(const InterfaceID& riid,
    00038                                       void** ppvInterface){
    00039       if ( 0 == ppvInterface ) {
    00040         return StatusCode::FAILURE;
    00041       }
    00042       if ( IIncidentListener::interfaceID().versionMatch(riid) ) {
    00043         *ppvInterface = static_cast<IIncidentListener*>( this );
    00044       }
    00045       else if ( IInterface::interfaceID().versionMatch(riid) ) {
    00046         *ppvInterface = static_cast<IInterface*>( this );
    00047       }
    00048       else {
    00049         *ppvInterface = 0;
    00050         return NO_INTERFACE;
    00051       }
    00052       // increment reference counter
    00053       addRef();
    00054       return SUCCESS;
    00055     }
    00056
    00058     virtual unsigned long addRef() {return ++m_refCount;}
    00059
    00061     virtual unsigned long release() {
    00062       unsigned long count = --m_refCount;
    00063       if( count == 0 ) {
    00064         delete this;
    00065       }
    00066       return count;
    00067     }
    00068
    00069   private:
    00071     bool &m_flag;
    00073     std::string &m_source;
    00074     unsigned long m_refCount;
    00075   };
    00076 }
    00077
    00078 //--------------------------------------------------------------------------------------------
    00079 // Standard Constructor
    00080 //--------------------------------------------------------------------------------------------
    00081 MinimalEventLoopMgr::MinimalEventLoopMgr(const std::string& nam, ISvcLocator* svcLoc)
    00082 : Service(nam, svcLoc)
    00083 {
    00084   declareProperty("TopAlg",         m_topAlgNames );
    00085   declareProperty("OutStream",      m_outStreamNames );
    00086   declareProperty("OutStreamType",  m_outStreamType = "OutputStream");
    00087   m_topAlgNames.declareUpdateHandler   ( &MinimalEventLoopMgr::topAlgHandler, this );
    00088   m_outStreamNames.declareUpdateHandler( &MinimalEventLoopMgr::outStreamHandler, this );
    00089   svcLoc->queryInterface(IID_IAppMgrUI, pp_cast<void>(&m_appMgrUI)).ignore();
    00090   m_incidentSvc = 0;
    00091   m_state = OFFLINE;
    00092   m_scheduledStop = false;
    00093   m_abortEventListener = 0;
    00094   m_abortEvent = false;
    00095 }
    00096
    00097 //--------------------------------------------------------------------------------------------
    00098 // Standard Destructor
    00099 //--------------------------------------------------------------------------------------------
    00100 MinimalEventLoopMgr::~MinimalEventLoopMgr()   {
    00101   if( m_incidentSvc ) m_incidentSvc->release();
    00102   if( m_appMgrUI ) m_appMgrUI->release();
    00103   m_state = OFFLINE;
    00104 }
    00105
    00106 //--------------------------------------------------------------------------------------------
    00107 // implementation of IInterface: queryInterface
    00108 //--------------------------------------------------------------------------------------------
    00109 StatusCode MinimalEventLoopMgr::queryInterface(const InterfaceID& riid, void** ppvInterface)   {
    00110   if ( riid == IID_IAppMgrUI )  {
    00111     *ppvInterface = (IAppMgrUI*)this;
    00112   }
    00113   else if ( riid == IID_IEventProcessor )  {
    00114     *ppvInterface = (IEventProcessor*)this;
    00115   }
    00116   else  {
    00117     return Service::queryInterface(riid, ppvInterface);
    00118   }
    00119   addRef();
    00120   return StatusCode::SUCCESS;
    00121 }
    00122
    00123
    00124 //--------------------------------------------------------------------------------------------
    00125 // implementation of IAppMgrUI::initalize
    00126 //--------------------------------------------------------------------------------------------
    00127 StatusCode MinimalEventLoopMgr::initialize()    {
    00128
    00129   MsgStream log(msgSvc(), name());
    00130
    00131   if ( 0 == m_appMgrUI ) {
    00132     return StatusCode::FAILURE;
    00133   }
    00134
    00135   StatusCode sc = Service::initialize();
    00136   if ( !sc.isSuccess() )   {
    00137     log << MSG::ERROR << "Failed to initialize Service Base class." << endreq;
    00138     return StatusCode::FAILURE;
    00139   }
    00140
    00141   SmartIF<IProperty> prpMgr(IID_IProperty, serviceLocator());
    00142   if ( ! prpMgr.isValid() )   {
    00143     log << MSG::ERROR << "Error retrieving AppMgr interface IProperty." << endreq;
    00144     return StatusCode::FAILURE;
    00145   }
    00146   else {
    00147     if ( m_topAlgNames.value().size() == 0 )    {
    00148       setProperty(prpMgr->getProperty("TopAlg")).ignore();
    00149     }
    00150     if ( m_outStreamNames.value().size() == 0 )   {
    00151       setProperty(prpMgr->getProperty("OutStream")).ignore();
    00152     }
    00153   }
    00154
    00155   // Get the references to the services that are needed by the ApplicationMgr itself
    00156   sc = serviceLocator()->service("IncidentSvc", m_incidentSvc, true);
    00157   if( !sc.isSuccess() )  {
    00158     log << MSG::FATAL << "Error retrieving IncidentSvc." << endreq;
    00159     return sc;
    00160   }
    00161
    00162   m_abortEventListener = new AbortEventListener(m_abortEvent,m_abortEventSource);
    00163   m_incidentSvc->addListener(m_abortEventListener,IncidentType::AbortEvent);
    00164
    00165   // The state is changed at this moment to allow decodeXXXX() to do something
    00166   m_state = INITIALIZED;
    00167
    00168   //--------------------------------------------------------------------------------------------
    00169   // Create output streams. Do not initialize them yet.
    00170   // The state is updated temporarily in order to enable the handler, which
    00171   // is also triggered by a change to the "OutputStream" Property.
    00172   //--------------------------------------------------------------------------------------------
    00173   sc = decodeOutStreams();
    00174   if ( !sc.isSuccess() )    {
    00175     log << MSG::ERROR << "Failed to initialize Output streams." << endreq;
    00176     m_state = CONFIGURED;
    00177     return sc;
    00178   }
    00179   //--------------------------------------------------------------------------------------------
    00180   // Create all needed Top Algorithms. Do not initialize them yet.
    00181   // The state is updated temporarily in order to enable the handler, which
    00182   // is also triggered by a change to the "TopAlg" Property.
    00183   //--------------------------------------------------------------------------------------------
    00184   sc = decodeTopAlgs();
    00185   if ( !sc.isSuccess() )    {
    00186     log << MSG::ERROR << "Failed to initialize Top Algorithms streams." << endreq;
    00187     m_state = CONFIGURED;
    00188     return sc;
    00189   }
    00190
    00191   ListAlg::iterator ita;
    00192   // Initialize all the new TopAlgs. In fact Algorithms are protected against getting
    00193   // initialized twice.
    00194   for (ita = m_topAlgList.begin(); ita != m_topAlgList.end(); ita++ ) {
    00195     sc = (*ita)->sysInitialize();
    00196     if( !sc.isSuccess() ) {
    00197       log << MSG::ERROR << "Unable to initialize Algorithm: " << (*ita)->name() << endreq;
    00198       return sc;
    00199     }
    00200   }
    00201   for (ita = m_outStreamList.begin(); ita != m_outStreamList.end(); ita++ ) {
    00202     sc = (*ita)->sysInitialize();
    00203     if( !sc.isSuccess() ) {
    00204       log << MSG::ERROR << "Unable to initialize Output Stream: " << (*ita)->name() << endreq;
    00205       return sc;
    00206     }
    00207   }
    00208
    00209   return StatusCode::SUCCESS;
    00210 }
    00211 //--------------------------------------------------------------------------------------------
    00212 // implementation of IAppMgrUI::start
    00213 //--------------------------------------------------------------------------------------------
    00214 StatusCode MinimalEventLoopMgr::start()    {
    00215
    00216   StatusCode sc = Service::start();
    00217   if ( ! sc.isSuccess() ) return sc;
    00218
    00219   MsgStream log(msgSvc(), name());
    00220
    00221   ListAlg::iterator ita;
    00222   // Start all the new TopAlgs. In fact Algorithms are protected against getting
    00223   // started twice.
    00224   for (ita = m_topAlgList.begin(); ita != m_topAlgList.end(); ita++ ) {
    00225     sc = (*ita)->sysStart();
    00226     if( !sc.isSuccess() ) {
    00227       log << MSG::ERROR << "Unable to initialize Algorithm: " << (*ita)->name() << endreq;
    00228       return sc;
    00229     }
    00230   }
    00231   for (ita = m_outStreamList.begin(); ita != m_outStreamList.end(); ita++ ) {
    00232     sc = (*ita)->sysStart();
    00233     if( !sc.isSuccess() ) {
    00234       log << MSG::ERROR << "Unable to initialize Output Stream: " << (*ita)->name() << endreq;
    00235       return sc;
    00236     }
    00237   }
    00238   return StatusCode::SUCCESS;
    00239 }
    00240 //--------------------------------------------------------------------------------------------
    00241 // implementation of IAppMgrUI::stop
    00242 //--------------------------------------------------------------------------------------------
    00243 StatusCode MinimalEventLoopMgr::stop()    {
    00244
    00245   StatusCode sc = StatusCode::SUCCESS;
    00246
    00247   MsgStream log(msgSvc(), name());
    00248
    00249   ListAlg::iterator ita;
    00250   // Start all the new TopAlgs. In fact Algorithms are protected against getting
    00251   // started twice.
    00252   for (ita = m_topAlgList.begin(); ita != m_topAlgList.end(); ita++ ) {
    00253     sc = (*ita)->sysStop();
    00254     if( !sc.isSuccess() ) {
    00255       log << MSG::ERROR << "Unable to initialize Algorithm: " << (*ita)->name() << endreq;
    00256       return sc;
    00257     }
    00258   }
    00259   for (ita = m_outStreamList.begin(); ita != m_outStreamList.end(); ita++ ) {
    00260     sc = (*ita)->sysStop();
    00261     if( !sc.isSuccess() ) {
    00262       log << MSG::ERROR << "Unable to initialize Output Stream: " << (*ita)->name() << endreq;
    00263       return sc;
    00264     }
    00265   }
    00266
    00267   return Service::stop();
    00268 }
    00269
    00270 //--------------------------------------------------------------------------------------------
    00271 // implementation of IService::reinitialize
    00272 //--------------------------------------------------------------------------------------------
    00273 StatusCode MinimalEventLoopMgr::reinitialize() {
    00274   MsgStream log( msgSvc(), name() );
    00275   StatusCode sc = StatusCode::SUCCESS;
    00276   ListAlg::iterator ita;
    00277
    00278   // Renitialize all the TopAlgs.
    00279   for (ita = m_topAlgList.begin(); ita != m_topAlgList.end(); ita++ ) {
    00280     sc = (*ita)->sysReinitialize();
    00281     if( !sc.isSuccess() ) {
    00282       log << MSG::ERROR << "Unable to reinitialize Algorithm: " << (*ita)->name() << endreq;
    00283       return sc;
    00284     }
    00285   }
    00286   for (ita = m_outStreamList.begin(); ita != m_outStreamList.end(); ita++ ) {
    00287     sc = (*ita)->sysReinitialize();
    00288     if( !sc.isSuccess() ) {
    00289       log << MSG::ERROR << "Unable to reinitialize Output Stream: " << (*ita)->name() << endreq;
    00290       return sc;
    00291     }
    00292   }
    00293
    00294   return sc;
    00295 }
    00296 //--------------------------------------------------------------------------------------------
    00297 // implementation of IService::restart
    00298 //--------------------------------------------------------------------------------------------
    00299 StatusCode MinimalEventLoopMgr::restart() {
    00300   MsgStream log( msgSvc(), name() );
    00301   StatusCode sc = StatusCode::SUCCESS;
    00302   ListAlg::iterator ita;
    00303
    00304   // Restart all the TopAlgs.
    00305   for (ita = m_topAlgList.begin(); ita != m_topAlgList.end(); ita++ ) {
    00306     sc = (*ita)->sysRestart();
    00307     if( !sc.isSuccess() ) {
    00308       log << MSG::ERROR << "Unable to restart Algorithm: " << (*ita)->name() << endreq;
    00309       return sc;
    00310     }
    00311   }
    00312   for (ita = m_outStreamList.begin(); ita != m_outStreamList.end(); ita++ ) {
    00313     sc = (*ita)->sysRestart();
    00314     if( !sc.isSuccess() ) {
    00315       log << MSG::ERROR << "Unable to restart Output Stream: " << (*ita)->name() << endreq;
    00316       return sc;
    00317     }
    00318   }
    00319
    00320   return sc;
    00321 }
    00322
    00323 //--------------------------------------------------------------------------------------------
    00324 // implementation of IService::finalize
    00325 //--------------------------------------------------------------------------------------------
    00326 StatusCode MinimalEventLoopMgr::finalize()    {
    00327   MsgStream log( msgSvc(), name() );
    00328   StatusCode sc = StatusCode::SUCCESS;
    00329   // Call the finalize() method of all top algorithms
    00330   ListAlg::iterator ita;
    00331   for ( ita = m_topAlgList.begin(); ita != m_topAlgList.end(); ita++ ) {
    00332     sc = (*ita)->sysFinalize();
    00333     if( !sc.isSuccess() ) {
    00334       log << MSG::WARNING << "Finalization of algorithm " << (*ita)->name() << " failed" << endreq;
    00335     }
    00336   }
    00337   // Call the finalize() method of all Output streams
    00338   for ( ita = m_outStreamList.begin(); ita != m_outStreamList.end(); ita++ ) {
    00339     sc = (*ita)->sysFinalize();
    00340     if( !sc.isSuccess() ) {
    00341       log << MSG::WARNING << "Finalization of algorithm " << (*ita)->name() << " failed" << endreq;
    00342     }
    00343   }
    00344   // release all top algorithms
    00345   SmartIF<IAlgManager> algMan(IID_IAlgManager, serviceLocator());
    00346   for ( ita = m_topAlgList.begin(); ita != m_topAlgList.end(); ita++ ) {
    00347     if (algMan->removeAlgorithm(*ita).isFailure()) {
    00348       log << MSG::ERROR << "Problems removing Algorithm " << (*ita)->name()
    00349           << endreq;
    00350     }
    00351     (*ita)->release();
    00352   }
    00353   m_topAlgList.erase(m_topAlgList.begin(), m_topAlgList.end() );
    00354
    00355   // release all output streams
    00356   for ( ita = m_outStreamList.begin(); ita != m_outStreamList.end(); ita++ ) {
    00357     (*ita)->release();
    00358   }
    00359   m_outStreamList.erase(m_outStreamList.begin(), m_outStreamList.end() );
    00360   if ( sc.isSuccess() ) m_state = FINALIZED;
    00361
    00362   m_incidentSvc->removeListener(m_abortEventListener,IncidentType::AbortEvent);
    00363   m_abortEventListener = releaseInterface(m_abortEventListener);
    00364
    00365   m_incidentSvc = releaseInterface(m_incidentSvc);
    00366   m_appMgrUI = releaseInterface(m_appMgrUI);
    00367
    00368   return Service::finalize();
    00369 }
    00370
    00371 //--------------------------------------------------------------------------------------------
    00372 // implementation of IAppMgrUI::nextEvent
    00373 //--------------------------------------------------------------------------------------------
    00374 StatusCode MinimalEventLoopMgr::nextEvent(int /* maxevt */)   {
    00375   MsgStream log(msgSvc(), name());
    00376   log << MSG::ERROR << "This method cannot be called on an object of type "
    00377       << System::typeinfoName(typeid(*this)) << endreq;
    00378   return StatusCode::FAILURE;
    00379 }
    00380
    00381 //--------------------------------------------------------------------------------------------
    00382 // IEventProcessing::executeRun
    00383 //--------------------------------------------------------------------------------------------
    00384 StatusCode MinimalEventLoopMgr::executeRun( int maxevt ) {
    00385   StatusCode  sc;
    00386   MsgStream log( msgSvc(), name() );
    00387   ListAlg::iterator ita;
    00388   bool eventfailed = false;
    00389
    00390   // Call the beginRun() method of all top algorithms
    00391   for (ita = m_topAlgList.begin(); ita != m_topAlgList.end(); ita++ ) {
    00392     sc = (*ita)->sysBeginRun();
    00393     if( !sc.isSuccess() ) {
    00394       log << MSG::WARNING << "beginRun() of algorithm " << (*ita)->name() << " failed" << endreq;
    00395       eventfailed = true;
    00396     }
    00397   }
    00398
    00399   // Call now the nextEvent(...)
    00400   sc = nextEvent(maxevt);
    00401   if( !sc.isSuccess() ) {
    00402     eventfailed = true;
    00403   }
    00404
    00405   // Call the endRun() method of all top algorithms
    00406   for (ita = m_topAlgList.begin(); ita != m_topAlgList.end(); ita++ ) {
    00407     sc = (*ita)->sysEndRun();
    00408     if( !sc.isSuccess() ) {
    00409       log << MSG::WARNING << "endRun() of algorithm " << (*ita)->name() << " failed" << endreq;
    00410       eventfailed = true;
    00411     }
    00412   }
    00413
    00414   if( eventfailed ){
    00415     return StatusCode::FAILURE;
    00416   }
    00417   else {
    00418     return StatusCode::SUCCESS;
    00419   }
    00420 }
    00421
    00422 //--------------------------------------------------------------------------------------------
    00423 // implemenation of IEventProcessor::executeEvent(void* par)
    00424 //--------------------------------------------------------------------------------------------
    00425 StatusCode MinimalEventLoopMgr::executeEvent(void* /* par */)    {
    00426   bool eventfailed = false;
    00427
    00428   // Call the resetExecuted() method of ALL "known" algorithms
    00429   // (before we were reseting only the topalgs)
    00430   SmartIF<IAlgManager> algMan(IID_IAlgManager, serviceLocator());
    00431   if ( algMan.isValid() ) {
    00432     const ListAlg& allAlgs = algMan->getAlgorithms() ;
    00433     for( ListAlg::const_iterator ialg = allAlgs.begin() ; allAlgs.end() != ialg ; ++ialg ) {
    00434       if ( 0 != *ialg ) (*ialg)->resetExecuted();
    00435     }
    00436   }
    00437
    00438   // Call the execute() method of all top algorithms
    00439   for (ListAlg::const_iterator ita = m_topAlgList.begin(); ita != m_topAlgList.end(); ita++ ) {
    00440     StatusCode sc(StatusCode::FAILURE);
    00441     try {
    00442       if (m_abortEvent){
    00443         MsgStream log ( msgSvc() , name() );
    00444         log << MSG::DEBUG << "AbortEvent incident fired by "
    00445                           << m_abortEventSource << endreq;
    00446         m_abortEvent = false;
    00447         sc.ignore();
    00448         break;
    00449       }
    00450       sc = (*ita)->sysExecute();
    00451     } catch ( const GaudiException& Exception ) {
    00452       MsgStream log ( msgSvc() , "MinimalEventLoopMgr.executeEvent()" );
    00453       log << MSG::FATAL << " Exception with tag=" << Exception.tag()
    00454           << " thrown by " << (*ita)->name() << endreq;
    00455       log << MSG::ERROR << Exception << endreq;
    00456     } catch ( const std::exception& Exception ) {
    00457       MsgStream log ( msgSvc() , "MinimalEventLoopMgr.executeEvent()" );
    00458       log << MSG::FATAL << " Standard std::exception thrown by "
    00459           << (*ita)->name() << endreq;
    00460       log << MSG::ERROR << Exception.what()  << endreq;
    00461     } catch(...) {
    00462       MsgStream log ( msgSvc() , "MinimalEventLoopMgr.executeEvent()" );
    00463       log << MSG::FATAL << "UNKNOWN Exception thrown by "
    00464           << (*ita)->name() << endreq;
    00465     }
    00466
    00467     if( !sc.isSuccess() )  {
    00468       MsgStream log( msgSvc(), name() );
    00469       log << MSG::WARNING << "Execution of algorithm " << (*ita)->name() << " failed" << endreq;
    00470       eventfailed = true;
    00471     }
    00472   }
    00473
    00474   // Call the execute() method of all output streams
    00475   for (ListAlg::const_iterator ito = m_outStreamList.begin(); ito != m_outStreamList.end(); ito++ ) {
    00476     (*ito)->resetExecuted();
    00477       StatusCode sc;
    00478       sc = (*ito)->sysExecute();
    00479     if( !sc.isSuccess() )  {
    00480       MsgStream log( msgSvc(), name() );
    00481       log << MSG::WARNING << "Execution of output stream " << (*ito)->name() << " failed" << endreq;
    00482       eventfailed = true;
    00483     }
    00484   }
    00485
    00486   // Check if there was an error processing current event
    00487   if( eventfailed ){
    00488     MsgStream log( msgSvc(), name() );
    00489     log << MSG::ERROR << "Error processing event loop." << endreq;
    00490     return StatusCode(StatusCode::FAILURE,true);
    00491   }
    00492   return StatusCode(StatusCode::SUCCESS,true);
    00493 }
    00494 //--------------------------------------------------------------------------------------------
    00495 // implemenation of IEventProcessor::stopRun()
    00496 //--------------------------------------------------------------------------------------------
    00497 StatusCode MinimalEventLoopMgr::stopRun() {
    00498   m_scheduledStop = true;
    00499   return StatusCode::SUCCESS;
    00500 }
    00501
    00502 //--------------------------------------------------------------------------------------------
    00503 // Top algorithm List handler
    00504 //--------------------------------------------------------------------------------------------
    00505 void MinimalEventLoopMgr::topAlgHandler( Property& /* theProp */ )  {
    00506   if ( !(decodeTopAlgs( )).isSuccess() ) {
    00507     throw GaudiException("Failed to initialize Top Algorithms streams.",
    00508                          "MinimalEventLoopMgr::topAlgHandler",
    00509                          StatusCode::FAILURE);
    00510   }
    00511 }
    00512
    00513 //--------------------------------------------------------------------------------------------
    00514 // decodeTopAlgNameList & topAlgNameListHandler
    00515 //--------------------------------------------------------------------------------------------
    00516 StatusCode MinimalEventLoopMgr::decodeTopAlgs()    {
    00517   StatusCode sc = StatusCode::SUCCESS;
    00518   if ( CONFIGURED == m_state || INITIALIZED == m_state ) {
    00519     SmartIF<IAlgManager> algMan(IID_IAlgManager, serviceLocator());
    00520     MsgStream log(msgSvc(), name());
    00521     if ( algMan.isValid() )   {
    00522       // Reset the existing Top Algorithm List
    00523       m_topAlgList.clear( );
    00524       const std::vector<std::string>& algNames = m_topAlgNames.value( );
    00525       for (VectorName::const_iterator it = algNames.begin(); it != algNames.end(); it++) {
    00526         ListItem item(*it);
    00527         // Got the type and name. Now creating the algorithm, avoiding duplicate creation.
    00528         IAlgorithm* ialg;
    00529         std::string item_name = item.name() + getGaudiThreadIDfromName(name()) ;
    00530         sc = algMan->getAlgorithm( item_name, ialg );
    00531         if ( sc.isSuccess( ) ) {
    00532           log << MSG::DEBUG << "Top Algorithm " << item_name << " already exists" << endreq;
    00533           ialg->addRef();  // increment reference count
    00534         }
    00535         else {
    00536           log << MSG::DEBUG << "Creating Top Algorithm " << item.type() << " with name " << item_name << endreq;
    00537           sc = algMan->createAlgorithm( item.type(), item_name, ialg );
    00538           if( !sc.isSuccess() ) {
    00539             log << MSG::ERROR << "Unable to create Top Algorithm " << item.type() << " with name " << item_name << endreq;
    00540             return sc;
    00541           }
    00542         }
    00543         m_topAlgList.push_back(ialg);
    00544       }
    00545       return sc;
    00546     }
    00547     sc = StatusCode::FAILURE;
    00548   }
    00549   return sc;
    00550 }
    00551
    00552 //--------------------------------------------------------------------------------------------
    00553 // Output stream List handler
    00554 //--------------------------------------------------------------------------------------------
    00555 void MinimalEventLoopMgr::outStreamHandler( Property& /* theProp */ )    {
    00556   if ( !(decodeOutStreams( )).isSuccess() ) {
    00557     throw GaudiException("Failed to initialize output streams.",
    00558                          "MinimalEventLoopMgr::outStreamHandler",
    00559                          StatusCode::FAILURE);
    00560   }
    00561 }
    00562
    00563 //--------------------------------------------------------------------------------------------
    00564 // decodeOutStreamNameList & outStreamNameListHandler
    00565 //--------------------------------------------------------------------------------------------
    00566 StatusCode MinimalEventLoopMgr::decodeOutStreams( )    {
    00567   StatusCode sc = StatusCode::SUCCESS;
    00568   if ( CONFIGURED == m_state || INITIALIZED == m_state ) {
    00569     MsgStream log(msgSvc(), name());
    00570     SmartIF<IAlgManager> algMan(IID_IAlgManager, serviceLocator());
    00571     if ( algMan.isValid() )   {
    00572       // Reset the existing Top Algorithm List
    00573       m_outStreamList.clear();
    00574       const std::vector<std::string>& algNames = m_outStreamNames.value( );
    00575       for (VectorName::const_iterator it = algNames.begin(); it != algNames.end(); it++) {
    00576         ListItem item(*it, m_outStreamType);
    00577         IAlgorithm* ios;
    00578         log << MSG::DEBUG << "Creating " << m_outStreamType <<  (*it) << endreq;
    00579         sc = algMan->getAlgorithm( item.name(), ios );
    00580         if ( sc.isSuccess( ) ) {
    00581           log << MSG::DEBUG << "Output Stream " << item.name() << " already exists" << endreq;
    00582         }
    00583         else {
    00584           log << MSG::DEBUG << "Creating Output Stream " << (*it) << endreq;
    00585           sc = algMan->createAlgorithm( item.type(), item.name(), ios );
    00586           if( !sc.isSuccess() ) {
    00587             log << MSG::ERROR << "Unable to create Output Stream " << (*it) << endreq;
    00588             return sc;
    00589           }
    00590         }
    00591         m_outStreamList.push_back( ios );
    00592       }
    00593      return sc;
    00594     }
    00595     sc = StatusCode::FAILURE;
    00596   }
    00597   return sc;
    00598 }
    00599
    00600