| # Gaudi Framework, version v20r2
Generated: 18 Jul 2008

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

- Search for |

- File List
- File Members

# Sequencer.cpp

Go to the documentation of this file.

    00001 //$Id: Sequencer.cpp,v 1.7 2008/06/02 14:22:04 marcocle Exp $
    00002
    00003 // Sequencer class
    00004 // Implements:
    00005 // 1) Common functionality of IInterface
    00006 // 2) Default behaviour for the IAlgorithm
    00007
    00008 #include "GaudiAlg/Sequencer.h"
    00009
    00010 #include "GaudiKernel/IAlgManager.h"
    00011 #include "GaudiKernel/ISvcLocator.h"
    00012 #include "GaudiKernel/AlgFactory.h"
    00013 #include "GaudiKernel/MsgStream.h"
    00014 #include "GaudiKernel/Chrono.h"
    00015 #include "GaudiKernel/Stat.h"
    00016 #include "GaudiKernel/GaudiException.h"
    00017
    00021 Sequencer::Sequencer( const std::string& name, ISvcLocator* pSvcLocator )
    00022 : Algorithm( name, pSvcLocator ),
    00023   m_branchFilterPassed( false )
    00024 {
    00025
    00026   // Create vector of branch algorithms
    00027   m_branchAlgs = new std::vector<Algorithm*>();
    00028
    00029   // Declare Sequencer properties with their defaults
    00030   declareProperty( "Members", m_names );
    00031   declareProperty( "BranchMembers", m_branchNames );
    00032   declareProperty( "StopOverride", m_stopOverride=false );
    00033
    00034   // Associate action handlers with the "Members" and "BranchMembers" properties
    00035   m_names.declareUpdateHandler      ( &Sequencer::membershipHandler      , this );
    00036   m_branchNames.declareUpdateHandler( &Sequencer::branchMembershipHandler, this );
    00037
    00038 }
    00039
    00043 Sequencer::~Sequencer()
    00044 {
    00045   delete m_branchAlgs;
    00046 }
    00047
    00048 StatusCode
    00049 Sequencer::initialize()
    00050 {
    00051   StatusCode result = StatusCode::SUCCESS;
    00052   MsgStream log( msgSvc( ), name( ) );
    00053
    00054   std::vector<Algorithm*>* theAlgs;
    00055   std::vector<Algorithm*>::iterator it;
    00056   std::vector<Algorithm*>::iterator itend;
    00057
    00058   result = decodeMemberNames();
    00059   if( result.isFailure() ) {
    00060     log << MSG::ERROR << "Unable to configure one or more sequencer members " << endreq;
    00061     return result;
    00062   }
    00063   result = decodeBranchMemberNames();
    00064   if( result.isFailure() ) {
    00065     log << MSG::ERROR << "Unable to configure one or more branch members " << endreq;
    00066     return result;
    00067   }
    00068
    00069   // Loop over all sub-algorithms
    00070   theAlgs = subAlgorithms( );
    00071   itend   = theAlgs->end( );
    00072   for (it = theAlgs->begin(); it != itend; it++) {
    00073     Algorithm* theAlgorithm = (*it);
    00074     result = theAlgorithm->sysInitialize( );
    00075     if( result.isFailure() ) {
    00076       log << MSG::ERROR << "Unable to initialize Algorithm " << theAlgorithm->name() << endreq;
    00077       return result;
    00078     }
    00079   }
    00080
    00081   // Loop over all branches
    00082   theAlgs = branchAlgorithms( );
    00083   itend   = theAlgs->end( );
    00084   for (it = theAlgs->begin(); it != itend; it++) {
    00085     Algorithm* theAlgorithm = (*it);
    00086     result = theAlgorithm->sysInitialize( );
    00087     if( result.isFailure() ) {
    00088       log << MSG::ERROR << "Unable to initialize Algorithm " << theAlgorithm->name() << endreq;
    00089       return result;
    00090     }
    00091   }
    00092
    00093   return result;
    00094 }
    00095
    00096 StatusCode
    00097 Sequencer::reinitialize()
    00098 {
    00099   // Bypass the loop if this sequencer is disabled
    00100   if ( isEnabled( ) ) {
    00101
    00102     // Loop over all members calling their reinitialize functions
    00103     // if they are not disabled.
    00104     std::vector<Algorithm*>* theAlgms = subAlgorithms( );
    00105     std::vector<Algorithm*>::iterator it;
    00106     std::vector<Algorithm*>::iterator itend = theAlgms->end( );
    00107     for (it = theAlgms->begin(); it != itend; it++) {
    00108       Algorithm* theAlgorithm = (*it);
    00109       if ( ! theAlgorithm->isEnabled( ) ) {
    00110         theAlgorithm->reinitialize( ).ignore();
    00111       }
    00112     }
    00113     // Loop over all branch members calling their reinitialize functions
    00114     // if they are not disabled.
    00115     theAlgms = branchAlgorithms( );
    00116     itend    = theAlgms->end( );
    00117     for (it = theAlgms->begin(); it != itend; it++) {
    00118       Algorithm* theAlgorithm = (*it);
    00119       if ( ! theAlgorithm->isEnabled( ) ) {
    00120         theAlgorithm->reinitialize( ).ignore();
    00121       }
    00122     }
    00123
    00124   }
    00125   return StatusCode::SUCCESS;
    00126 }
    00127
    00128 StatusCode
    00129 Sequencer::execute()
    00130 {
    00131   StatusCode result = StatusCode::SUCCESS;
    00132   MsgStream log( msgSvc( ), name( ) );
    00133
    00134   log << MSG::DEBUG << name( ) << " Sequencer::execute( )" << endreq;
    00135
    00136   // Bypass the loop if this sequencer is disabled or has already been executed
    00137   if ( isEnabled( ) && ! isExecuted( ) ) {
    00138     Algorithm* lastAlgorithm;
    00139     result = execute( subAlgorithms( ), m_isInverted, lastAlgorithm );
    00140     if ( result.isSuccess( ) ) {
    00141       bool passed = filterPassed( );
    00142       if ( ! passed && ! isStopOverride( ) ) {
    00143
    00144         // Filter failed and stop override not set. Execute the
    00145         // branch if there is one associated with the filter
    00146         // algorithm that failed. Note that the first member on
    00147         // the branch is the failing algorithm and so should
    00148         // be skipped.
    00149         std::vector<Algorithm*>* theAlgs = branchAlgorithms( );
    00150         if ( theAlgs->size( ) > 0 ) {
    00151           Algorithm* branchAlgorithm = (*theAlgs)[0];
    00152           if ( lastAlgorithm == branchAlgorithm ) {
    00153
    00154             // Branch specified - Loop over branch members
    00155             result = execute( branchAlgorithms( ),
    00156                               m_isBranchInverted,
    00157                               lastAlgorithm, 1 );
    00158             if ( result.isSuccess( ) ) {
    00159
    00160               // The final filter passed state will be set true if either
    00161               // of the main or branches passed, otherwise false.
    00162
    00163               // Save the branch  filter passed state.
    00164               setBranchFilterPassed( filterPassed( ) ).ignore();
    00165             }
    00166           }
    00167         }
    00168       }
    00169     }
    00170
    00171     // Prevent multiple executions of this sequencer for the current event
    00172     setExecuted( true );
    00173   }
    00174   return result;
    00175 }
    00176
    00177 StatusCode
    00178 Sequencer::finalize()
    00179 {
    00180   // Loop over all branch members calling their finalize functions
    00181   // if they are not disabled. Note that the Algoriithm::sysFinalize
    00182   // function already does this for the main members.
    00183   std::vector<Algorithm*>* theAlgs = branchAlgorithms( );
    00184   std::vector<Algorithm*>::iterator it;
    00185   std::vector<Algorithm*>::iterator itend = theAlgs->end( );
    00186   for (it = theAlgs->begin(); it != itend; it++) {
    00187     Algorithm* theAlgorithm = (*it);
    00188     if (theAlgorithm->sysFinalize( ).isFailure()) {
    00189       MsgStream log( msgSvc( ), name( ) );
    00190       log << MSG::ERROR << "Unable to finalize Algorithm "
    00191           << theAlgorithm->name() << endreq;
    00192     }
    00193   }
    00194   return StatusCode::SUCCESS;
    00195 }
    00196
    00197 StatusCode
    00198 Sequencer::start()
    00199 {
    00200   StatusCode result = StatusCode::SUCCESS;
    00201   MsgStream log( msgSvc( ), name( ) );
    00202
    00203   std::vector<Algorithm*>* theAlgs;
    00204   std::vector<Algorithm*>::iterator it;
    00205   std::vector<Algorithm*>::iterator itend;
    00206
    00207   // Loop over all sub-algorithms
    00208   theAlgs = subAlgorithms( );
    00209   itend   = theAlgs->end( );
    00210   for (it = theAlgs->begin(); it != itend; it++) {
    00211     Algorithm* theAlgorithm = (*it);
    00212     result = theAlgorithm->sysStart( );
    00213     if( result.isFailure() ) {
    00214       log << MSG::ERROR << "Unable to start Algorithm " << theAlgorithm->name() << endreq;
    00215       return result;
    00216     }
    00217   }
    00218
    00219   // Loop over all branches
    00220   theAlgs = branchAlgorithms( );
    00221   itend   = theAlgs->end( );
    00222   for (it = theAlgs->begin(); it != itend; it++) {
    00223     Algorithm* theAlgorithm = (*it);
    00224     result = theAlgorithm->sysStart( );
    00225     if( result.isFailure() ) {
    00226       log << MSG::ERROR << "Unable to start Algorithm " << theAlgorithm->name() << endreq;
    00227       return result;
    00228     }
    00229   }
    00230
    00231   return result;
    00232 }
    00233
    00234 StatusCode
    00235 Sequencer::stop()
    00236 {
    00237   // Loop over all branch members calling their finalize functions
    00238   // if they are not disabled.
    00239   std::vector<Algorithm*>* theAlgs;
    00240   std::vector<Algorithm*>::iterator it;
    00241   std::vector<Algorithm*>::iterator itend;
    00242
    00243   theAlgs = subAlgorithms( );
    00244   itend   = theAlgs->end( );
    00245   for (it = theAlgs->begin(); it != itend; it++) {
    00246     Algorithm* theAlgorithm = (*it);
    00247     if (theAlgorithm->sysStop( ).isFailure()) {
    00248       MsgStream log( msgSvc( ), name( ) );
    00249       log << MSG::ERROR << "Unable to stop Algorithm "
    00250           << theAlgorithm->name() << endreq;
    00251     }
    00252   }
    00253
    00254   theAlgs = branchAlgorithms( );
    00255   itend   = theAlgs->end( );
    00256   for (it = theAlgs->begin(); it != itend; it++) {
    00257     Algorithm* theAlgorithm = (*it);
    00258     if (theAlgorithm->sysStop( ).isFailure()) {
    00259       MsgStream log( msgSvc( ), name( ) );
    00260       log << MSG::ERROR << "Unable to stop Algorithm "
    00261           << theAlgorithm->name() << endreq;
    00262     }
    00263   }
    00264   return StatusCode::SUCCESS;
    00265 }
    00266
    00267 StatusCode
    00268 Sequencer::beginRun()
    00269 {
    00270   StatusCode result = StatusCode::SUCCESS;
    00271   MsgStream log( msgSvc( ), name( ) );
    00272
    00273   // Bypass the loop if this sequencer is disabled
    00274   if ( isEnabled( ) ) {
    00275
    00276     // Loop over all members calling their sysInitialize functions
    00277     // if they are not disabled. Note that the Algoriithm::sysInitialize
    00278     // function protects this from affecting Algorithms that have already
    00279     // been initialized.
    00280     std::vector<Algorithm*>* theAlgs = subAlgorithms( );
    00281     std::vector<Algorithm*>::iterator it;
    00282     std::vector<Algorithm*>::iterator itend = theAlgs->end( );
    00283     for (it = theAlgs->begin(); it != itend; it++) {
    00284       Algorithm* theAlgorithm = (*it);
    00285       result = theAlgorithm->sysInitialize( );
    00286       if( result.isFailure() ) {
    00287         log << MSG::ERROR << "Unable to initialize Algorithm " << theAlgorithm->name() << endreq;
    00288         break;
    00289       }
    00290       result = theAlgorithm->sysStart( );
    00291       if( result.isFailure() ) {
    00292         log << MSG::ERROR << "Unable to start Algorithm " << theAlgorithm->name() << endreq;
    00293         break;
    00294       }
    00295     }
    00296
    00297     // Loop over all members calling their beginRun functions
    00298     // if they are not disabled.
    00299     for (it = theAlgs->begin(); it != itend; it++) {
    00300       Algorithm* theAlgorithm = (*it);
    00301       if ( ! theAlgorithm->isEnabled( ) ) {
    00302         theAlgorithm->beginRun( ).ignore();
    00303       }
    00304     }
    00305
    00306     // Loop over all branch members calling their sysInitialize functions
    00307     // if they are not disabled. Note that the Algoriithm::sysInitialize
    00308     // function protects this from affecting Algorithms that have already
    00309     // been initialized.
    00310     theAlgs = branchAlgorithms( );
    00311     itend   = theAlgs->end( );
    00312     for (it = theAlgs->begin(); it != itend; it++) {
    00313       Algorithm* theAlgorithm = (*it);
    00314       result = theAlgorithm->sysInitialize( );
    00315       if( result.isFailure() ) {
    00316         log << MSG::ERROR << "Unable to initialize Algorithm " << theAlgorithm->name() << endreq;
    00317         break;
    00318       }
    00319       result = theAlgorithm->sysStart( );
    00320       if( result.isFailure() ) {
    00321         log << MSG::ERROR << "Unable to start Algorithm " << theAlgorithm->name() << endreq;
    00322         break;
    00323       }
    00324     }
    00325
    00326     // Loop over all branch members calling their beginRun functions
    00327     // if they are not disabled.
    00328     for (it = theAlgs->begin(); it != itend; it++) {
    00329       Algorithm* theAlgorithm = (*it);
    00330       if ( ! theAlgorithm->isEnabled( ) ) {
    00331         theAlgorithm->beginRun( ).ignore();
    00332       }
    00333     }
    00334   }
    00335   return StatusCode::SUCCESS;
    00336 }
    00337
    00338 StatusCode
    00339 Sequencer::endRun()
    00340 {
    00341   // Bypass the loop if this sequencer is disabled
    00342   if ( isEnabled( ) ) {
    00343
    00344     // Loop over all members calling their endRun functions
    00345     // if they are not disabled.
    00346     std::vector<Algorithm*>* theAlgms = subAlgorithms( );
    00347     std::vector<Algorithm*>::iterator it;
    00348     std::vector<Algorithm*>::iterator itend = theAlgms->end( );
    00349     for (it = theAlgms->begin(); it != itend; it++) {
    00350       Algorithm* theAlgorithm = (*it);
    00351       if ( ! theAlgorithm->isEnabled( ) ) {
    00352         theAlgorithm->endRun( ).ignore();
    00353       }
    00354     }
    00355     // Loop over all branch members calling their endRun functions
    00356     // if they are not disabled.
    00357     theAlgms = branchAlgorithms( );
    00358     itend    = theAlgms->end( );
    00359     for (it = theAlgms->begin(); it != itend; it++) {
    00360       Algorithm* theAlgorithm = (*it);
    00361       if ( ! theAlgorithm->isEnabled( ) ) {
    00362         theAlgorithm->endRun( ).ignore();
    00363       }
    00364     }
    00365   }
    00366   return StatusCode::SUCCESS;
    00367 }
    00368
    00369 void
    00370 Sequencer::resetExecuted( )
    00371 {
    00372   Algorithm::resetExecuted( );
    00373
    00374   // Loop over all members calling their resetExecuted functions
    00375   // if they are not disabled.
    00376   std::vector<Algorithm*>* subAlgms = subAlgorithms( );
    00377   std::vector<Algorithm*>::iterator it;
    00378   std::vector<Algorithm*>::iterator itend = subAlgms->end( );
    00379   for (it = subAlgms->begin(); it != itend; it++) {
    00380     Algorithm* theAlgorithm = (*it);
    00381     theAlgorithm->resetExecuted( );
    00382   }
    00383
    00384   // Loop over all branch members calling their resetExecuted functions
    00385   // if they are not disabled.
    00386   subAlgms = branchAlgorithms( );
    00387   itend    = subAlgms->end( );
    00388   for (it = subAlgms->begin(); it != itend; it++) {
    00389     Algorithm* theAlgorithm = (*it);
    00390     theAlgorithm->resetExecuted( );
    00391   }
    00392
    00393   // Reset the branch filter passed flag
    00394   m_branchFilterPassed = false;
    00395 }
    00396
    00397 bool
    00398 Sequencer::branchFilterPassed( ) const
    00399 {
    00400   return m_branchFilterPassed;
    00401 }
    00402
    00403 StatusCode
    00404 Sequencer::setBranchFilterPassed( bool state )
    00405 {
    00406   m_branchFilterPassed = state;
    00407   return StatusCode::SUCCESS;
    00408 }
    00409
    00410 bool
    00411 Sequencer::isStopOverride( ) const
    00412 {
    00413   return m_stopOverride.value( );
    00414 }
    00415
    00416 StatusCode
    00417 Sequencer::append( Algorithm* pAlgorithm )
    00418 {
    00419   StatusCode result = append( pAlgorithm, subAlgorithms( ) );
    00420   return result;
    00421 }
    00422
    00423 StatusCode
    00424 Sequencer::appendToBranch( Algorithm* pAlgorithm )
    00425 {
    00426   StatusCode result = append( pAlgorithm, branchAlgorithms( ) );
    00427   return result;
    00428 }
    00429
    00430 StatusCode
    00431 Sequencer::createAndAppend( const std::string& type,
    00432                             const std::string& name,
    00433                             Algorithm*& pAlgorithm )
    00434 {
    00435   StatusCode result = createAndAppend( type, name, pAlgorithm, subAlgorithms( ) );
    00436   return result;
    00437 }
    00438
    00439 StatusCode
    00440 Sequencer::createAndAppendToBranch( const std::string& type,
    00441                                     const std::string& name,
    00442                                     Algorithm*& pAlgorithm )
    00443 {
    00444   StatusCode result = createAndAppend( type, name, pAlgorithm, branchAlgorithms( ) );
    00445   return result;
    00446 }
    00447
    00448 StatusCode
    00449 Sequencer::remove( Algorithm* pAlgorithm )
    00450 {
    00451   std::string theName = pAlgorithm->name( );
    00452   StatusCode result = remove( theName );
    00453   return result;
    00454 }
    00455
    00456 StatusCode
    00457 Sequencer::remove( const std::string& algname )
    00458 {
    00459   StatusCode result = remove( algname, subAlgorithms( ) );
    00460   return result;
    00461 }
    00462
    00463 StatusCode
    00464 Sequencer::removeFromBranch( Algorithm* pAlgorithm )
    00465 {
    00466   std::string theName = pAlgorithm->name( );
    00467   StatusCode result = removeFromBranch( theName );
    00468   return result;
    00469 }
    00470
    00471 StatusCode
    00472 Sequencer::removeFromBranch( const std::string& algname )
    00473 {
    00474   StatusCode result = remove( algname, branchAlgorithms( ) );
    00475   return result;
    00476 }
    00477
    00478 std::vector<Algorithm*>*
    00479 Sequencer::branchAlgorithms( ) const {
    00480   return m_branchAlgs;
    00481 }
    00482
    00483 StatusCode
    00484 Sequencer::decodeMemberNames( )
    00485 {
    00486   StatusCode result = StatusCode::SUCCESS;
    00487
    00488   // Decode the membership list
    00489   result = decodeNames( m_names,
    00490                         subAlgorithms( ),
    00491                         m_isInverted );
    00492
    00493   return result;
    00494 }
    00495
    00496 void
    00497 Sequencer::membershipHandler( Property& /* theProp */ )
    00498 {
    00499   if ( isInitialized() ) decodeMemberNames();
    00500 }
    00501
    00502 StatusCode
    00503 Sequencer::decodeBranchMemberNames( )
    00504 {
    00505   StatusCode result = StatusCode::SUCCESS;
    00506
    00507   // Decode the branch membership list
    00508   result = decodeNames( m_branchNames,
    00509                         branchAlgorithms( ),
    00510                         m_isBranchInverted );
    00511
    00512   return result;
    00513 }
    00514
    00515 void
    00516 Sequencer::branchMembershipHandler( Property& /* theProp */ )
    00517 {
    00518   if ( isInitialized() ) decodeBranchMemberNames();
    00519 }
    00520
    00525 StatusCode
    00526 Sequencer::append( Algorithm* pAlgorithm,
    00527                    std::vector<Algorithm*>* theAlgs )
    00528 {
    00529   StatusCode result = StatusCode::SUCCESS;
    00530   // Check that the specified algorithm doesn't already exist in the membership list
    00531   std::vector<Algorithm*>::iterator it;
    00532   std::vector<Algorithm*>::iterator itend = theAlgs->end( );
    00533   for (it = theAlgs->begin(); it != itend; it++) {
    00534     Algorithm* theAlgorithm = (*it);
    00535     if ( theAlgorithm == pAlgorithm ) {
    00536       result = StatusCode::FAILURE;
    00537       break;
    00538     }
    00539   }
    00540   if ( result.isSuccess( ) ) {
    00541     theAlgs->push_back( pAlgorithm );
    00542     pAlgorithm->addRef();
    00543   }
    00544   return result;
    00545 }
    00546
    00547 StatusCode
    00548 Sequencer::createAndAppend( const std::string& type,
    00549                                 const std::string& algName,
    00550                                 Algorithm*& pAlgorithm,
    00551                                 std::vector<Algorithm*>* theAlgs )
    00552 {
    00553   StatusCode result = StatusCode::FAILURE;
    00554   MsgStream log( msgSvc( ), name( ) );
    00555   IAlgManager* theAlgMgr = 0;
    00556   //result = service( "ApplicationMgr", theAlgMgr );
    00557   result = serviceLocator()->getService( "ApplicationMgr",
    00558                                        IID_IAlgManager,
    00559                                        *pp_cast<IInterface>(&theAlgMgr) );
    00560   if ( result.isSuccess( ) ) {
    00561     IAlgorithm* tmp;
    00562     result = theAlgMgr->createAlgorithm( type, algName, tmp );
    00563     if ( result.isSuccess( ) ) {
    00564       try{
    00565         pAlgorithm = dynamic_cast<Algorithm*>(tmp);
    00566         theAlgs->push_back( pAlgorithm );
    00567       } catch(...){
    00568         log << MSG::ERROR << "Unable to create Algorithm " << algName << endreq;
    00569         result = StatusCode::FAILURE;
    00570       }
    00571     }
    00572         }
    00573   theAlgMgr->release();
    00574         return result;
    00575 }
    00576
    00577 StatusCode
    00578 Sequencer::decodeNames( StringArrayProperty& theNames,
    00579                         std::vector<Algorithm*>* theAlgs,
    00580                         std::vector<bool>& theLogic )
    00581 {
    00582   StatusCode result;
    00583   MsgStream log( msgSvc( ), name( ) );
    00584   IAlgManager* theAlgMgr = 0;
    00585   //result = service( "ApplicationMgr", theAlgMgr );
    00586   result = serviceLocator()->getService( "ApplicationMgr",
    00587                                          IID_IAlgManager,
    00588                                          *pp_cast<IInterface>(&theAlgMgr) );
    00589
    00590   if ( result.isSuccess( ) ) {
    00591
    00592     // Clear the existing list of algorithms
    00593     theAlgs->clear( );
    00594
    00595     // Build the list of member algorithms from the contents of the
    00596     // theNames list.
    00597     const std::vector<std::string>& theNameVector = theNames.value( );
    00598     std::vector<std::string>::const_iterator it;
    00599     std::vector<std::string>::const_iterator itend = theNameVector.end( );
    00600     for (it = theNameVector.begin(); it != itend; it++) {
    00601
    00602       // Parse the name for a syntax of the form:
    00603       //
    00604       // <type>/<name>
    00605       //
    00606       // Where <name> is the algorithm instance name, and <type> is the
    00607       // algorithm class type (being a subclass of Algorithm).
    00608       std::string theName = (*it);
    00609       std::string theType = (*it);
    00610       std::string::size_type slash = (*it).find_first_of( "/" );
    00611       if ( std::string::npos != slash ) {
    00612         theType = (*it).substr( 0, slash );
    00613         theName = (*it).substr( slash+1 );
    00614       }
    00615
    00616       // Parse the name for a syntax of the form:
    00617       //
    00618       // <name>:invert
    00619       //
    00620       // Where <name> is the algorithm instance name and ":invert"
    00621       // indicates that the filter passed logic is inverted.
    00622       bool isInverted = false;
    00623       std::string::size_type invert = theName.find_first_of( ":" );
    00624       while ( std::string::npos != invert
    00625               && invert < (theName.size() - 1) && theName[invert+1] == ':' )
    00626         invert = theName.find_first_of( ":", invert+2 );
    00627       if ( std::string::npos != invert ) {
    00628         if ( theName == theType ) {
    00629           // This means that we got something like "Type:invert",
    00630           // so we have to strip the ":invert" from the type too.
    00631           theType = theType.substr( 0, invert );
    00632         }
    00633         theName = theName.substr( 0, invert );
    00634         isInverted = true;
    00635       }
    00636       // Check whether the suppied name corresponds to an existing
    00637       // Algorithm object.
    00638       IAlgorithm* theIAlg;
    00639       Algorithm*  theAlgorithm;
    00640       StatusCode status = theAlgMgr->getAlgorithm( theName, theIAlg );
    00641       if ( status.isSuccess( ) ) {
    00642         try{
    00643           theAlgorithm = dynamic_cast<Algorithm*>(theIAlg);
    00644         } catch(...){
    00645           log << MSG::WARNING << theName << " is not an Algorithm - Failed dynamic cast" << endreq;
    00646           status = StatusCode::FAILURE;
    00647         }
    00648       }
    00649       if ( status.isSuccess( ) ) {
    00650
    00651         // The specified Algorithm already exists - just append it to the membership list.
    00652         status = append( theAlgorithm, theAlgs );
    00653         if ( status.isSuccess( ) ) {
    00654           log << MSG::DEBUG << theName << " already exists - appended to member list" << endreq;
    00655         } else {
    00656           log << MSG::WARNING << theName << " already exists - append failed!!!" << endreq;
    00657           result = StatusCode::FAILURE;
    00658         }
    00659       } else {
    00660
    00661         // The specified name doesn't exist - create a new object of the specified type
    00662         // and append it to the membership list.
    00663         status = createAndAppend( theType, theName, theAlgorithm, theAlgs );
    00664         if ( status.isSuccess( ) ) {
    00665           log << MSG::DEBUG << theName << " doesn't exist - created and appended to member list" << endreq;
    00666         } else {
    00667           log << MSG::WARNING << theName << " doesn't exist - creation failed!!!" << endreq;
    00668           result = StatusCode::FAILURE;
    00669         }
    00670       }
    00671       if ( status.isSuccess( ) ) {
    00672         theLogic.push_back( isInverted );
    00673       }
    00674     }
    00675
    00676   }
    00677   // Print membership list
    00678   if ( result.isSuccess() && theAlgs->size() != 0 ) {
    00679     log << MSG::INFO << "Member list: ";
    00680     std::vector<Algorithm*>::iterator ai = theAlgs->begin();
    00681     std::vector<bool>::iterator li = theLogic.begin();
    00682     for ( ; ai != theAlgs->end(); ++ai, ++li ) {
    00683
    00684       if ( ai != theAlgs->begin() ) log << ", ";
    00685
    00686       if ( (*ai)->name() == System::typeinfoName(typeid(**ai)) )
    00687         log << (*ai)->name();
    00688       else
    00689         log << System::typeinfoName(typeid(**ai)) << "/" << (*ai)->name();
    00690
    00691       if (*li) log << ":invert";
    00692     }
    00693     log << endmsg;
    00694   }
    00695   theAlgMgr->release();
    00696   return result;
    00697 }
    00698
    00699 StatusCode
    00700 Sequencer::execute( std::vector<Algorithm*>* theAlgs,
    00701                     std::vector<bool>& theLogic,
    00702                     Algorithm*& lastAlgorithm,
    00703                     unsigned int first )
    00704 {
    00705   StatusCode result = StatusCode::SUCCESS;
    00706
    00707   // Loop over all algorithms calling their execute functions if they
    00708   // are (a) not disabled, and (b) aren't already executed. Note that
    00709   // in the latter case the filter state is still examined. Terminate
    00710   // the loop if an algorithm indicates that it's filter didn't pass.
    00711   unsigned int size = theAlgs->size( );
    00712   for (unsigned int i = first; i < size; i++) {
    00713     lastAlgorithm = (*theAlgs)[i];
    00714     result = executeMember( lastAlgorithm );
    00715     if ( result.isSuccess( ) ) {
    00716
    00717       // Take the filter passed status of this algorithm as my own status.
    00718       // Note that we take into account inverted logic.
    00719       bool passed = lastAlgorithm->filterPassed( );
    00720       bool isInverted = theLogic[i];
    00721       if ( isInverted ) {
    00722         passed = ! passed;
    00723       }
    00724       setFilterPassed( passed );
    00725
    00726       // The behaviour when the filter fails depends on the StopOverride property.
    00727       // The default action is to stop processing, but this default can be
    00728       // overridden by setting the "StopOverride" property to true.
    00729       if ( ! isStopOverride( ) ) {
    00730         if ( ! passed ) break;
    00731       }
    00732     } else {
    00733       break;
    00734     }
    00735   }
    00736   return result;
    00737 }
    00738
    00739 StatusCode
    00740 Sequencer::executeMember( Algorithm* theAlgorithm )
    00741 {
    00742   StatusCode result = StatusCode::SUCCESS;
    00743   if ( theAlgorithm->isEnabled( ) ) {
    00744     if ( ! theAlgorithm->isExecuted( ) ) {
    00745       result = theAlgorithm->sysExecute( );
    00746
    00747       // Set the executed state of the algorithm.
    00748       // I think this should be done by the algorithm itself, but just in case...
    00749       theAlgorithm->setExecuted( true );
    00750     }
    00751   }
    00752   return result;
    00753 }
    00754
    00755 StatusCode
    00756 Sequencer::remove( const std::string& algname, std::vector<Algorithm*>* theAlgs )
    00757 {
    00758   MsgStream log( msgSvc( ), name( ) );
    00759   StatusCode result = StatusCode::FAILURE;
    00760
    00761   // Test that the algorithm exists in the member list
    00762   std::vector<Algorithm*>::iterator it;
    00763   std::vector<Algorithm*>::iterator itend = theAlgs->end( );
    00764   for (it = theAlgs->begin(); it != itend; it++) {
    00765     Algorithm* theAlgorithm = (*it);
    00766     if ( theAlgorithm->name( ) == algname ) {
    00767
    00768       // Algorithm with specified name exists in the algorithm list - remove it
    00769       // THIS ISN'T IMPLEMENTED YET!!!!
    00770       log << MSG::INFO <<"Sequencer::remove( ) isn't implemented yet!!!!!" << endreq;
    00771       result = StatusCode::SUCCESS;
    00772       break;
    00773     }
    00774   }
    00775   return result;
    00776 }