All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
AlgContextAuditor.cpp
Go to the documentation of this file.
1 #include <cassert>
2 
5 #include "GaudiKernel/SmartIF.h"
7 
8 #include "AlgContextAuditor.h"
9 
10 // ============================================================================
16 // ============================================================================
17 namespace
18 {
27  inline IAlgorithm* toAlg ( IInterface* ni )
28  {
29  if ( 0 == ni ) { return 0 ; }
30  SmartIF<IAlgorithm> alg ( ni ) ;
31  return alg ;
32  }
33 }
34 // ============================================================================
35 // mandatory auditor factory, needed for instantiation
36 // ============================================================================
38 // ============================================================================
39 // standard constructor @see Auditor
40 // ============================================================================
42 ( const std::string& name ,
43  ISvcLocator* pSvc )
44  : Auditor( name , pSvc )
45  , m_svc ( 0 )
46 {}
47 // ============================================================================
48 // destructor
49 // ============================================================================
51 // ============================================================================
52 // standard initialization, see @IAuditor
53 // ============================================================================
55 {
56  // initialize the base class
58  if ( sc.isFailure() ) { return sc ; } // RETURN
59  if ( 0 != m_svc ) { m_svc -> release() ; m_svc = 0 ; }
60  sc = Auditor::service ( "AlgContextSvc" , m_svc , true ) ;
61  if ( sc.isFailure() )
62  {
63  MsgStream log ( msgSvc() , name() ) ;
64  log << MSG::ERROR << "Unable to locate 'AlgContextSvc'" << sc << endmsg ;
65  m_svc = 0 ;
66  return sc ; // RETURN
67  }
68  if ( 0 == m_svc )
69  {
70  MsgStream log ( msgSvc() , name() ) ;
71  log << MSG::ERROR << "Invalid pointer to IAlgContextSvc" << endmsg ;
72  return StatusCode::FAILURE ; // RETURN
73  }
74  return StatusCode::SUCCESS ;
75 }
76 // ============================================================================
77 // standard finalization, see @IAuditor
78 // ============================================================================
80 {
81  if ( 0 != m_svc ) { m_svc-> release() ; m_svc = 0 ; }
82  // finalize the base class
83  return Auditor::finalize () ;
84 }
85 // ============================================================================
87  if ( 0 != m_svc ) {
88  IAlgorithm* alg = toAlg(a);
89  if (alg != 0) m_svc -> setCurrentAlg ( alg ).ignore() ;
90  }
91 }
92 // ============================================================================
94  if ( 0 != m_svc ) {
95  IAlgorithm* alg = toAlg(a);
96  if (alg != 0) m_svc -> unSetCurrentAlg ( alg ).ignore() ;
97  }
98 }
99 // ============================================================================
101  if ( 0 != m_svc ) {
102  IAlgorithm* alg = toAlg(a);
103  if (alg != 0) m_svc -> setCurrentAlg ( alg ).ignore() ;
104  }
105 }
106 // ============================================================================
108  if ( 0 != m_svc ) {
109  IAlgorithm* alg = toAlg(a);
110  if (alg != 0) m_svc -> unSetCurrentAlg ( alg ).ignore() ;
111  }
112 }
113 // ============================================================================
115  if ( 0 != m_svc ) {
116  IAlgorithm* alg = toAlg(a);
117  if (alg != 0) m_svc -> setCurrentAlg ( alg ).ignore() ;
118  }
119 }
120 // ============================================================================
122  const StatusCode& /* s */ ) {
123  if ( 0 != m_svc ) {
124  IAlgorithm* alg = toAlg(a);
125  if (alg != 0) m_svc -> unSetCurrentAlg ( alg ).ignore() ;
126  }
127 }
128 // ============================================================================
129 
130 // ============================================================================
131 // The END
132 // ============================================================================
133 
virtual void afterInitialize(INamedInterface *a)
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
virtual StatusCode finalize()
Definition: Auditor.cpp:213
StatusCode service(const std::string &name, T *&svc, bool createIf=false) const
Access a service by name, creating it if it doesn't already exist.
Definition: Auditor.h:119
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:26
virtual const std::string & name() const
Retrieve the name of the instance.
Definition: Auditor.cpp:218
Description: Register/Unregister the AlgContext of each algorithm before entering the algorithm and a...
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: Auditor.cpp:226
virtual ~AlgContextAuditor()
virtual destructor
virtual StatusCode initialize()
standard initialization,
IAlgContextSvc * m_svc
the pointer to Algorithm Context Service
virtual void afterFinalize(INamedInterface *a)
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:85
virtual void afterExecute(INamedInterface *a, const StatusCode &s)
#define DECLARE_COMPONENT(type)
Definition: PluginService.h:36
virtual StatusCode finalize()
standard finalization,
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
Definition of the basic interface.
Definition: IInterface.h:160
virtual void beforeExecute(INamedInterface *a)
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:20
IInterface compliant class extending IInterface with the name() method.
virtual unsigned long release()=0
Release Interface instance.
virtual void beforeInitialize(INamedInterface *a)
virtual void beforeFinalize(INamedInterface *a)
virtual StatusCode initialize()
Definition: Auditor.cpp:97
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
Base class from which all concrete auditor classes should be derived.
Definition: Auditor.h:34