| # Gaudi Framework, version v21r10p1 |

Home |  | Generated: 29 Jul 2010

# Sequencer Class Reference

ClassName: Sequencer. More...

`#include <Sequencer.h>`

Inheritance diagram for Sequencer:

[legend]
Collaboration diagram for Sequencer:

[legend]

List of all members.

## Public Member Functions
| Sequencer (const std::string &name, ISvcLocator *svcloc)
| Constructor(s).
virtual | ~Sequencer ()
| Destructor.
virtual StatusCode | initialize ()
| Initialization of a sequencer.
virtual StatusCode | reinitialize ()
| Sequencer Reinitialization.
virtual StatusCode | start ()
| Sequencer finalization.
virtual StatusCode | execute ()
| The actions to be performed by the sequencer on an event.
virtual StatusCode | stop ()
| Sequencer finalization.
virtual StatusCode | finalize ()
| Sequencer finalization.
virtual StatusCode | beginRun ()
| Sequencer beginRun.
virtual StatusCode | endRun ()
| Sequencer endRun.
void | resetExecuted ()
| Reset the Sequencer executed state for the current event.
virtual bool | branchFilterPassed () const
| Was the branch filter passed for the last event?
virtual StatusCode | setBranchFilterPassed (bool state)
| Set the branch filter passed flag for the last event.
virtual bool | isStopOverride () const
| Has the StopOverride mode been set?
StatusCode | append (Algorithm *pAlgorithm)
| Append an algorithm to the sequencer.
StatusCode | appendToBranch (Algorithm *pAlgorithm)
| Append an algorithm to the sequencer branch.
StatusCode | createAndAppend (const std::string &type, const std::string &name, Algorithm *&pAlgorithm)
| Create a algorithm and append it to the sequencer.
StatusCode | createAndAppendToBranch (const std::string &type, const std::string &name, Algorithm *&pAlgorithm)
| Create a algorithm and append it to the sequencer branch.
StatusCode | remove (Algorithm *pAlgorithm)
| Remove the specified algorithm from the sequencer.
StatusCode | remove (const std::string &name)
StatusCode | removeFromBranch (Algorithm *pAlgorithm)
StatusCode | removeFromBranch (const std::string &name)
std::vector< Algorithm * > * | branchAlgorithms () const
| List of branch algorithms.
StatusCode | decodeMemberNames ()
| Decode Member Name list.
void | membershipHandler (Property &theProp)
| "Members" property handler
StatusCode | decodeBranchMemberNames ()
| Decode branch member name list.
void | branchMembershipHandler (Property &theProp)
| "BranchMembers" property handler
## Protected Member Functions
StatusCode | append (Algorithm *pAlgorithm, std::vector< Algorithm * > *theAlgs)
| Append an algorithm to the sequencer.
StatusCode | createAndAppend (const std::string &type, const std::string &name, Algorithm *&pAlgorithm, std::vector< Algorithm * > *theAlgs)
| Create a algorithm and append it to the sequencer.
StatusCode | decodeNames (StringArrayProperty &theNames, std::vector< Algorithm * > *theAlgs, std::vector< bool > &theLogic)
| Decode algorithm names, creating or appending algorithms as appropriate.
StatusCode | execute (std::vector< Algorithm * > *theAlgs, std::vector< bool > &theLogic, Algorithm *&lastAlgorithm, unsigned int first=0)
| Execute the members in the specified list.
StatusCode | executeMember (Algorithm *theAlgorithm)
| Execute member algorithm.
StatusCode | remove (const std::string &algname, std::vector< Algorithm * > *theAlgs)
| Remove the specified algorithm from the sequencer.
## Private Member Functions
| Sequencer (const Sequencer &a)
| Private Copy constructor: NO COPY ALLOWED.
Sequencer & | operator= (const Sequencer &rhs)
| Private assignment operator: NO ASSIGNMENT ALLOWED.
## Private Attributes
StringArrayProperty | m_names
std::vector< bool > | m_isInverted
StringArrayProperty | m_branchNames
std::vector< Algorithm * > * | m_branchAlgs
std::vector< bool > | m_isBranchInverted
BooleanProperty | m_stopOverride
bool | m_branchFilterPassed

## Detailed Description

ClassName: Sequencer.

