| The Gaudi Framework v29r0 (ff2e7097)

- 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/MsgStream.h"
6 #include "GaudiKernel/SmartIF.h"
7
8 #include "AlgContextAuditor.h"
9
10 // ============================================================================
16 // ============================================================================
17 namespace
18 {
19 template <StatusCode ( IAlgContextSvc::*fun )( IAlgorithm* )>
20 void call( IAlgContextSvc* ctx, INamedInterface* a )
21 {
22 if ( ctx ) {
23 // make a safe cast using "smart interface"
24 SmartIF<IAlgorithm> alg{a};
25 if ( alg ) ( ctx->*fun )( alg.get() ).ignore();
26 }
27 }
28 }
29 // ============================================================================
30 // mandatory auditor factory, needed for instantiation
31 // ============================================================================
32 DECLARE_COMPONENT( AlgContextAuditor )
33 // ============================================================================
34 // standard constructor @see Auditor
35 // ============================================================================
36 AlgContextAuditor::AlgContextAuditor( const std::string& name, ISvcLocator* pSvc ) : Auditor( name, pSvc ) {}
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() ) {
45 return sc;
46 } // RETURN
47 m_svc = service( "AlgContextSvc", true );
48 if ( !m_svc ) {
49 error() << "Invalid pointer to IAlgContextSvc" << endmsg;
50 return StatusCode::FAILURE; // RETURN
51 }
52 return StatusCode::SUCCESS;
53 }
54 // ============================================================================
55 // standard finalization, see @IAuditor
56 // ============================================================================
57 StatusCode AlgContextAuditor::finalize()
58 {
59 m_svc.reset();
60 // finalize the base class
61 return Auditor::finalize();
62 }
63 // ============================================================================
64 void AlgContextAuditor::beforeInitialize( INamedInterface* a ) { call<&IAlgContextSvc::setCurrentAlg>( m_svc, a ); }
65 // ============================================================================
66 void AlgContextAuditor::afterInitialize( INamedInterface* a ) { call<&IAlgContextSvc::unSetCurrentAlg>( m_svc, a ); }
67 // ============================================================================
68 void AlgContextAuditor::beforeFinalize( INamedInterface* a ) { call<&IAlgContextSvc::setCurrentAlg>( m_svc, a ); }
69 // ============================================================================
70 void AlgContextAuditor::afterFinalize( INamedInterface* a ) { call<&IAlgContextSvc::unSetCurrentAlg>( m_svc, a ); }
71 // ============================================================================
72 void AlgContextAuditor::beforeExecute( INamedInterface* a ) { call<&IAlgContextSvc::setCurrentAlg>( m_svc, a ); }
73 // ============================================================================
74 void AlgContextAuditor::afterExecute( INamedInterface* a, const StatusCode& /* s */ )
75 {
76 call<&IAlgContextSvc::unSetCurrentAlg>( m_svc, a );
77 }
78 // ============================================================================
79
80 // ============================================================================
81 // The END
82 // ============================================================================
AlgContextAuditor::initialize
StatusCode initialize() override
standard initialization,
Definition: AlgContextAuditor.cpp:40
StatusCode::SUCCESS
Definition: StatusCode.h:31
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:32
AlgContextAuditor
Description: Register/Unregister the AlgContext of each algorithm before entering the algorithm and a...
Definition: AlgContextAuditor.h:21
StatusCode::FAILURE
Definition: StatusCode.h:31
AlgContextAuditor::afterFinalize
void afterFinalize(INamedInterface *a) override
Definition: AlgContextAuditor.cpp:70
MsgStream.h
IAlgorithm.h
std
STL namespace.
AlgContextAuditor::m_svc
SmartIF< IAlgContextSvc > m_svc
the pointer to Algorithm Context Service
Definition: AlgContextAuditor.h:51
AlgContextAuditor::beforeInitialize
void beforeInitialize(INamedInterface *a) override
Definition: AlgContextAuditor.cpp:64
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:86
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginService.h:33
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:111
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
SmartIF.h
AlgContextAuditor::finalize
StatusCode finalize() override
standard finalization,
Definition: AlgContextAuditor.cpp:57
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:68
AlgContextAuditor::afterExecute
void afterExecute(INamedInterface *a, const StatusCode &s) override
Definition: AlgContextAuditor.cpp:74
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:92
Auditor::initialize
virtual StatusCode initialize()
Definition: Auditor.cpp:70
AlgContextAuditor::beforeExecute
void beforeExecute(INamedInterface *a) override
Definition: AlgContextAuditor.cpp:72
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
Auditor
Base class from which all concrete auditor classes should be derived.
Definition: Auditor.h:35