| The Gaudi Framework v28r2p1 (f1a77ff4)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

AlgContextAuditor.cpp
Go to the documentation of this file.
1 #include <cassert>
2
3 #include "GaudiKernel/IAlgContextSvc.h"
4 #include "GaudiKernel/IAlgorithm.h"
5 #include "GaudiKernel/SmartIF.h"
6 #include "GaudiKernel/MsgStream.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 // ============================================================================
30 DECLARE_COMPONENT(AlgContextAuditor)
31 // ============================================================================
32 // standard constructor @see Auditor
33 // ============================================================================
34 AlgContextAuditor::AlgContextAuditor(const std::string& name, ISvcLocator* pSvc )
35 : Auditor( name , pSvc )
36 {}
37 // ============================================================================
38 // standard initialization, see @IAuditor
39 // ============================================================================
40 StatusCode AlgContextAuditor::initialize()
41 {
42 // initialize the base class
43 StatusCode sc = Auditor::initialize() ;
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 // ============================================================================
55 StatusCode AlgContextAuditor::finalize ()
56 {
57 m_svc.reset();
58 // finalize the base class
59 return Auditor::finalize () ;
60 }
61 // ============================================================================
62 void AlgContextAuditor::beforeInitialize ( INamedInterface* a ) {
63 call<&IAlgContextSvc::setCurrentAlg>(m_svc,a);
64 }
65 // ============================================================================
66 void AlgContextAuditor::afterInitialize ( INamedInterface* a ) {
67 call<&IAlgContextSvc::unSetCurrentAlg>(m_svc,a);
68 }
69 // ============================================================================
70 void AlgContextAuditor::beforeFinalize ( INamedInterface* a ) {
71 call<&IAlgContextSvc::setCurrentAlg>(m_svc,a);
72 }
73 // ============================================================================
74 void AlgContextAuditor::afterFinalize ( INamedInterface* a ) {
75 call<&IAlgContextSvc::unSetCurrentAlg>(m_svc,a);
76 }
77 // ============================================================================
78 void AlgContextAuditor::beforeExecute ( INamedInterface* a ) {
79 call<&IAlgContextSvc::setCurrentAlg>(m_svc,a);
80 }
81 // ============================================================================
82 void AlgContextAuditor::afterExecute ( INamedInterface* a ,
83 const StatusCode& /* s */ ) {
84 call<&IAlgContextSvc::unSetCurrentAlg>(m_svc,a);
85 }
86 // ============================================================================
87
88 // ============================================================================
89 // The END
90 // ============================================================================
91
AlgContextAuditor::initialize
StatusCode initialize() override
standard initialization,
Definition: AlgContextAuditor.cpp:40
StatusCode::SUCCESS
Definition: StatusCode.h:30
SmartIF< IAlgorithm >
Auditor::finalize
virtual StatusCode finalize()
Definition: Auditor.cpp:200
Auditor::service
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
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:28
AlgContextAuditor
Description: Register/Unregister the AlgContext of each algorithm before entering the algorithm and a...
Definition: AlgContextAuditor.h:21
StatusCode::FAILURE
Definition: StatusCode.h:29
AlgContextAuditor::afterFinalize
void afterFinalize(INamedInterface *a) override
Definition: AlgContextAuditor.cpp:74
MsgStream.h
IAlgorithm.h
std
STL namespace.
AlgContextAuditor::m_svc
SmartIF< IAlgContextSvc > m_svc
the pointer to Algorithm Context Service
Definition: AlgContextAuditor.h:53
AlgContextAuditor::beforeInitialize
void beforeInitialize(INamedInterface *a) override
Definition: AlgContextAuditor.cpp:62
AlgContextAuditor::afterInitialize
void afterInitialize(INamedInterface *a) override
Definition: AlgContextAuditor.cpp:66
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:84
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginService.h:36
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:117
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
SmartIF.h
AlgContextAuditor::finalize
StatusCode finalize() override
standard finalization,
Definition: AlgContextAuditor.cpp:55
IAlgContextSvc.h
INamedInterface
IInterface compliant class extending IInterface with the name() method.
Definition: INamedInterface.h:15
AlgContextAuditor::beforeFinalize
void beforeFinalize(INamedInterface *a) override
Definition: AlgContextAuditor.cpp:70
AlgContextAuditor::afterExecute
void afterExecute(INamedInterface *a, const StatusCode &s) override
Definition: AlgContextAuditor.cpp:82
fun
double fun(const std::vector< double > &x)
Definition: PFuncTest.cpp:26
AlgContextAuditor.h
IAlgContextSvc
An abstract interface for Algorithm Context Service.
Definition: IAlgContextSvc.h:23
SmartIF::reset
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:88
Auditor::initialize
virtual StatusCode initialize()
Definition: Auditor.cpp:70
AlgContextAuditor::beforeExecute
void beforeExecute(INamedInterface *a) override
Definition: AlgContextAuditor.cpp:78
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
Auditor
Base class from which all concrete auditor classes should be derived.
Definition: Auditor.h:35