Description: A Sequencer is essentially a list of Algorithms and is responsible for their management. Note that Sequences may themselves contain other Sequences. The default execute( ) implementation loops over the members of the sequence, calling their execute( ) methods. However, this can be modified if a member is disabled, has already been executed, or a member indicates that it's filter fails. The the former two cases the execution of the member is bypassed. In the latter case, the loop is terminated and the Sequencer assumes the same filtered state as the last member.

Definition at line 24 of file Sequencer.h.

## Constructor & Destructor Documentation

Sequencer::Sequencer | ( | const std::string & | name,
|  | ISvcLocator * | svcloc |
| ) |  |  |

Constructor(s).

Definition at line 21 of file Sequencer.cpp.

    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 }

Sequencer::~Sequencer | ( |  | ) | `[virtual]`

Destructor.

Definition at line 43 of file Sequencer.cpp.

    00044 {
    00045   delete m_branchAlgs;
    00046 }

Sequencer::Sequencer | ( | const Sequencer & | a | ) | `[private]`

Private Copy constructor: NO COPY ALLOWED.

## Member Function Documentation

StatusCode Sequencer::initialize | ( |  | ) | `[virtual]`

Initialization of a sequencer.

Typically things like histogram creation, setting up of data structures etc, should be done here. If a sequence has properties specified in the job options file, they will be set to the requested values BEFORE the initialize() method is invoked.

Reimplemented from Algorithm.

Definition at line 49 of file Sequencer.cpp.

    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 " << endmsg;
    00061     return result;
    00062   }
    00063   result = decodeBranchMemberNames();
    00064   if( result.isFailure() ) {
    00065     log << MSG::ERROR << "Unable to configure one or more branch members " << endmsg;
    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() << endmsg;
    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() << endmsg;
    00089       return result;
    00090     }
    00091   }
    00092
    00093   return result;
    00094 }

StatusCode Sequencer::reinitialize | ( |  | ) | `[virtual]`

Sequencer Reinitialization.

Reimplemented from Algorithm.

Definition at line 97 of file Sequencer.cpp.

    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 }

StatusCode Sequencer::start | ( |  | ) | `[virtual]`

Sequencer finalization.

Reimplemented from Algorithm.

Definition at line 198 of file Sequencer.cpp.

    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() << endmsg;
    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() << endmsg;
    00227       return result;
    00228     }
    00229   }
    00230
    00231   return result;
    00232 }

StatusCode Sequencer::execute | ( |  | ) | `[virtual]`

The actions to be performed by the sequencer on an event.

This method is invoked once per event.

Definition at line 129 of file Sequencer.cpp.

    00130 {
    00131   StatusCode result = StatusCode::SUCCESS;
    00132   MsgStream log( msgSvc( ), name( ) );
    00133
    00134   log << MSG::DEBUG << name( ) << " Sequencer::execute( )" << endmsg;
    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 }

StatusCode Sequencer::stop | ( |  | ) | `[virtual]`

Sequencer finalization.

Reimplemented from Algorithm.

Definition at line 235 of file Sequencer.cpp.

    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() << endmsg;
    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() << endmsg;
    00262     }
    00263   }
    00264   return StatusCode::SUCCESS;
    00265 }

StatusCode Sequencer::finalize | ( |  | ) | `[virtual]`

Sequencer finalization.

Reimplemented from Algorithm.

Definition at line 178 of file Sequencer.cpp.

    00179 {
    00180   // Loop over all branch members calling their finalize functions
    00181   // if they are not disabled. Note that the Algorithm::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() << endmsg;
    00192     }
    00193   }
    00194   return StatusCode::SUCCESS;
    00195 }

StatusCode Sequencer::beginRun | ( |  | ) | `[virtual]`

Sequencer beginRun.

Reimplemented from Algorithm.

Definition at line 268 of file Sequencer.cpp.

    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() << endmsg;
    00288         break;
    00289       }
    00290       result = theAlgorithm->sysStart( );
    00291       if( result.isFailure() ) {
    00292         log << MSG::ERROR << "Unable to start Algorithm " << theAlgorithm->name() << endmsg;
    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() << endmsg;
    00317         break;
    00318       }
    00319       result = theAlgorithm->sysStart( );
    00320       if( result.isFailure() ) {
    00321         log << MSG::ERROR << "Unable to start Algorithm " << theAlgorithm->name() << endmsg;
    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 }

StatusCode Sequencer::endRun | ( |  | ) | `[virtual]`

Sequencer endRun.

Reimplemented from Algorithm.

Definition at line 339 of file Sequencer.cpp.

    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 }

