| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Sequencer Class Reference

ClassName: Sequencer. More...

#include <Sequencer.h>

Inheritance diagram for Sequencer:

[legend]
Collaboration diagram for Sequencer:
[legend]
List of all members.

Public Types

 SUCCESS
 NO_INTERFACE
 VERSMISMATCH
 LAST_ERROR
enum  Status

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 naem list.
void branchMembershipHandler (Property &theProp)
 "BranchMembers" propertry handler
virtual StatusCode sysStart ()
virtual StatusCode sysInitialize ()
virtual StatusCode sysReinitialize ()
virtual StatusCode sysRestart ()
virtual StatusCode sysExecute ()
virtual StatusCode sysStop ()
virtual StatusCode sysFinalize ()
virtual StatusCode sysBeginRun ()
virtual StatusCode sysEndRun ()
virtual const std::string & name () const
virtual const std::string & version () const
virtual StatusCode configure ()
virtual StatusCode terminate ()
virtual StatusCode restart ()
virtual bool isExecuted () const
virtual void setExecuted (bool state)
virtual Gaudi::StateMachine::State FSMState () const
virtual Gaudi::StateMachine::State targetFSMState () const
virtual bool isEnabled () const
virtual bool filterPassed () const
virtual void setFilterPassed (bool state)
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
void setOutputLevel (int level)
IAuditorSvcauditorSvc () const
IChronoStatSvcchronoSvc () const
IChronoStatSvcchronoStatService () const
IDataProviderSvcdetSvc () const
IDataProviderSvcdetDataService () const
IConversionSvcdetCnvSvc () const
IConversionSvcdetDataCnvService () const
IDataProviderSvceventSvc () const
IDataProviderSvcevtSvc () const
IDataProviderSvceventDataService () const
IConversionSvceventCnvSvc () const
IConversionSvceventDataCnvService () const
IHistogramSvchistoSvc () const
IHistogramSvchistogramDataService () const
IMessageSvcmsgSvc () const
IMessageSvcmessageService () const
INTupleSvcntupleSvc () const
INTupleSvcntupleService () const
IRndmGenSvcrandSvc () const
IToolSvctoolSvc () const
IExceptionSvcexceptionSvc () const
ISvcLocatorserviceLocator () const
ISvcLocatorsvcLoc () const
StatusCode createSubAlgorithm (const std::string &type, const std::string &name, Algorithm *&pSubAlg)
std::vector< Algorithm * > * subAlgorithms () const
virtual StatusCode setProperty (const Property &p)
virtual StatusCode setProperty (const std::string &s)
virtual StatusCode setProperty (const std::string &n, const std::string &v)
StatusCode setProperty (const std::string &name, const TYPE &value)
virtual StatusCode getProperty (Property *p) const
virtual const PropertygetProperty (const std::string &name) const
virtual StatusCode getProperty (const std::string &n, std::string &v) const
virtual const std::vector<
Property * > & 
getProperties () const
StatusCode setProperties ()
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
IMonitorSvcmonitorSvc () const
void declareInfo (const std::string &name, const T &var, const std::string &desc) const
void declareInfo (const std::string &name, const std::string &format, const void *var, int size, const std::string &desc) const
unsigned long addRef ()
unsigned long release ()
StatusCode queryInterface (const InterfaceID &riid, void **)

Static Public Member Functions

static const InterfaceIDinterfaceID ()
static const InterfaceIDinterfaceID ()
static const InterfaceIDinterfaceID ()

Public Attributes

 SUCCESS
 NO_INTERFACE
 VERSMISMATCH
 LAST_ERROR

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.
bool isInitialized () const
bool isFinalized () const
int outputLevel () const
IntegerPropertyoutputLevelProperty ()
void initOutputLevel (Property &prop)

Private Member Functions

 Sequencer (const Sequencer &a)
 Private Copy constructor: NO COPY ALLOWED.
Sequenceroperator= (const Sequencer &rhs)
 Private asignment 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 " << 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 }

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() << 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 }

StatusCode Sequencer::execute (  )  [virtual]

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

This method is invoked once per event.

Implements Algorithm.

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( )" << 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 }

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() << 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 }

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 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 }

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() << 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 }

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 naem 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" propertry 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.

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   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 }

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 578 of file Sequencer.cpp.

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 }

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 700 of file Sequencer.cpp.

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 }

StatusCode Sequencer::executeMember ( Algorithm theAlgorithm  )  [protected]

Execute member algorithm.

Definition at line 740 of file Sequencer.cpp.

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 }

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

Remove the specified algorithm from the sequencer.

Definition at line 756 of file Sequencer.cpp.

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 }

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

Private asignment 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:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 19:58:21 2011 for GaudiAlg by doxygen 1.4.7