All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules 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  template <StatusCode(IAlgContextSvc::*fun)(IAlgorithm*)>
19  void call(IAlgContextSvc* ctx,INamedInterface* a) {
20  if ( ctx ) {
21  // make a safe cast using "smart interface"
22  SmartIF<IAlgorithm> alg{ a };
23  if (alg) (ctx->*fun)( alg.get() ).ignore() ;
24  }
25  }
26 }
27 // ============================================================================
28 // mandatory auditor factory, needed for instantiation
29 // ============================================================================
31 // ============================================================================
32 // standard constructor @see Auditor
33 // ============================================================================
35  : Auditor( name , pSvc )
36 {}
37 // ============================================================================
38 // standard initialization, see @IAuditor
39 // ============================================================================
41 {
42  // initialize the base class
44  if ( sc.isFailure() ) { return sc ; } // RETURN
45  m_svc = service( "AlgContextSvc" , true ) ;
46  if ( !m_svc ) {
47  error() << "Invalid pointer to IAlgContextSvc" << endmsg ;
48  return StatusCode::FAILURE ; // RETURN
49  }
50  return StatusCode::SUCCESS ;
51 }
52 // ============================================================================
53 // standard finalization, see @IAuditor
54 // ============================================================================
56 {
57  m_svc.reset();
58  // finalize the base class
59  return Auditor::finalize () ;
60 }
61 // ============================================================================
63  call<&IAlgContextSvc::setCurrentAlg>(m_svc,a);
64 }
65 // ============================================================================
67  call<&IAlgContextSvc::unSetCurrentAlg>(m_svc,a);
68 }
69 // ============================================================================
71  call<&IAlgContextSvc::setCurrentAlg>(m_svc,a);
72 }
73 // ============================================================================
75  call<&IAlgContextSvc::unSetCurrentAlg>(m_svc,a);
76 }
77 // ============================================================================
79  call<&IAlgContextSvc::setCurrentAlg>(m_svc,a);
80 }
81 // ============================================================================
83  const StatusCode& /* s */ ) {
84  call<&IAlgContextSvc::unSetCurrentAlg>(m_svc,a);
85 }
86 // ============================================================================
87 
88 // ============================================================================
89 // The END
90 // ============================================================================
91 
StatusCode initialize() override
standard initialization,
virtual StatusCode finalize()
Definition: Auditor.cpp:200
StatusCode service(const std::string &name, T *&svc, bool createIf=false) const
Access a service by name, creating it if it doesn&#39;t already exist.
Definition: Auditor.h:109
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
Description: Register/Unregister the AlgContext of each algorithm before entering the algorithm and a...
void afterFinalize(INamedInterface *a) override
STL namespace.
SmartIF< IAlgContextSvc > m_svc
the pointer to Algorithm Context Service
void beforeInitialize(INamedInterface *a) override
void afterInitialize(INamedInterface *a) override
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:84
#define DECLARE_COMPONENT(type)
Definition: PluginService.h:36
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
StatusCode finalize() override
standard finalization,
IInterface compliant class extending IInterface with the name() method.
void beforeFinalize(INamedInterface *a) override
void afterExecute(INamedInterface *a, const StatusCode &s) override
double fun(const std::vector< double > &x)
Definition: PFuncTest.cpp:26
An abstract interface for Algorithm Context Service.
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:88
virtual StatusCode initialize()
Definition: Auditor.cpp:70
void beforeExecute(INamedInterface *a) override
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:35