void Sequencer::resetExecuted | ( |  | ) | `[virtual]`

Reset the Sequencer executed state for the current event.

Reimplemented from Algorithm.

Definition at line 370 of file Sequencer.cpp.

    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 }

bool Sequencer::branchFilterPassed | ( |  | ) | const`[virtual]`

Was the branch filter passed for the last event?

Definition at line 398 of file Sequencer.cpp.

    00399 {
    00400   return m_branchFilterPassed;
    00401 }

StatusCode Sequencer::setBranchFilterPassed | ( | bool | state | ) | `[virtual]`

Set the branch filter passed flag for the last event.

Definition at line 404 of file Sequencer.cpp.

    00405 {
    00406   m_branchFilterPassed = state;
    00407   return StatusCode::SUCCESS;
    00408 }

bool Sequencer::isStopOverride | ( |  | ) | const`[virtual]`

Has the StopOverride mode been set?

Definition at line 411 of file Sequencer.cpp.

    00412 {
    00413   return m_stopOverride.value( );
    00414 }

StatusCode Sequencer::append | ( | Algorithm * | pAlgorithm | ) |

Append an algorithm to the sequencer.

Definition at line 417 of file Sequencer.cpp.

    00418 {
    00419   StatusCode result = append( pAlgorithm, subAlgorithms( ) );
    00420   return result;
    00421 }

StatusCode Sequencer::appendToBranch | ( | Algorithm * | pAlgorithm | ) |

Append an algorithm to the sequencer branch.

Definition at line 424 of file Sequencer.cpp.

    00425 {
    00426   StatusCode result = append( pAlgorithm, branchAlgorithms( ) );
    00427   return result;
    00428 }

StatusCode Sequencer::createAndAppend | ( | const std::string & | type,
|  | const std::string & | name,
|  | Algorithm *& | pAlgorithm |
| ) |  |  |

Create a algorithm and append it to the sequencer.

A call to this method creates a child algorithm object. Note that the returned pointer is to Algorithm (as opposed to IAlgorithm), and thus the methods of IProperty are also available for the direct setting of the algorithm's properties. Using this mechanism instead of creating algorithms directly via the new operator is preferred since then the framework may take care of all of the necessary book-keeping.

Definition at line 431 of file Sequencer.cpp.

    00434 {
    00435   StatusCode result = createAndAppend( type, name, pAlgorithm, subAlgorithms( ) );
    00436   return result;
    00437 }

StatusCode Sequencer::createAndAppendToBranch | ( | const std::string & | type,
|  | const std::string & | name,
|  | Algorithm *& | pAlgorithm |
| ) |  |  |

Create a algorithm and append it to the sequencer branch.

A call to this method creates a child algorithm object. Note that the returned pointer is to Algorithm (as opposed to IAlgorithm), and thus the methods of IProperty are also available for the direct setting of the algorithm's properties. Using this mechanism instead of creating algorithms directly via the new operator is preferred since then the framework may take care of all of the necessary book-keeping.

Definition at line 440 of file Sequencer.cpp.

    00443 {
    00444   StatusCode result = createAndAppend( type, name, pAlgorithm, branchAlgorithms( ) );
    00445   return result;
    00446 }

StatusCode Sequencer::remove | ( | Algorithm * | pAlgorithm | ) |

Remove the specified algorithm from the sequencer.

Definition at line 449 of file Sequencer.cpp.

    00450 {
    00451   std::string theName = pAlgorithm->name( );
    00452   StatusCode result = remove( theName );
    00453   return result;
    00454 }

StatusCode Sequencer::remove | ( | const std::string & | name | ) |

Definition at line 457 of file Sequencer.cpp.

    00458 {
    00459   StatusCode result = remove( algname, subAlgorithms( ) );
    00460   return result;
    00461 }

StatusCode Sequencer::removeFromBranch | ( | Algorithm * | pAlgorithm | ) |

Definition at line 464 of file Sequencer.cpp.

    00465 {
    00466   std::string theName = pAlgorithm->name( );
    00467   StatusCode result = removeFromBranch( theName );
    00468   return result;
    00469 }

StatusCode Sequencer::removeFromBranch | ( | const std::string & | name | ) |

Definition at line 472 of file Sequencer.cpp.

    00473 {
    00474   StatusCode result = remove( algname, branchAlgorithms( ) );
    00475   return result;
    00476 }

