Gaudi Framework, version v23r2

Home   Generated: Thu Jun 28 2012

AlgContextAuditor.cpp

Go to the documentation of this file.
00001 #include <cassert>
00002 
00003 #include "GaudiKernel/IAlgContextSvc.h"
00004 #include "GaudiKernel/IAlgorithm.h"
00005 #include "GaudiKernel/AudFactory.h"
00006 #include "GaudiKernel/SmartIF.h"
00007 #include "GaudiKernel/MsgStream.h"
00008 
00009 #include "AlgContextAuditor.h"
00010 
00011 // ============================================================================
00017 // ============================================================================
00018 namespace
00019 {
00028   inline IAlgorithm* toAlg ( IInterface* ni )
00029   {
00030     if ( 0 == ni ) { return 0 ; }
00031     SmartIF<IAlgorithm> alg ( ni ) ;
00032     return alg ;
00033   }
00034 }
00035 // ============================================================================
00036 // mandatory auditor factory, needed for instantiation
00037 // ============================================================================
00038 DECLARE_AUDITOR_FACTORY(AlgContextAuditor)
00039 // ============================================================================
00040 // standard constructor @see Auditor
00041 // ============================================================================
00042 AlgContextAuditor::AlgContextAuditor
00043 ( const std::string& name ,
00044   ISvcLocator*       pSvc )
00045   : Auditor( name , pSvc )
00046   , m_svc   ( 0    )
00047 {}
00048 // ============================================================================
00049 // destructor
00050 // ============================================================================
00051 AlgContextAuditor::~AlgContextAuditor() {}
00052 // ============================================================================
00053 // standard initialization, see @IAuditor
00054 // ============================================================================
00055 StatusCode AlgContextAuditor::initialize()
00056 {
00057   // initialize the base class
00058   StatusCode sc = Auditor::initialize() ;
00059   if ( sc.isFailure() ) { return sc ; }                           // RETURN
00060   if ( 0 != m_svc ) { m_svc -> release() ; m_svc = 0 ; }
00061   sc = Auditor::service ( "AlgContextSvc" , m_svc , true ) ;
00062   if ( sc.isFailure() )
00063   {
00064     MsgStream log ( msgSvc() , name() ) ;
00065     log << MSG::ERROR << "Unable to locate 'AlgContextSvc'" << sc << endmsg ;
00066     m_svc = 0 ;
00067     return sc ;  // RETURN
00068   }
00069   if ( 0 == m_svc     )
00070   {
00071     MsgStream log ( msgSvc() , name() ) ;
00072     log << MSG::ERROR << "Invalid pointer to IAlgContextSvc" << endmsg ;
00073     return StatusCode::FAILURE ;           // RETURN
00074   }
00075   return StatusCode::SUCCESS ;
00076 }
00077 // ============================================================================
00078 // standard finalization, see @IAuditor
00079 // ============================================================================
00080 StatusCode AlgContextAuditor::finalize ()
00081 {
00082   if ( 0 != m_svc ) { m_svc-> release() ; m_svc = 0 ; }
00083   // finalize the base class
00084   return Auditor::finalize () ;
00085 }
00086 // ============================================================================
00087 void AlgContextAuditor::beforeInitialize ( INamedInterface*  a ) {
00088   if ( 0 != m_svc ) {
00089     IAlgorithm* alg = toAlg(a);
00090     if (alg != 0) m_svc -> setCurrentAlg ( alg ).ignore() ;
00091   }
00092 }
00093 // ============================================================================
00094 void AlgContextAuditor::afterInitialize  ( INamedInterface*  a ) {
00095   if ( 0 != m_svc ) {
00096     IAlgorithm* alg = toAlg(a);
00097     if (alg != 0) m_svc -> unSetCurrentAlg ( alg ).ignore() ;
00098   }
00099 }
00100 // ============================================================================
00101 void AlgContextAuditor::beforeFinalize   ( INamedInterface*  a ) {
00102   if ( 0 != m_svc ) {
00103     IAlgorithm* alg = toAlg(a);
00104     if (alg != 0) m_svc -> setCurrentAlg ( alg ).ignore() ;
00105   }
00106 }
00107 // ============================================================================
00108 void AlgContextAuditor::afterFinalize    ( INamedInterface*  a ) {
00109   if ( 0 != m_svc ) {
00110     IAlgorithm* alg = toAlg(a);
00111     if (alg != 0) m_svc -> unSetCurrentAlg ( alg ).ignore() ;
00112   }
00113 }
00114 // ============================================================================
00115 void AlgContextAuditor::beforeExecute    ( INamedInterface*  a ) {
00116   if ( 0 != m_svc ) {
00117     IAlgorithm* alg = toAlg(a);
00118     if (alg != 0) m_svc -> setCurrentAlg ( alg ).ignore() ;
00119   }
00120 }
00121 // ============================================================================
00122 void AlgContextAuditor::afterExecute     ( INamedInterface*  a       ,
00123                                            const StatusCode& /* s */ ) {
00124   if ( 0 != m_svc ) {
00125     IAlgorithm* alg = toAlg(a);
00126     if (alg != 0) m_svc -> unSetCurrentAlg ( alg ).ignore() ;
00127   }
00128 }
00129 // ============================================================================
00130 
00131 // ============================================================================
00132 // The END
00133 // ============================================================================
00134 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Thu Jun 28 2012 23:27:15 for Gaudi Framework, version v23r2 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004