![]() |
|
|
Generated: 18 Jul 2008 |
00001 // $Id: GaudiAlgorithm.cpp,v 1.11 2007/09/25 16:12:41 marcocle Exp $ 00002 // ============================================================================ 00003 #define GAUDIALG_GAUDIALGORITHM_CPP 1 00004 // ============================================================================ 00005 // include files 00006 // ============================================================================ 00007 // GaudiKernel 00008 // ============================================================================ 00009 #include "GaudiKernel/IAlgContextSvc.h" 00010 // ============================================================================ 00011 // GaudiAlg 00012 // ============================================================================ 00013 #include "GaudiAlg/GaudiAlgorithm.h" 00014 // ============================================================================ 00026 // ============================================================================ 00027 // templated methods 00028 // ============================================================================ 00029 #include "GaudiCommon.icpp" 00030 // ============================================================================ 00031 template class GaudiCommon<Algorithm>; 00032 // ============================================================================ 00033 // Standard algorithm like constructor 00034 // ============================================================================ 00035 GaudiAlgorithm::GaudiAlgorithm ( const std::string& name , 00036 ISvcLocator* pSvcLocator ) 00037 : GaudiCommon<Algorithm> ( name , pSvcLocator ) 00038 // 00039 , m_evtColSvc ( 0 ) // pointer to Event Tag Collection Service 00040 , m_contextSvc ( 0 ) // pointer to Algorithm Context Service 00041 , m_contextSvcName ( "AlgContextSvc" ) // Algorithm Context Service name 00042 // enforce the algorithm registration for Algorithm Context Service 00043 , m_registerContext ( true ) 00044 { 00045 declareProperty 00046 ( "ContextService" , 00047 m_contextSvcName , 00048 "The name of Algorithm Context Service" ) ; 00049 declareProperty 00050 ( "RegisterForContextService" , 00051 m_registerContext , 00052 "The flag to enforce the registration for Algorithm Context Service") ; 00053 } 00054 // ============================================================================ 00055 // Destructor 00056 // ============================================================================ 00057 GaudiAlgorithm::~GaudiAlgorithm() { } 00058 // ============================================================================ 00059 // standard initialization method 00060 // ============================================================================ 00061 StatusCode GaudiAlgorithm::initialize() 00062 { 00063 // initialize the base class 00064 const StatusCode sc = GaudiCommon<Algorithm>::initialize() ; 00065 if ( sc.isFailure() ) { return sc; } 00066 00067 // Add any customisations here, that cannot go in GaudiCommon 00068 00069 // return 00070 return sc; 00071 } 00072 // ============================================================================ 00073 // standard finalization method 00074 // ============================================================================ 00075 StatusCode GaudiAlgorithm::finalize() 00076 { 00077 if ( msgLevel(MSG::DEBUG) ) 00078 debug() << "Finalize base class GaudiAlgorithm" << endreq; 00079 00080 // reset pointers 00081 m_evtColSvc = 0 ; 00082 00083 // finalize the base class and return 00084 return GaudiCommon<Algorithm>::finalize() ; 00085 } 00086 // ============================================================================ 00087 // standard execution method 00088 // ============================================================================ 00089 StatusCode GaudiAlgorithm::execute() 00090 { 00091 return Error ( "Default GaudiAlgorithm execute method called !!" ) ; 00092 } 00093 // ============================================================================ 00094 // The standard event collection service 00095 // ============================================================================ 00096 INTupleSvc* GaudiAlgorithm::evtColSvc() const 00097 { 00098 if ( 0 == m_evtColSvc ) 00099 { 00100 m_evtColSvc = svc< INTupleSvc > ( "EvtTupleSvc" , true ) ; 00101 } 00102 return m_evtColSvc ; 00103 } 00104 // ============================================================================ 00105 // The standard Algorithm Context Service 00106 // ============================================================================ 00107 IAlgContextSvc* GaudiAlgorithm::contextSvc() const 00108 { 00109 if ( 0 == m_contextSvc ) 00110 { 00111 m_contextSvc = svc< IAlgContextSvc > ( m_contextSvcName , true ) ; 00112 } 00113 return m_contextSvc ; 00114 } 00115 // ============================================================================ 00116 /* The generic actions for the execution. 00117 * @see Algorithm 00118 * @see IAlgorithm 00119 * @see Algorithm::sysExecute 00120 * @return status code 00121 */ 00122 // ============================================================================ 00123 StatusCode GaudiAlgorithm::sysExecute () 00124 { 00125 IAlgContextSvc* ctx = 0 ; 00126 if ( registerContext() ) { ctx = contextSvc() ; } 00127 // Lock the context 00128 Gaudi::Utils::AlgContext cnt ( ctx , this ) ; 00129 00130 return Algorithm::sysExecute() ; 00131 } 00132 // ============================================================================ 00133 00134 00135 00136 00137 // ============================================================================ 00138 // The END 00139 // ============================================================================ 00140