std::vector< Algorithm * > * Sequencer::branchAlgorithms | ( |  | ) | const

List of branch algorithms.

These are the algorithms that would get executed if a filter algorithm indicated a failure. The branch is located within the main sequence by the first element, which is the filter algorithm.

Definition at line 479 of file Sequencer.cpp.

    00479                                    {
    00480   return m_branchAlgs;
    00481 }

StatusCode Sequencer::decodeMemberNames | ( |  | ) |

Decode Member Name list.

Definition at line 484 of file Sequencer.cpp.

    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 }

void Sequencer::membershipHandler | ( | Property & | theProp | ) |

"Members" property handler

Definition at line 497 of file Sequencer.cpp.

    00498 {
    00499   if ( isInitialized() ) decodeMemberNames();
    00500 }

StatusCode Sequencer::decodeBranchMemberNames | ( |  | ) |

Decode branch member name list.

Definition at line 503 of file Sequencer.cpp.

    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 }

void Sequencer::branchMembershipHandler | ( | Property & | theProp | ) |

"BranchMembers" property handler

Definition at line 516 of file Sequencer.cpp.

    00517 {
    00518   if ( isInitialized() ) decodeBranchMemberNames();
    00519 }

StatusCode Sequencer::append | ( | Algorithm * | pAlgorithm,
|  | std::vector< Algorithm * > * | theAlgs |
| ) |  |  | `[protected]`

Append an algorithm to the sequencer.

Protected Member Functions.

Definition at line 526 of file Sequencer.cpp.

    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 }

StatusCode Sequencer::createAndAppend | ( | const std::string & | type,
|  | const std::string & | name,
|  | Algorithm *& | pAlgorithm,
|  | std::vector< Algorithm * > * | theAlgs |
| ) |  |  | `[protected]`

Create a algorithm and append it to the sequencer.

A call to this method creates a child algorithm object. Note that the returned pointer is to Algorithm (as opposed to IAlgorithm), and thus the methods of IProperty are also available for the direct setting of the algorithm's properties. Using this mechanism instead of creating algorithms directly via the new operator is preferred since then the framework may take care of all of the necessary book-keeping.

Definition at line 548 of file Sequencer.cpp.

    00552 {
    00553   StatusCode result = StatusCode::FAILURE;
    00554   MsgStream log( msgSvc( ), name( ) );
    00555   SmartIF<IAlgManager> theAlgMgr(serviceLocator()->service("ApplicationMgr"));
    00556   if ( theAlgMgr.isValid() ) {
    00557     IAlgorithm* tmp;
    00558     result = theAlgMgr->createAlgorithm( type, algName, tmp );
    00559     if ( result.isSuccess( ) ) {
    00560       try{
    00561         pAlgorithm = dynamic_cast<Algorithm*>(tmp);
    00562         theAlgs->push_back( pAlgorithm );
    00563       } catch(...){
    00564         log << MSG::ERROR << "Unable to create Algorithm " << algName << endmsg;
    00565         result = StatusCode::FAILURE;
    00566       }
    00567     }
    00568   }
    00569   return result;
    00570 }

StatusCode Sequencer::decodeNames | ( | StringArrayProperty & | theNames,
|  | std::vector< Algorithm * > * | theAlgs,
|  | std::vector< bool > & | theLogic |
| ) |  |  | `[protected]`

Decode algorithm names, creating or appending algorithms as appropriate.

