| # Gaudi Framework, version v21r11 |

Home |  | Generated: 30 Sep 2010

# Algorithm.cpp

Go to the documentation of this file.

    00001 //$Id: Algorithm.cpp,v 1.42 2008/10/23 15:57:37 marcocle Exp $
    00002 #include "GaudiKernel/Kernel.h"
    00003 #include "GaudiKernel/ISvcLocator.h"
    00004 #include "GaudiKernel/IMessageSvc.h"
    00005 #include "GaudiKernel/IJobOptionsSvc.h"
    00006 #include "GaudiKernel/IAlgManager.h"
    00007 #include "GaudiKernel/IAuditorSvc.h"
    00008 #include "GaudiKernel/IDataProviderSvc.h"
    00009 #include "GaudiKernel/IConversionSvc.h"
    00010 #include "GaudiKernel/IHistogramSvc.h"
    00011 #include "GaudiKernel/INTupleSvc.h"
    00012 #include "GaudiKernel/IRndmGenSvc.h"
    00013 #include "GaudiKernel/IToolSvc.h"
    00014 #include "GaudiKernel/IExceptionSvc.h"
    00015 #include "GaudiKernel/IAlgContextSvc.h"
    00016 #include "GaudiKernel/IProperty.h"
    00017
    00018 #include "GaudiKernel/Algorithm.h"
    00019 #include "GaudiKernel/PropertyMgr.h"
    00020 #include "GaudiKernel/MsgStream.h"
    00021 #include "GaudiKernel/Chrono.h"
    00022 #include "GaudiKernel/Stat.h"
    00023 #include "GaudiKernel/GaudiException.h"
    00024 #include "GaudiKernel/ServiceLocatorHelper.h"
    00025 #include "GaudiKernel/ThreadGaudi.h"
    00026 #include "GaudiKernel/Guards.h"
    00027
    00028 // Constructor
    00029 Algorithm::Algorithm( const std::string& name, ISvcLocator *pSvcLocator,
    00030                       const std::string& version)
    00031   : m_name(name),
    00032     m_version(version),
    00033     m_registerContext ( false ) ,
    00034     m_pSvcLocator(pSvcLocator),
    00035     m_filterPassed(true),
    00036     m_isEnabled(true),
    00037     m_isExecuted(false),
    00038     m_state(Gaudi::StateMachine::CONFIGURED),
    00039     m_targetState(Gaudi::StateMachine::CONFIGURED)
    00040 {
    00041   m_propertyMgr = new PropertyMgr();
    00042   m_subAlgms = new std::vector<Algorithm *>();
    00043
    00044   // Declare common Algorithm properties with their defaults
    00045   declareProperty( "OutputLevel",        m_outputLevel = MSG::NIL);
    00046   declareProperty( "Enable",             m_isEnabled = true);
    00047   declareProperty( "ErrorMax",           m_errorMax  = 1);
    00048   declareProperty( "ErrorCount",         m_errorCount = 0);
    00049   // Auditor monitoring properties
    00050
    00051   // Get the default setting for service auditing from the AppMgr
    00052   declareProperty( "AuditAlgorithms", m_auditInit );
    00053
    00054   bool audit(false);
    00055   SmartIF<IProperty> appMgr(serviceLocator()->service("ApplicationMgr"));
    00056   if (appMgr.isValid()) {
    00057     const Property& prop = appMgr->getProperty("AuditAlgorithms");
    00058     Property &pr = const_cast<Property&>(prop);
    00059     if (m_name != "IncidentSvc") {
    00060       setProperty( pr ).ignore();
    00061     }
    00062     audit = m_auditInit.value();
    00063   }
    00064
    00065   declareProperty( "AuditInitialize"  , m_auditorInitialize   = audit ) ;
    00066   declareProperty( "AuditReinitialize", m_auditorReinitialize = audit ) ;
    00067   declareProperty( "AuditRestart"     , m_auditorRestart      = audit ) ;
    00068   declareProperty( "AuditExecute"     , m_auditorExecute      = audit ) ;
    00069   declareProperty( "AuditFinalize"    , m_auditorFinalize     = audit ) ;
    00070   declareProperty( "AuditBeginRun"    , m_auditorBeginRun     = audit ) ;
    00071   declareProperty( "AuditEndRun"      , m_auditorEndRun       = audit ) ;
    00072   declareProperty( "AuditStart"       , m_auditorStart        = audit ) ;
    00073   declareProperty( "AuditStop"        , m_auditorStop         = audit ) ;
    00074
    00075   declareProperty( "MonitorService"   , m_monitorSvcName      = "MonitorSvc" );
    00076
    00077   declareProperty
    00078     ( "RegisterForContextService" ,
    00079       m_registerContext  ,
    00080       "The flag to enforce the registration for Algorithm Context Service") ;
    00081
    00082   // update handlers.
    00083   m_outputLevel.declareUpdateHandler(&Algorithm::initOutputLevel, this);
    00084
    00085 }
    00086
    00087 // Default Destructor
    00088 Algorithm::~Algorithm() {
    00089   delete m_subAlgms;
    00090   delete m_propertyMgr;
    00091 }
    00092
    00093 // IAlgorithm implementation
    00094 StatusCode Algorithm::sysInitialize() {
    00095
    00096   // Bypass the initialization if the algorithm
    00097   // has already been initialized.
    00098   if ( Gaudi::StateMachine::INITIALIZED <= FSMState() ) return StatusCode::SUCCESS;
    00099
    00100   // Set the Algorithm's properties
    00101   StatusCode sc = setProperties();
    00102   if( sc.isFailure() ) return StatusCode::FAILURE;
    00103
    00104   // Bypass the initialization if the algorithm is disabled.
    00105   // Need to do this after setProperties.
    00106   if ( !isEnabled( ) ) return StatusCode::SUCCESS;
    00107
    00108   m_targetState = Gaudi::StateMachine::ChangeState(Gaudi::StateMachine::INITIALIZE,m_state);
    00109
    00110   // Check current outputLevel to evetually inform the MessagsSvc
    00111   //if( m_outputLevel != MSG::NIL ) {
    00112   setOutputLevel( m_outputLevel );
    00113   //}
    00114
    00115   // TODO: (MCl) where shoud we do this? initialize or start?
    00116   // Reset Error count
    00117   //m_errorCount = 0;
    00118
    00119   // lock the context service
    00120   Gaudi::Utils::AlgContext cnt
    00121     ( this , registerContext() ? contextSvc().get() : 0 ) ;
    00122
    00123   // Invoke initialize() method of the derived class inside a try/catch clause
    00124   try {
    00125
    00126     { // limit the scope of the guard
    00127       Gaudi::Guards::AuditorGuard guard
    00128         ( this,
    00129           // check if we want to audit the initialize
    00130           (m_auditorInitialize) ? auditorSvc().get() : 0,
    00131           IAuditor::Initialize);
    00132       // Invoke the initialize() method of the derived class
    00133       sc = initialize();
    00134     }
    00135     if( sc.isSuccess() ) {
    00136
    00137       // Now initialize care of any sub-algorithms
    00138       std::vector<Algorithm *>::iterator it;
    00139       bool fail(false);
    00140       for (it = m_subAlgms->begin(); it != m_subAlgms->end(); it++) {
    00141         if ((*it)->sysInitialize().isFailure()) fail = true;
    00142       }
    00143       if( fail ) {
    00144         sc = StatusCode::FAILURE;
    00145         MsgStream log ( msgSvc() , name() );
    00146         log << MSG::ERROR << " Error initializing one or several sub-algorithms"
    00147             << endmsg;
    00148       } else {
    00149         // Update the state.
    00150         m_state = m_targetState;
    00151       }
    00152     }
    00153   }
    00154   catch ( const GaudiException& Exception )
    00155   {
    00156     MsgStream log ( msgSvc() , name() ) ;
    00157     log << MSG::FATAL << " Exception with tag=" << Exception.tag()
    00158         << " is caught " << endmsg;
    00159     log << MSG::ERROR << Exception  << endmsg;
    00160     Stat stat( chronoSvc() , Exception.tag() );
    00161     sc = StatusCode::FAILURE;
    00162   }
    00163   catch( const std::exception& Exception )
    00164   {
    00165     MsgStream log ( msgSvc() , name() ) ;
    00166     log << MSG::FATAL << " Standard std::exception is caught " << endmsg;
    00167     log << MSG::ERROR << Exception.what()  << endmsg;
    00168     Stat stat( chronoSvc() , "*std::exception*" );
    00169     sc = StatusCode::FAILURE;
    00170   }
    00171   catch(...)
    00172   {
    00173     MsgStream log ( msgSvc() , name() ) ;
    00174     log << MSG::FATAL << "UNKNOWN Exception is caught " << endmsg;
    00175     Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
    00176     sc = StatusCode::FAILURE;
    00177   }
    00178
    00179   return sc;
    00180 }
    00181
    00182 // IAlgorithm implementation
    00183 StatusCode Algorithm::sysStart() {
    00184
    00185   // Bypass the startup if already running or disabled.
    00186   if ( Gaudi::StateMachine::RUNNING == FSMState() ||
    00187        !isEnabled() ) return StatusCode::SUCCESS;
    00188
    00189   m_targetState = Gaudi::StateMachine::ChangeState(Gaudi::StateMachine::START,m_state);
    00190
    00191   // TODO: (MCl) where shoud we do this? initialize or start?
    00192   // Reset Error count
    00193   m_errorCount = 0;
    00194
    00195   // lock the context service
    00196   Gaudi::Utils::AlgContext cnt
    00197     ( this , registerContext() ? contextSvc().get() : 0 ) ;
    00198
    00199   StatusCode sc(StatusCode::FAILURE);
    00200   // Invoke start() method of the derived class inside a try/catch clause
    00201   try
    00202   {
    00203     { // limit the scope of the guard
    00204       Gaudi::Guards::AuditorGuard guard
    00205         (this,
    00206          // check if we want to audit the initialize
    00207          (m_auditorStart) ? auditorSvc().get() : 0,
    00208          IAuditor::Start);
    00209       // Invoke the start() method of the derived class
    00210       sc = start();
    00211     }
    00212     if( sc.isSuccess() ) {
    00213
    00214       // Now start any sub-algorithms
    00215       std::vector<Algorithm *>::iterator it;
    00216       bool fail(false);
    00217       for (it = m_subAlgms->begin(); it != m_subAlgms->end(); it++) {
    00218         if ((*it)->sysStart().isFailure()) fail = true;
    00219       }
    00220       if( fail ) {
    00221         sc = StatusCode::FAILURE;
    00222         MsgStream log ( msgSvc() , name() );
    00223         log << MSG::ERROR << " Error starting one or several sub-algorithms"
    00224             << endmsg;
    00225       } else {
    00226         // Update the state.
    00227         m_state = m_targetState;
    00228       }
    00229     }
    00230   }
    00231   catch ( const GaudiException& Exception )
    00232   {
    00233     MsgStream log ( msgSvc() , name() );
    00234     log << MSG::FATAL << "in sysStart(): exception with tag=" << Exception.tag()
    00235         << " is caught" << endmsg;
    00236     log << MSG::ERROR << Exception << endmsg;
    00237     Stat stat( chronoSvc() , Exception.tag() );
    00238     sc = StatusCode::FAILURE;
    00239   }
    00240   catch( const std::exception& Exception )
    00241   {
    00242     MsgStream log ( msgSvc() , name() );
    00243     log << MSG::FATAL << "in sysStart(): standard std::exception is caught" << endmsg;
    00244     log << MSG::ERROR << Exception.what()  << endmsg;
    00245     Stat stat( chronoSvc() , "*std::exception*" );
    00246     sc = StatusCode::FAILURE;
    00247   }
    00248   catch(...)
    00249   {
    00250     MsgStream log ( msgSvc() , name() );
    00251     log << MSG::FATAL << "in sysStart(): UNKNOWN Exception is caught" << endmsg;
    00252     Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
    00253     sc = StatusCode::FAILURE;
    00254   }
    00255
    00256   return sc;
    00257 }
    00258
    00259 // IAlgorithm implementation
    00260 StatusCode Algorithm::sysReinitialize() {
    00261
    00262   // Bypass the initialization if the algorithm is disabled.
    00263   if ( !isEnabled( ) ) return StatusCode::SUCCESS;
    00264
    00265   // Check that the current status is the correct one.
    00266   if ( Gaudi::StateMachine::INITIALIZED != FSMState() ) {
    00267     MsgStream log ( msgSvc() , name() );
    00268     log << MSG::ERROR
    00269         << "sysReinitialize(): cannot reinitialize algorithm not initialized"
    00270         << endmsg;
    00271     return StatusCode::FAILURE;
    00272   }
    00273
    00274   // Check current outputLevel to evetually inform the MessagsSvc
    00275   //if( m_outputLevel != MSG::NIL ) {
    00276   setOutputLevel( m_outputLevel );
    00277   //}
    00278
    00279   // Reset Error count
    00280   // m_errorCount = 0; // done during start
    00281
    00282   // lock the context service
    00283   Gaudi::Utils::AlgContext cnt
    00284     ( this , registerContext() ? contextSvc().get() : 0 ) ;
    00285
    00286   StatusCode sc(StatusCode::SUCCESS);
    00287   // Invoke reinitialize() method of the derived class inside a try/catch clause
    00288   try {
    00289     { // limit the scope of the guard
    00290       Gaudi::Guards::AuditorGuard guard(this,
    00291                                         // check if we want to audit the initialize
    00292                                         (m_auditorReinitialize) ? auditorSvc().get() : 0,
    00293                                         IAuditor::ReInitialize);
    00294       // Invoke the reinitialize() method of the derived class
    00295       sc = reinitialize();
    00296     }
    00297     if( sc.isSuccess() ) {
    00298
    00299       // Now initialize care of any sub-algorithms
    00300       std::vector<Algorithm *>::iterator it;
    00301       bool fail(false);
    00302       for (it = m_subAlgms->begin(); it != m_subAlgms->end(); it++) {
    00303         if((*it)->sysReinitialize().isFailure()) fail = true;
    00304       }
    00305
    00306       if (fail) {
    00307         sc = StatusCode::FAILURE;
    00308         MsgStream log ( msgSvc() , name() );
    00309         log << MSG::ERROR
    00310             << "sysReinitialize(): Error reinitializing one or several "
    00311             << "sub-algorithms" << endmsg;
    00312       }
    00313     }
    00314   }
    00315   catch ( const GaudiException& Exception )
    00316   {
    00317     MsgStream log ( msgSvc() , name() );
    00318     log << MSG::FATAL << "sysReinitialize(): Exception with tag=" << Exception.tag()
    00319         << " is caught" << endmsg;
    00320     log << MSG::ERROR << Exception  << endmsg;
    00321     Stat stat( chronoSvc() , Exception.tag() );
    00322     sc = StatusCode::FAILURE;
    00323   }
    00324   catch( const std::exception& Exception )
    00325   {
    00326     MsgStream log ( msgSvc() , name() );
    00327     log << MSG::FATAL << "sysReinitialize(): Standard std::exception is caught" << endmsg;
    00328     log << MSG::ERROR << Exception.what()  << endmsg;
    00329     Stat stat( chronoSvc() , "*std::exception*" );
    00330     sc = StatusCode::FAILURE;
    00331   }
    00332   catch(...)
    00333   {
    00334     MsgStream log ( msgSvc() , name() );
    00335     log << MSG::FATAL << "sysReinitialize(): UNKNOWN Exception is caught" << endmsg;
    00336     Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
    00337     sc = StatusCode::FAILURE;
    00338   }
    00339
    00340   return sc;
    00341 }
    00342
    00343 // IAlgorithm implementation
    00344 StatusCode Algorithm::sysRestart() {
    00345
    00346   // Bypass the initialization if the algorithm is disabled.
    00347   if ( !isEnabled( ) ) return StatusCode::SUCCESS;
    00348
    00349   // Check that the current status is the correct one.
    00350   if ( Gaudi::StateMachine::RUNNING != FSMState() ) {
    00351     MsgStream log ( msgSvc() , name() );
    00352     log << MSG::ERROR
    00353         << "sysRestart(): cannot restart algorithm not started"
    00354         << endmsg;
    00355     return StatusCode::FAILURE;
    00356   }
    00357
    00358   // Check current outputLevel to evetually inform the MessagsSvc
    00359   //if( m_outputLevel != MSG::NIL ) {
    00360   setOutputLevel( m_outputLevel );
    00361   //}
    00362
    00363   // Reset Error count
    00364   m_errorCount = 0;
    00365
    00366   // lock the context service
    00367   Gaudi::Utils::AlgContext cnt
    00368     ( this , registerContext() ? contextSvc().get() : 0 ) ;
    00369
    00370   StatusCode sc(StatusCode::FAILURE);
    00371   // Invoke reinitialize() method of the derived class inside a try/catch clause
    00372   try {
    00373     { // limit the scope of the guard
    00374       Gaudi::Guards::AuditorGuard guard(this,
    00375                                         // check if we want to audit the initialize
    00376                                         (m_auditorRestart) ? auditorSvc().get() : 0,
    00377                                         IAuditor::ReStart);
    00378       // Invoke the reinitialize() method of the derived class
    00379       sc = restart();
    00380     }
    00381     if( sc.isSuccess() ) {
    00382
    00383       // Now initialize care of any sub-algorithms
    00384       std::vector<Algorithm *>::iterator it;
    00385       bool fail(false);
    00386       for (it = m_subAlgms->begin(); it != m_subAlgms->end(); it++) {
    00387         if ((*it)->sysRestart().isFailure()) fail = true;
    00388       }
    00389       if( fail ) {
    00390         sc = StatusCode::FAILURE;
    00391         MsgStream log ( msgSvc() , name() );
    00392         log << MSG::ERROR
    00393             << "sysRestart(): Error restarting one or several sub-algorithms"
    00394             << endmsg;
    00395       }
    00396     }
    00397   }
    00398   catch ( const GaudiException& Exception )
    00399   {
    00400     MsgStream log ( msgSvc() , name() );
    00401     log << MSG::FATAL << "sysRestart(): Exception with tag=" << Exception.tag()
    00402         << " is caught" << endmsg;
    00403     log << MSG::ERROR << Exception  << endmsg;
    00404     Stat stat( chronoSvc() , Exception.tag() );
    00405     sc = StatusCode::FAILURE;
    00406   }
    00407   catch( const std::exception& Exception )
    00408   {
    00409     MsgStream log ( msgSvc() , name() );
    00410     log << MSG::FATAL << "sysRestart(): Standard std::exception is caught" << endmsg;
    00411     log << MSG::ERROR << Exception.what()  << endmsg;
    00412     Stat stat( chronoSvc() , "*std::exception*" );
    00413     sc = StatusCode::FAILURE;
    00414   }
    00415   catch(...)
    00416   {
    00417     MsgStream log ( msgSvc() , name() );
    00418     log << MSG::FATAL << "sysRestart(): UNKNOWN Exception is caught" << endmsg;
    00419     Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
    00420     sc = StatusCode::FAILURE;
    00421   }
    00422
    00423   return sc;
    00424 }
    00425
    00426 // IAlgorithm implementation
    00427 StatusCode Algorithm::sysBeginRun() {
    00428
    00429   // Bypass the beginRun if the algorithm is disabled.
    00430   if ( !isEnabled( ) ) return StatusCode::SUCCESS;
    00431
    00432   // Check current outputLevel to evetually inform the MessagsSvc
    00433   //if( m_outputLevel != MSG::NIL ) {
    00434   setOutputLevel( m_outputLevel );
    00435   //}
    00436
    00437   // Reset Error count
    00438   m_errorCount = 0;
    00439
    00440   // lock the context service
    00441   Gaudi::Utils::AlgContext cnt
    00442     ( this , registerContext() ? contextSvc().get() : 0 ) ;
    00443
    00444   StatusCode sc(StatusCode::FAILURE);
    00445   // Invoke beginRun() method of the derived class inside a try/catch clause
    00446   try {
    00447     { // limit the scope of the guard
    00448       Gaudi::Guards::AuditorGuard guard(this,
    00449                                         // check if we want to audit the initialize
    00450                                         (m_auditorBeginRun) ? auditorSvc().get() : 0,
    00451                                         IAuditor::BeginRun);
    00452       // Invoke the beginRun() method of the derived class
    00453       sc = beginRun();
    00454     }
    00455     if( sc.isSuccess() ) {
    00456
    00457       // Now call beginRun for any sub-algorithms
    00458       std::vector<Algorithm *>::iterator it;
    00459       bool fail(false);
    00460       for (it = m_subAlgms->begin(); it != m_subAlgms->end(); it++) {
    00461         if((*it)->sysBeginRun().isFailure()) fail = true;
    00462       }
    00463       if( fail ) {
    00464         sc = StatusCode::FAILURE;
    00465         MsgStream log ( msgSvc() , name() );
    00466         log << MSG::ERROR << " Error executing BeginRun for one or several sub-algorithms"
    00467           << endmsg;
    00468       }
    00469     }
    00470   }
    00471   catch ( const GaudiException& Exception )
    00472   {
    00473     MsgStream log ( msgSvc() , name() );
    00474     log << MSG::FATAL << " Exception with tag=" << Exception.tag()
    00475         << " is caught " << endmsg;
    00476     log << MSG::ERROR << Exception  << endmsg;
    00477     Stat stat( chronoSvc() , Exception.tag() );
    00478     sc = StatusCode::FAILURE;
    00479   }
    00480   catch( const std::exception& Exception )
    00481   {
    00482     MsgStream log ( msgSvc() , name() );
    00483     log << MSG::FATAL << " Standard std::exception is caught " << endmsg;
    00484     log << MSG::ERROR << Exception.what()  << endmsg;
    00485     Stat stat( chronoSvc() , "*std::exception*" );
    00486     sc = StatusCode::FAILURE;
    00487   }
    00488   catch(...)
    00489   {
    00490     MsgStream log ( msgSvc() , name() );
    00491     log << MSG::FATAL << "UNKNOWN Exception is caught " << endmsg;
    00492     Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
    00493     sc = StatusCode::FAILURE;
    00494   }
    00495   return sc;
    00496 }
    00497
    00498 StatusCode Algorithm::beginRun() {
    00499   return StatusCode::SUCCESS;
    00500 }
    00501
    00502 // IAlgorithm implementation
    00503 StatusCode Algorithm::sysEndRun() {
    00504
    00505   // Bypass the endRun if the algorithm is disabled.
    00506   if ( !isEnabled( ) ) return StatusCode::SUCCESS;
    00507
    00508   // Check current outputLevel to eventually inform the MessagsSvc
    00509   //if( m_outputLevel != MSG::NIL ) {
    00510   setOutputLevel( m_outputLevel );
    00511   //}
    00512
    00513   // Reset Error count
    00514   m_errorCount = 0;
    00515
    00516   // lock the context service
    00517   Gaudi::Utils::AlgContext cnt
    00518     ( this , registerContext() ? contextSvc().get() : 0 ) ;
    00519
    00520   // Invoke endRun() method of the derived class inside a try/catch clause
    00521   StatusCode sc(StatusCode::FAILURE);
    00522   try {
    00523     { // limit the scope of the guard
    00524       Gaudi::Guards::AuditorGuard guard(this,
    00525                                         // check if we want to audit the initialize
    00526                                         (m_auditorEndRun) ? auditorSvc().get() : 0,
    00527                                         IAuditor::EndRun);
    00528       // Invoke the endRun() method of the derived class
    00529       sc = endRun();
    00530     }
    00531     if( sc.isSuccess() ) {
    00532
    00533       // Now call endRun for any sub-algorithms
    00534       std::vector<Algorithm *>::iterator it;
    00535       bool fail(false);
    00536       for (it = m_subAlgms->begin(); it != m_subAlgms->end(); it++) {
    00537         if ((*it)->sysEndRun().isFailure()) fail = true;
    00538       }
    00539       if( fail ) {
    00540         sc = StatusCode::FAILURE;
    00541         MsgStream log ( msgSvc() , name() );
    00542         log << MSG::ERROR << " Error calling endRun for one or several sub-algorithms"
    00543             << endmsg;
    00544       }
    00545     }
    00546   }
    00547   catch ( const GaudiException& Exception )
    00548   {
    00549     MsgStream log ( msgSvc() , name() );
    00550     log << MSG::FATAL << " Exception with tag=" << Exception.tag()
    00551         << " is caught " << endmsg;
    00552     log << MSG::ERROR << Exception  << endmsg;
    00553     Stat stat( chronoSvc() , Exception.tag() );
    00554     sc = StatusCode::FAILURE;
    00555   }
    00556   catch( const std::exception& Exception )
    00557   {
    00558     MsgStream log ( msgSvc() , name() );
    00559     log << MSG::FATAL << " Standard std::exception is caught " << endmsg;
    00560     log << MSG::ERROR << Exception.what()  << endmsg;
    00561     Stat stat( chronoSvc() , "*std::exception*" );
    00562     sc = StatusCode::FAILURE;
    00563   }
    00564   catch(...)
    00565   {
    00566     MsgStream log ( msgSvc() , name() );
    00567     log << MSG::FATAL << "UNKNOWN Exception is caught " << endmsg;
    00568     Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
    00569     sc = StatusCode::FAILURE;
    00570   }
    00571   return sc;
    00572 }
    00573
    00574 StatusCode Algorithm::endRun() {
    00575   return StatusCode::SUCCESS;
    00576 }
    00577
    00578
    00579 StatusCode Algorithm::sysExecute() {
    00580   if (!isEnabled()) {
    00581     MsgStream log ( msgSvc() , name() );
    00582     log << MSG::VERBOSE << ".sysExecute(): is not enabled. Skip execution" <<endmsg;
    00583     return StatusCode::SUCCESS;
    00584   }
    00585
    00586   StatusCode status;
    00587
    00588   // Should performance profile be performed ?
    00589   // invoke execute() method of Algorithm class
    00590   //   and catch all uncaught exceptions
    00591
    00592   // lock the context service
    00593   Gaudi::Utils::AlgContext cnt
    00594     ( this , registerContext() ? contextSvc().get() : 0 ) ;
    00595
    00596   Gaudi::Guards::AuditorGuard guard(this,
    00597                                     // check if we want to audit the initialize
    00598                                     (m_auditorExecute) ? auditorSvc().get() : 0,
    00599                                     IAuditor::Execute,
    00600                                     status);
    00601   try {
    00602     status = execute();
    00603     setExecuted(true);  // set the executed flag
    00604
    00605     if (status.isFailure()) {
    00606       status = exceptionSvc()->handleErr(*this,status);
    00607     }
    00608
    00609   }
    00610   catch( const GaudiException& Exception )
    00611   {
    00612     setExecuted(true);  // set the executed flag
    00613
    00614     MsgStream log ( msgSvc() , name() );
    00615     if (Exception.code() == StatusCode::FAILURE) {
    00616       log << MSG::FATAL;
    00617     } else {
    00618       log << MSG::ERROR << " Recoverable";
    00619     }
    00620
    00621     log << " Exception with tag=" << Exception.tag()
    00622         << " is caught " << endmsg;
    00623
    00624     log << MSG::ERROR << Exception  << endmsg;
    00625
    00626     Stat stat( chronoSvc() , Exception.tag() ) ;
    00627     status = exceptionSvc()->handle(*this,Exception);
    00628   }
    00629   catch( const std::exception& Exception )
    00630   {
    00631     setExecuted(true);  // set the executed flag
    00632
    00633     MsgStream log ( msgSvc() , name() );
    00634     log << MSG::FATAL << " Standard std::exception is caught " << endmsg;
    00635     log << MSG::ERROR << Exception.what()  << endmsg;
    00636     Stat stat( chronoSvc() , "*std::exception*" ) ;
    00637     status = exceptionSvc()->handle(*this,Exception);
    00638   }
    00639   catch(...)
    00640   {
    00641     setExecuted(true);  // set the executed flag
    00642
    00643     MsgStream log ( msgSvc() , name() );
    00644     log << MSG::FATAL << "UNKNOWN Exception is caught " << endmsg;
    00645     Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
    00646
    00647     status = exceptionSvc()->handle(*this);
    00648   }
    00649
    00650   if( status.isFailure() ) {
    00651     MsgStream log ( msgSvc() , name() );
    00652     // Increment the error count
    00653     m_errorCount++;
    00654     // Check if maximum is exeeded
    00655     if( m_errorCount < m_errorMax ) {
    00656       log << MSG::WARNING << "Continuing from error (cnt=" << m_errorCount
    00657           << ", max=" << m_errorMax << ")" << endmsg;
    00658       // convert to success
    00659       status = StatusCode::SUCCESS;
    00660     }
    00661   }
    00662   return status;
    00663 }
    00664
    00665 // IAlgorithm implementation
    00666 StatusCode Algorithm::sysStop() {
    00667
    00668   // Bypass the startup if already running or disabled.
    00669   if ( Gaudi::StateMachine::INITIALIZED == FSMState() ||
    00670        !isEnabled() ) return StatusCode::SUCCESS;
    00671
    00672   m_targetState = Gaudi::StateMachine::ChangeState(Gaudi::StateMachine::STOP,m_state);
    00673
    00674   // lock the context service
    00675   Gaudi::Utils::AlgContext cnt
    00676     ( this , registerContext() ? contextSvc().get() : 0 ) ;
    00677
    00678   StatusCode sc(StatusCode::FAILURE);
    00679   // Invoke stop() method of the derived class inside a try/catch clause
    00680   try {
    00681     // Stop first any sub-algorithms (in reverse order)
    00682     std::vector<Algorithm *>::reverse_iterator it;
    00683     for (it = m_subAlgms->rbegin(); it != m_subAlgms->rend(); it++) {
    00684       (*it)->sysStop().ignore();
    00685     }
    00686     { // limit the scope of the guard
    00687       Gaudi::Guards::AuditorGuard guard(this,
    00688                                         // check if we want to audit the initialize
    00689                                         (m_auditorStop) ? auditorSvc().get() : 0,
    00690                                         IAuditor::Stop);
    00691
    00692       // Invoke the stop() method of the derived class
    00693       sc = stop();
    00694     }
    00695     if( sc.isSuccess() ) {
    00696       // Update the state.
    00697       m_state = m_targetState;
    00698     }
    00699   }
    00700   catch ( const GaudiException& Exception )  {
    00701     MsgStream log ( msgSvc() , name() );
    00702     log << MSG::FATAL << "in sysStop(): exception with tag=" << Exception.tag()
    00703         << " is caught" << endmsg;
    00704     log << MSG::ERROR << Exception << endmsg;
    00705     Stat stat( chronoSvc() , Exception.tag() );
    00706     sc = StatusCode::FAILURE;
    00707   }
    00708   catch( const std::exception& Exception ) {
    00709     MsgStream log ( msgSvc() , name() );
    00710     log << MSG::FATAL << "in sysStop(): standard std::exception is caught" << endmsg;
    00711     log << MSG::ERROR << Exception.what()  << endmsg;
    00712     Stat stat( chronoSvc() , "*std::exception*" );
    00713     sc = StatusCode::FAILURE;
    00714   }
    00715   catch(...) {
    00716     MsgStream log ( msgSvc() , name() );
    00717     log << MSG::FATAL << "in sysStop(): UNKNOWN Exception is caught" << endmsg;
    00718     Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
    00719     sc = StatusCode::FAILURE;
    00720   }
    00721
    00722   return sc;
    00723 }
    00724
    00725 StatusCode Algorithm::sysFinalize() {
    00726
    00727   // Bypass the finalialization if the algorithm hasn't been initilized.
    00728   if ( Gaudi::StateMachine::CONFIGURED == FSMState() ||
    00729        !isEnabled() ) return StatusCode::SUCCESS;
    00730
    00731   m_targetState = Gaudi::StateMachine::ChangeState(Gaudi::StateMachine::FINALIZE,m_state);
    00732
    00733   // lock the context service
    00734   Gaudi::Utils::AlgContext cnt
    00735     ( this , registerContext() ? contextSvc().get() : 0 ) ;
    00736
    00737   StatusCode sc(StatusCode::FAILURE);
    00738   // Invoke finalize() method of the derived class inside a try/catch clause
    00739   try {
    00740     // Order changed (bug #3903 overview: finalize and nested algorithms)
    00741     // Finalize first any sub-algoithms (it can be done more than once)
    00742     std::vector<Algorithm *>::iterator it;
    00743     bool fail(false);
    00744     for (it = m_subAlgms->begin(); it != m_subAlgms->end(); it++) {
    00745       if (!(*it)->sysFinalize().isSuccess()) {
    00746         fail = true;
    00747       }
    00748     }
    00749
    00750     { // limit the scope of the guard
    00751       Gaudi::Guards::AuditorGuard guard(this,
    00752                                         // check if we want to audit the initialize
    00753                                         (m_auditorFinalize) ? auditorSvc().get() : 0,
    00754                                         IAuditor::Finalize);
    00755       // Invoke the finalize() method of the derived class
    00756       sc = finalize();
    00757     }
    00758     if (fail) sc = StatusCode::FAILURE;
    00759
    00760     if( sc.isSuccess() ) {
    00761
    00762       // Release all sub-algorithms
    00763       for (it = m_subAlgms->begin(); it != m_subAlgms->end(); it++) {
    00764         (*it)->release();
    00765       }
    00766       // Indicate that this Algorithm has been finalized to prevent duplicate attempts
    00767       m_state = m_targetState;
    00768     }
    00769   }
    00770   catch( const GaudiException& Exception )
    00771   {
    00772     MsgStream log ( msgSvc() , name() );
    00773     log << MSG::FATAL << " Exception with tag=" << Exception.tag()
    00774         << " is caught " << endmsg;
    00775     log << MSG::ERROR << Exception  << endmsg;
    00776     Stat stat( chronoSvc() , Exception.tag() ) ;
    00777     sc = StatusCode::FAILURE;
    00778   }
    00779   catch( const std::exception& Exception )
    00780   {
    00781     MsgStream log ( msgSvc() , name() );
    00782     log << MSG::FATAL << " Standard std::exception is caught " << endmsg;
    00783     log << MSG::ERROR << Exception.what()  << endmsg;
    00784     Stat stat( chronoSvc() , "*std::exception*" ) ;
    00785     sc = StatusCode::FAILURE;
    00786   }
    00787   catch( ... )
    00788   {
    00789     MsgStream log ( msgSvc() , name() );
    00790     log << MSG::FATAL << "UNKNOWN Exception is caught " << endmsg;
    00791     Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
    00792     sc = StatusCode::FAILURE;
    00793   }
    00794   return sc;
    00795 }
    00796
    00797 StatusCode Algorithm::reinitialize() {
    00798   /* @TODO
    00799    * MCl 2008-10-23: the implementation of reinitialize as finalize+initialize
    00800    *                 is causing too many problems
    00801    *
    00802   // Default implementation is finalize+initialize
    00803   StatusCode sc = finalize();
    00804   if (sc.isFailure()) {
    00805     MsgStream log ( msgSvc() , name() );
    00806     log << MSG::ERROR << "reinitialize(): cannot be finalized" << endmsg;
    00807     return sc;
    00808   }
    00809   sc = initialize();
    00810   if (sc.isFailure()) {
    00811     MsgStream log ( msgSvc() , name() );
    00812     log << MSG::ERROR << "reinitialize(): cannot be initialized" << endmsg;
    00813     return sc;
    00814   }
    00815   */
    00816   return StatusCode::SUCCESS;
    00817 }
    00818
    00819 StatusCode Algorithm::restart() {
    00820   // Default implementation is stop+start
    00821   StatusCode sc = stop();
    00822   if (sc.isFailure()) {
    00823     MsgStream log ( msgSvc() , name() );
    00824     log << MSG::ERROR << "restart(): cannot be stopped" << endmsg;
    00825     return sc;
    00826   }
    00827   sc = start();
    00828   if (sc.isFailure()) {
    00829     MsgStream log ( msgSvc() , name() );
    00830     log << MSG::ERROR << "restart(): cannot be started" << endmsg;
    00831     return sc;
    00832   }
    00833   return StatusCode::SUCCESS;
    00834 }
    00835
    00836 const std::string& Algorithm::name() const {
    00837   return m_name;
    00838 }
    00839
    00840 const std::string& Algorithm::version() const {
    00841   return m_version;
    00842 }
    00843
    00844 bool Algorithm::isExecuted() const {
    00845   return m_isExecuted;
    00846 }
    00847
    00848 void Algorithm::setExecuted( bool state ) {
    00849   m_isExecuted = state;
    00850 }
    00851
    00852 void Algorithm::resetExecuted() {
    00853   m_isExecuted   = false;
    00854   m_filterPassed = true;
    00855 }
    00856
    00857 bool Algorithm::isEnabled() const {
    00858   return m_isEnabled;
    00859 }
    00860
    00861 bool Algorithm::filterPassed() const {
    00862   return m_filterPassed;
    00863 }
    00864
    00865 void Algorithm::setFilterPassed( bool state ) {
    00866   m_filterPassed = state;
    00867 }
    00868
    00869 std::vector<Algorithm*>* Algorithm::subAlgorithms( ) const {
    00870   return m_subAlgms;
    00871 }
    00872
    00873 void Algorithm::setOutputLevel( int level ) {
    00874   if ( msgSvc() != 0 )
    00875   {
    00876     if ( MSG::NIL != level )
    00877     { msgSvc()->setOutputLevel( name(), level ) ; }
    00878     m_outputLevel = msgSvc()->outputLevel( name() );
    00879   }
    00880 }
    00881
    00882 #define serviceAccessor(METHOD,INTERFACE,NAME,MEMBER) \
    00883 SmartIF<INTERFACE>& Algorithm::METHOD() const { \
    00884   if ( !MEMBER.isValid() ) { \
    00885     MEMBER = service(NAME); \
    00886     if( !MEMBER.isValid() ) { \
    00887       throw GaudiException("Service [" NAME  "] not found", name(), StatusCode::FAILURE); \
    00888     } \
    00889   } \
    00890   return MEMBER; \
    00891 }
    00892
    00893 //serviceAccessor(msgSvc, IMessageSvc, "MessageSvc", m_MS)
    00894 // Message service needs a special treatment to avoid infinite recursion
    00895 SmartIF<IMessageSvc>& Algorithm::msgSvc() const {
    00896   if ( !m_MS.isValid() ) {
    00897     //can not use service() method (infinite recursion!)
    00898     m_MS = serviceLocator(); // default message service
    00899     if( !m_MS.isValid() ) {
    00900       throw GaudiException("Service [MessageSvc] not found", name(), StatusCode::FAILURE);
    00901     }
    00902   }
    00903   return m_MS;
    00904 }
    00905
    00906 serviceAccessor(auditorSvc, IAuditorSvc, "AuditorSvc", m_pAuditorSvc)
    00907 serviceAccessor(chronoSvc, IChronoStatSvc, "ChronoStatSvc", m_CSS)
    00908 serviceAccessor(detSvc, IDataProviderSvc, "DetectorDataSvc", m_DDS)
    00909 serviceAccessor(detCnvSvc, IConversionSvc, "DetectorPersistencySvc", m_DCS)
    00910 serviceAccessor(eventSvc, IDataProviderSvc, "EventDataSvc", m_EDS)
    00911 serviceAccessor(eventCnvSvc, IConversionSvc, "EventPersistencySvc", m_ECS)
    00912 serviceAccessor(histoSvc, IHistogramSvc, "HistogramDataSvc", m_HDS)
    00913 serviceAccessor(exceptionSvc, IExceptionSvc, "ExceptionSvc", m_EXS)
    00914 serviceAccessor(ntupleSvc, INTupleSvc, "NTupleSvc", m_NTS)
    00915 //serviceAccessor(atupleSvc, IAIDATupleSvc, "AIDATupleSvc", m_ATS)
    00916 serviceAccessor(randSvc, IRndmGenSvc, "RndmGenSvc", m_RGS)
    00917 serviceAccessor(toolSvc, IToolSvc, "ToolSvc", m_ptoolSvc)
    00918 serviceAccessor(contextSvc, IAlgContextSvc,"AlgContextSvc", m_contextSvc)
    00919
    00920
    00921 // Obsoleted name, kept due to the backwards compatibility
    00922 SmartIF<IChronoStatSvc>& Algorithm::chronoStatService() const {
    00923   return chronoSvc();
    00924 }
    00925 // Obsoleted name, kept due to the backwards compatibility
    00926 SmartIF<IDataProviderSvc>& Algorithm::detDataService() const {
    00927   return detSvc();
    00928 }
    00929 // Obsoleted name, kept due to the backwards compatibility
    00930 SmartIF<IConversionSvc>& Algorithm::detDataCnvService() const {
    00931   return detCnvSvc();
    00932 }
    00933 // Obsoleted name, kept due to the backwards compatibility
    00934 SmartIF<IDataProviderSvc>& Algorithm::eventDataService() const {
    00935   return eventSvc();
    00936 }
    00937 // Obsoleted name, kept due to the backwards compatibility
    00938 SmartIF<IConversionSvc>& Algorithm::eventDataCnvService() const {
    00939   return eventCnvSvc();
    00940 }
    00941 // Obsoleted name, kept due to the backwards compatibility
    00942 SmartIF<IHistogramSvc>& Algorithm::histogramDataService() const {
    00943   return histoSvc();
    00944 }
    00945 // Obsoleted name, kept due to the backwards compatibility
    00946 SmartIF<IMessageSvc>& Algorithm::messageService() const {
    00947   return msgSvc();
    00948 }
    00949 // Obsoleted name, kept due to the backwards compatibility
    00950 SmartIF<INTupleSvc>& Algorithm::ntupleService() const {
    00951   return ntupleSvc();
    00952 }
    00953
    00954 #if 0
    00955 IAuditorSvc* Algorithm::auditorSvc() const {
    00956   if ( 0 == m_pAuditorSvc ) {
    00957     StatusCode sc = service( "AuditorSvc", m_pAuditorSvc, true );
    00958     if( sc.isFailure() ) {
    00959       throw GaudiException("Service [AuditorSvc] not found", name(), sc);
    00960     }
    00961   }
    00962   return m_pAuditorSvc;
    00963 }
    00964
    00965 IChronoStatSvc* Algorithm::chronoSvc() const {
    00966   if ( 0 == m_CSS ) {
    00967     StatusCode sc = service( "ChronoStatSvc", m_CSS, true );
    00968     if( sc.isFailure() ) {
    00969       throw GaudiException("Service [ChronoStatSvc] not found", name(), sc);
    00970     }
    00971   }
    00972   return m_CSS;
    00973 }
    00974
    00975 IDataProviderSvc* Algorithm::detSvc() const {
    00976   if ( 0 == m_DDS ) {
    00977     StatusCode sc = service( "DetectorDataSvc", m_DDS, true );
    00978     if( sc.isFailure() ) {
    00979       throw GaudiException("Service [DetectorDataSvc] not found", name(), sc);
    00980     }
    00981   }
    00982   return m_DDS;
    00983 }
    00984
    00985 IConversionSvc* Algorithm::detCnvSvc() const {
    00986   if ( 0 == m_DCS ) {
    00987     StatusCode sc = service( "DetectorPersistencySvc", m_DCS, true );
    00988     if( sc.isFailure() ) {
    00989       throw GaudiException("Service [DetectorPersistencySvc] not found",
    00990                            name(), sc);
    00991     }
    00992   }
    00993   return m_DCS;
    00994 }
    00995
    00996 IDataProviderSvc* Algorithm::eventSvc() const {
    00997   if ( 0 == m_EDS ) {
    00998     StatusCode sc = service( "EventDataSvc", m_EDS, true );
    00999     if( sc.isFailure() ) {
    01000       throw GaudiException("Service [EventDataSvc] not found", name(), sc);
    01001     }
    01002   }
    01003   return m_EDS;
    01004 }
    01005
    01006 IConversionSvc* Algorithm::eventCnvSvc() const {
    01007   if ( 0 == m_ECS ) {
    01008     StatusCode sc = service( "EventPersistencySvc", m_ECS, true );
    01009     if( sc.isFailure() ) {
    01010       throw GaudiException("Service [EventPersistencySvc] not found",
    01011                            name(), sc);
    01012     }
    01013   }
    01014   return m_ECS;
    01015 }
    01016
    01017 IHistogramSvc* Algorithm::histoSvc() const {
    01018   if ( 0 == m_HDS ) {
    01019     StatusCode sc = service( "HistogramDataSvc", m_HDS, true );
    01020     if( sc.isFailure() ) {
    01021       throw GaudiException("Service [HistogramDataSvc] not found", name(), sc);
    01022     }
    01023   }
    01024   return m_HDS;
    01025 }
    01026
    01027 IExceptionSvc* Algorithm::exceptionSvc() const {
    01028   if ( 0 == m_EXS ) {
    01029     StatusCode sc = service( "ExceptionSvc", m_EXS, true );
    01030     if( sc.isFailure() ) {
    01031       throw GaudiException("Service [ExceptionSvc] not found", name(), sc);
    01032     }
    01033   }
    01034   return m_EXS;
    01035 }
    01036
    01037 IMessageSvc* Algorithm::msgSvc() const {
    01038   if ( 0 == m_MS ) {
    01039     //can not use service() method (infinite recursion!)
    01040     StatusCode sc = serviceLocator()->service( "MessageSvc", m_MS, true );
    01041     if( sc.isFailure() ) {
    01042       throw GaudiException("Service [MessageSvc] not found", name(), sc);
    01043     }
    01044   }
    01045   return m_MS;
    01046 }
    01047
    01048 INTupleSvc* Algorithm::ntupleSvc() const {
    01049   if ( 0 == m_NTS ) {
    01050     StatusCode sc = service( "NTupleSvc", m_NTS, true );
    01051     if( sc.isFailure() ) {
    01052       throw GaudiException("Service [NTupleSvc] not found", name(), sc);
    01053     }
    01054   }
    01055   return m_NTS;
    01056 }
    01057
    01058 // AIDATupleSvc:
    01059 // IAIDATupleSvc* Algorithm::atupleSvc() const {
    01060 //   if ( 0 == m_ATS ) {
    01061 //     StatusCode sc = service( "AIDATupleSvc", m_ATS, true );
    01062 //     if( sc.isFailure() ) {
    01063 //       throw GaudiException("Service [AIDATupleSvc] not found", name(), sc);
    01064 //     }
    01065 //   }
    01066 //   return m_ATS;
    01067 // }
    01068
    01069 IRndmGenSvc* Algorithm::randSvc() const {
    01070   if ( 0 == m_RGS ) {
    01071     StatusCode sc = service( "RndmGenSvc", m_RGS, true );
    01072     if( sc.isFailure() ) {
    01073       throw GaudiException("Service [RndmGenSvc] not found", name(), sc);
    01074     }
    01075   }
    01076   return m_RGS;
    01077 }
    01078
    01079 IToolSvc* Algorithm::toolSvc() const {
    01080   if ( 0 == m_ptoolSvc ) {
    01081     StatusCode sc = service( "ToolSvc", m_ptoolSvc, true );
    01082     if( sc.isFailure() ) {
    01083       throw GaudiException("Service [ToolSvc] not found", name(), sc);
    01084     }
    01085   }
    01086   return m_ptoolSvc;
    01087 }
    01088 #endif
    01089
    01090 SmartIF<ISvcLocator>& Algorithm::serviceLocator() const {
    01091   return *const_cast<SmartIF<ISvcLocator>*>(&m_pSvcLocator);
    01092 }
    01093
    01094 // Use the job options service to set declared properties
    01095 StatusCode Algorithm::setProperties() {
    01096   if( m_pSvcLocator != 0 )    {
    01097     SmartIF<IJobOptionsSvc> jos(m_pSvcLocator->service("JobOptionsSvc"));
    01098     if( jos.isValid() ) {
    01099       // set first generic Properties
    01100       StatusCode sc = jos->setMyProperties( getGaudiThreadGenericName(name()), this );
    01101       if( sc.isFailure() ) return StatusCode::FAILURE;
    01102
    01103       // set specific Properties
    01104       if (isGaudiThreaded(name())) {
    01105         if(jos->setMyProperties( name(), this ).isFailure()) {
    01106           return StatusCode::FAILURE;
    01107         }
    01108       }
    01109       return sc;
    01110     }
    01111   }
    01112   return StatusCode::FAILURE;
    01113 }
    01114
    01115 StatusCode Algorithm::createSubAlgorithm(const std::string& type,
    01116                                          const std::string& name,
    01117                                          Algorithm*& pSubAlgorithm) {
    01118   if( m_pSvcLocator == 0 ) return StatusCode::FAILURE;
    01119
    01120   SmartIF<IAlgManager> am(m_pSvcLocator);
    01121   if ( !am.isValid() ) return StatusCode::FAILURE;
    01122
    01123   // Maybe modify the AppMgr interface to return Algorithm* ??
    01124   IAlgorithm *tmp;
    01125   StatusCode sc = am->createAlgorithm
    01126     (type, name+getGaudiThreadIDfromName(Algorithm::name()), tmp);
    01127   if( sc.isFailure() ) return StatusCode::FAILURE;
    01128
    01129   try{
    01130     pSubAlgorithm = dynamic_cast<Algorithm*>(tmp);
    01131     m_subAlgms->push_back(pSubAlgorithm);
    01132   } catch(...){
    01133     sc = StatusCode::FAILURE;
    01134   }
    01135   return sc;
    01136 }
    01137
    01138 // IProperty implementation
    01139 // Delegate to the Property manager
    01140 StatusCode Algorithm::setProperty(const Property& p) {
    01141   return m_propertyMgr->setProperty(p);
    01142 }
    01143 StatusCode Algorithm::setProperty(const std::string& s) {
    01144   return m_propertyMgr->setProperty(s);
    01145 }
    01146 StatusCode Algorithm::setProperty(const std::string& n, const std::string& v) {
    01147   return m_propertyMgr->setProperty(n,v);
    01148 }
    01149 StatusCode Algorithm::getProperty(Property* p) const {
    01150   return m_propertyMgr->getProperty(p);
    01151 }
    01152 const Property& Algorithm::getProperty( const std::string& name) const{
    01153   return m_propertyMgr->getProperty(name);
    01154 }
    01155 StatusCode Algorithm::getProperty(const std::string& n, std::string& v ) const {
    01156   return m_propertyMgr->getProperty(n,v);
    01157 }
    01158 const std::vector<Property*>& Algorithm::getProperties( ) const {
    01159   return m_propertyMgr->getProperties();
    01160 }
    01161
    01165 void
    01166 Algorithm::initOutputLevel(Property& /*prop*/)
    01167 {
    01168   // do nothing... yet ?
    01169 }
    01170
    01171 StatusCode
    01172 Algorithm::service_i(const std::string& svcName,
    01173                      bool createIf,
    01174                      const InterfaceID& iid,
    01175                      void** ppSvc) const {
    01176   const ServiceLocatorHelper helper(*serviceLocator(), *this);
    01177   return helper.getService(svcName, createIf, iid, ppSvc);
    01178 }
    01179
    01180 StatusCode
    01181 Algorithm::service_i(const std::string& svcType,
    01182                      const std::string& svcName,
    01183                      const InterfaceID& iid,
    01184                      void** ppSvc) const {
    01185   const ServiceLocatorHelper helper(*serviceLocator(), *this);
    01186   return helper.createService(svcType, svcName, iid, ppSvc);
    01187 }
    01188
    01189 SmartIF<IService> Algorithm::service(const std::string& name, const bool createIf, const bool quiet) const {
    01190   const ServiceLocatorHelper helper(*serviceLocator(), *this);
    01191   return helper.service(name, quiet, createIf);
    01192 }