Commits

Anonymous committed 796faea

Sequencer.cxx
Change reset( ) to resetExecuted( ) and perform exception handling for
the execute( ) method.

David Quarrie

  • Participants
  • Parent commits e695efa

Comments (0)

Files changed (1)

src/Sequencer.cxx

-//$Header: /build/atlas/cvs/atlas/offline/Control/GaudiSequencer/src/Sequencer.cxx,v 1.2 2000-06-02 08:24:01 dquarrie Exp $
+//$Header: /build/atlas/cvs/atlas/offline/Control/GaudiSequencer/src/Sequencer.cxx,v 1.3 2000-06-07 22:16:24 dquarrie Exp $
 
 // Sequencer class
 // Implements:
 #include "Gaudi/Interfaces/ISvcLocator.h"
 #include "Gaudi/Kernel/AlgFactory.h"
 #include "Gaudi/MessageSvc/MsgStream.h"
+#include "Gaudi/ChronoStatSvc/Chrono.h"
+#include "Gaudi/ChronoStatSvc/Stat.h"
+#include "Gaudi/Kernel/GaudiException.h"
 
 // External declarations
 extern const IID& IID_IAlgManager;
 Sequencer::execute()
 {
     StatusCode result = StatusCode::SUCCESS;
-    StatusCode status;
     MsgStream log( messageService( ), name( ) );
 
     log << MSG::DEBUG << name( ) << " Sequencer::execute( )" << endreq;
     // Bypass the loop if this sequencer is disabled or has already been executed
     if ( isEnabled( ) && ! isExecuted( ) ) {
 
+        // Prevent multiple executions of this sequencer for the current event
+        setExecuted( true );
+
         // Loop over all algorithms calling their execute functions if they
         // are (a) not disabled, and (b) aren't already executed. Note that
         // in the latter case the filter state is still examined. Terminate
             Algorithm* theAlgorithm = (*it);
             if ( theAlgorithm->isEnabled( ) ) {
                 if ( ! theAlgorithm->isExecuted( ) ) {
-                    status = theAlgorithm->execute( );
+                    try {
+                        result = theAlgorithm->execute( );
+                    } catch( const GaudiException& Exception   ) { /// catch GaudiExceptions
+
+                        /// (1) perform the printout of message
+                        MsgStream log ( msgSvc() , name() + ".execute()" );
+                        log << MSG::FATAL
+	                        << " Exception with tag=" << Exception.tag() << " is caught " << endreq;
+                        /// (2) print  the exception itself
+                        ///           (NB!  - GaudiException is a linked list of all "previous exceptions")
+                        MsgStream logEx ( msgSvc() , Exception.tag() );
+                        logEx << MSG::ERROR
+	                          << Exception  << endreq;
+                        /// (3) make record in Stat Table
+                        Stat stat( chronoSvc() , Exception.tag() ) ;
+                        result = StatusCode::FAILURE;
+                    } catch( const std::exception& Exception ) { /// catch std::exception
+
+                        /// (1) perform the printout of message
+                        MsgStream log ( msgSvc() , name() + ".execute()" );
+                        log << MSG::FATAL
+	                        << " Standard std::exception is caught " << endreq;
+                        /// (2) print  the exception itself
+                        MsgStream logEx ( msgSvc() , name() + "*std::exception*" );
+                        logEx << MSG::ERROR
+	                          << Exception.what()  << endreq;
+                        /// (3) make record in Stat Table
+                        Stat stat( chronoSvc() , "*std::exception*" ) ;
+                        result = StatusCode::FAILURE;
+                    } catch(...) { /// catch all other exceptions
+
+                        /// (1) perform the printout
+                        MsgStream log ( msgSvc() , name() + ".execute()" );
+                        log << MSG::FATAL
+	                        << " UNKNOWN Exception is caught " << endreq;
+                        /// (2) make record in Stat Table
+                        Stat stat( chronoSvc() , "*UNKNOWN Exception*" ) ;
+                        result = StatusCode::FAILURE;
+                    }
 
                     // I think this should be done by the algorithm itself, but just in case...
                     theAlgorithm->setExecuted( true );
                 }
 
-                // Take the filter passed status of this algorithm as my own status
-                bool passed = theAlgorithm->filterPassed( );
-                setFilterPassed( passed );
+                if ( result.isSuccess( ) ) {
 
-                // The behaviour when the filter fails depends on the StopOverride property.
-                // The default action is to stop processing, but this default can be
-                // overridden by setting the "StopOverride" property to false.
-                if ( ! m_stopOverride ) {
-                    if ( ! passed ) break;
+                    // Take the filter passed status of this algorithm as my own status
+                    bool passed = theAlgorithm->filterPassed( );
+                    setFilterPassed( passed );
+
+                    // The behaviour when the filter fails depends on the StopOverride property.
+                    // The default action is to stop processing, but this default can be
+                    // overridden by setting the "StopOverride" property to false.
+                    if ( ! m_stopOverride ) {
+                        if ( ! passed ) break;
+                   }
+                } else {
+                    break;
                 }
             }
         }
-
-        // Prevent multiple executions of this sequencer for the current event
-        setExecuted( true );
     }
     return result;
 }
 }
 
 StatusCode
-Sequencer::reset( )
+Sequencer::resetExecuted( )
 {
-    Algorithm::reset( );
+    Algorithm::resetExecuted( );
 
-    // Loop over all algorithms calling their reset functions if they
+    // Loop over all members calling their resetExecuted functions if they
     // are not disabled.
     std::vector<Algorithm*>* subAlgms = subAlgorithms( );
     std::vector<Algorithm*>::iterator it;
     std::vector<Algorithm*>::iterator itend = subAlgms->end( );
     for (it = subAlgms->begin(); it != itend; it++) {
         Algorithm* theAlgorithm = (*it);
-        theAlgorithm->reset( );
+        theAlgorithm->resetExecuted( );
     }
     return StatusCode::SUCCESS;
 }
 
             // Algorithm with specified name exists in the algorithm list - remove it
             // THIS ISN'T IMPLEMENTED YET!!!!
+            cerr << "Sequencer::remove( ) isn't implemented yet!!!!!" << endl;
             result = StatusCode::SUCCESS;
             break;
         }