Definition at line 573 of file Sequencer.cpp.

    00576 {
    00577   StatusCode result;
    00578   MsgStream log( msgSvc( ), name( ) );
    00579   SmartIF<IAlgManager> theAlgMgr(serviceLocator()->service("ApplicationMgr"));
    00580   if ( theAlgMgr.isValid() ) {
    00581     // Clear the existing list of algorithms
    00582     theAlgs->clear( );
    00583
    00584     // Build the list of member algorithms from the contents of the
    00585     // theNames list.
    00586     const std::vector<std::string>& theNameVector = theNames.value( );
    00587     std::vector<std::string>::const_iterator it;
    00588     std::vector<std::string>::const_iterator itend = theNameVector.end( );
    00589     for (it = theNameVector.begin(); it != itend; it++) {
    00590
    00591       // Parse the name for a syntax of the form:
    00592       //
    00593       // <type>/<name>
    00594       //
    00595       // Where <name> is the algorithm instance name, and <type> is the
    00596       // algorithm class type (being a subclass of Algorithm).
    00597       const Gaudi::Utils::TypeNameString typeName(*it);
    00598       std::string theName = typeName.name();
    00599       std::string theType = typeName.type();
    00600
    00601       // Parse the name for a syntax of the form:
    00602       //
    00603       // <name>:invert
    00604       //
    00605       // Where <name> is the algorithm instance name and ":invert"
    00606       // indicates that the filter passed logic is inverted.
    00607       bool isInverted = false;
    00608       std::string::size_type invert = theName.find_first_of( ":" );
    00609       // Skip all occurrences of "::" (allow namespaces)
    00610       while ( std::string::npos != invert
    00611               && invert < (theName.size() - 1) && theName[invert+1] == ':' )
    00612         invert = theName.find_first_of( ":", invert+2 );
    00613       if ( std::string::npos != invert ) {
    00614         if ( theName == theType ) {
    00615           // This means that we got something like "Type:invert",
    00616           // so we have to strip the ":invert" from the type too.
    00617           theType = theType.substr( 0, invert );
    00618         }
    00619         theName = theName.substr( 0, invert );
    00620         isInverted = true;
    00621       }
    00622       // Check whether the supplied name corresponds to an existing
    00623       // Algorithm object.
    00624       SmartIF<IAlgorithm>& theIAlg = theAlgMgr->algorithm(theName, false);
    00625       Algorithm*  theAlgorithm = 0;
    00626       StatusCode status = StatusCode::SUCCESS;
    00627       if ( theIAlg.isValid() ) {
    00628         try{
    00629           theAlgorithm = dynamic_cast<Algorithm*>(theIAlg.get());
    00630         } catch(...){
    00631           log << MSG::WARNING << theName << " is not an Algorithm - Failed dynamic cast" << endmsg;
    00632           theAlgorithm = 0; // release
    00633         }
    00634       }
    00635       if ( theAlgorithm ) {
    00636
    00637         // The specified Algorithm already exists - just append it to the membership list.
    00638         status = append( theAlgorithm, theAlgs );
    00639         if ( status.isSuccess( ) ) {
    00640           log << MSG::DEBUG << theName << " already exists - appended to member list" << endmsg;
    00641         } else {
    00642           log << MSG::WARNING << theName << " already exists - append failed!!!" << endmsg;
    00643           result = StatusCode::FAILURE;
    00644         }
    00645       } else {
    00646
    00647         // The specified name doesn't exist - create a new object of the specified type
    00648         // and append it to the membership list.
    00649         status = createAndAppend( theType, theName, theAlgorithm, theAlgs );
    00650         if ( status.isSuccess( ) ) {
    00651           log << MSG::DEBUG << theName << " doesn't exist - created and appended to member list" << endmsg;
    00652         } else {
    00653           log << MSG::WARNING << theName << " doesn't exist - creation failed!!!" << endmsg;
    00654           result = StatusCode::FAILURE;
    00655         }
    00656       }
    00657       if ( status.isSuccess( ) ) {
    00658         theLogic.push_back( isInverted );
    00659       }
    00660     }
    00661
    00662   }
    00663   // Print membership list
    00664   if ( result.isSuccess() && theAlgs->size() != 0 ) {
    00665     log << MSG::INFO << "Member list: ";
    00666     std::vector<Algorithm*>::iterator ai = theAlgs->begin();
    00667     std::vector<bool>::iterator li = theLogic.begin();
    00668     for ( ; ai != theAlgs->end(); ++ai, ++li ) {
    00669
    00670       if ( ai != theAlgs->begin() ) log << ", ";
    00671
    00672       if ( (*ai)->name() == System::typeinfoName(typeid(**ai)) )
    00673         log << (*ai)->name();
    00674       else
    00675         log << System::typeinfoName(typeid(**ai)) << "/" << (*ai)->name();
    00676
    00677       if (*li) log << ":invert";
    00678     }
    00679     log << endmsg;
    00680   }
    00681   return result;
    00682 }

StatusCode Sequencer::execute | ( | std::vector< Algorithm * > * | theAlgs,
|  | std::vector< bool > & | theLogic,
|  | Algorithm *& | lastAlgorithm,
|  | unsigned int | first = `0` |
| ) |  |  | `[protected]`

Execute the members in the specified list.

Definition at line 685 of file Sequencer.cpp.

    00689 {
    00690   StatusCode result = StatusCode::SUCCESS;
    00691
    00692   // Loop over all algorithms calling their execute functions if they
    00693   // are (a) not disabled, and (b) aren't already executed. Note that
    00694   // in the latter case the filter state is still examined. Terminate
    00695   // the loop if an algorithm indicates that it's filter didn't pass.
    00696   unsigned int size = theAlgs->size( );
    00697   for (unsigned int i = first; i < size; i++) {
    00698     lastAlgorithm = (*theAlgs)[i];
    00699     result = executeMember( lastAlgorithm );
    00700     if ( result.isSuccess( ) ) {
    00701
    00702       // Take the filter passed status of this algorithm as my own status.
    00703       // Note that we take into account inverted logic.
    00704       bool passed = lastAlgorithm->filterPassed( );
    00705       bool isInverted = theLogic[i];
    00706       if ( isInverted ) {
    00707         passed = ! passed;
    00708       }
    00709       setFilterPassed( passed );
    00710
    00711       // The behaviour when the filter fails depends on the StopOverride property.
    00712       // The default action is to stop processing, but this default can be
    00713       // overridden by setting the "StopOverride" property to true.
    00714       if ( ! isStopOverride( ) ) {
    00715         if ( ! passed ) break;
    00716       }
    00717     } else {
    00718       break;
    00719     }
    00720   }
    00721   return result;
    00722 }

StatusCode Sequencer::executeMember | ( | Algorithm * | theAlgorithm | ) | `[protected]`

Execute member algorithm.

Definition at line 725 of file Sequencer.cpp.

    00726 {
    00727   StatusCode result = StatusCode::SUCCESS;
    00728   if ( theAlgorithm->isEnabled( ) ) {
    00729     if ( ! theAlgorithm->isExecuted( ) ) {
    00730       result = theAlgorithm->sysExecute( );
    00731
    00732       // Set the executed state of the algorithm.
    00733       // I think this should be done by the algorithm itself, but just in case...
    00734       theAlgorithm->setExecuted( true );
    00735     }
    00736   }
    00737   return result;
    00738 }

StatusCode Sequencer::remove | ( | const std::string & | algname,
|  | std::vector< Algorithm * > * | theAlgs |
| ) |  |  | `[protected]`

Remove the specified algorithm from the sequencer.

Definition at line 741 of file Sequencer.cpp.

    00742 {
    00743   MsgStream log( msgSvc( ), name( ) );
    00744   StatusCode result = StatusCode::FAILURE;
    00745
    00746   // Test that the algorithm exists in the member list
    00747   std::vector<Algorithm*>::iterator it;
    00748   std::vector<Algorithm*>::iterator itend = theAlgs->end( );
    00749   for (it = theAlgs->begin(); it != itend; it++) {
    00750     Algorithm* theAlgorithm = (*it);
    00751     if ( theAlgorithm->name( ) == algname ) {
    00752
    00753       // Algorithm with specified name exists in the algorithm list - remove it
    00754       // THIS ISN'T IMPLEMENTED YET!!!!
    00755       log << MSG::INFO <<"Sequencer::remove( ) isn't implemented yet!!!!!" << endmsg;
    00756       result = StatusCode::SUCCESS;
    00757       break;
    00758     }
    00759   }
    00760   return result;
    00761 }

Sequencer& Sequencer::operator= | ( | const Sequencer & | rhs | ) | `[private]`

Private assignment operator: NO ASSIGNMENT ALLOWED.

## Member Data Documentation

StringArrayProperty Sequencer::m_names`[private]`

Definition at line 244 of file Sequencer.h.

std::vector<bool> Sequencer::m_isInverted`[private]`

Definition at line 245 of file Sequencer.h.

StringArrayProperty Sequencer::m_branchNames`[private]`

Definition at line 246 of file Sequencer.h.

std::vector<Algorithm*>* Sequencer::m_branchAlgs`[private]`

Definition at line 247 of file Sequencer.h.

std::vector<bool> Sequencer::m_isBranchInverted`[private]`

Definition at line 248 of file Sequencer.h.

BooleanProperty Sequencer::m_stopOverride`[private]`

Definition at line 249 of file Sequencer.h.

bool Sequencer::m_branchFilterPassed`[private]`

Definition at line 250 of file Sequencer.h.

The documentation for this class was generated from the following files:

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r10p1/GaudiAlg/GaudiAlg/Sequencer.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r10p1/GaudiAlg/src/lib/Sequencer.cpp