The Gaudi Framework
master (1a7a3838)
Toggle main menu visibility
Loading...
Searching...
No Matches
AlgContextAuditor.cpp
Go to the documentation of this file.
1
/***********************************************************************************\
2
* (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations *
3
* *
4
* This software is distributed under the terms of the Apache version 2 licence, *
5
* copied verbatim in the file "LICENSE". *
6
* *
7
* In applying this licence, CERN does not waive the privileges and immunities *
8
* granted to it by virtue of its status as an Intergovernmental Organization *
9
* or submit itself to any jurisdiction. *
10
\***********************************************************************************/
11
12
#include <
Gaudi/Auditor.h
>
13
#include <
GaudiKernel/EventContext.h
>
14
#include <
GaudiKernel/IAlgContextSvc.h
>
15
#include <
GaudiKernel/IAlgManager.h
>
16
#include <
GaudiKernel/IAlgorithm.h
>
17
18
class
IAlgContextSvc
;
19
26
class
AlgContextAuditor
:
public
Gaudi::Auditor
{
27
public
:
28
// IAuditor implementation
29
void
before
( std::string
const
&, std::string
const
&,
EventContext
const
& )
override
;
30
void
after
( std::string
const
&, std::string
const
&,
EventContext
const
&,
StatusCode
const
& )
override
;
31
32
public
:
33
using
Auditor::Auditor;
34
StatusCode
initialize
()
override
;
35
StatusCode
finalize
()
override
;
36
37
private
:
39
AlgContextAuditor
() =
delete
;
40
AlgContextAuditor
(
const
AlgContextAuditor
& ) =
delete
;
41
AlgContextAuditor
&
operator=
(
const
AlgContextAuditor
& ) =
delete
;
42
43
private
:
45
SmartIF<IAlgContextSvc>
m_svc
;
47
SmartIF<IAlgManager>
m_algMgr
;
48
};
49
50
// mandatory auditor factory, needed for instantiation
51
DECLARE_COMPONENT
(
AlgContextAuditor
)
52
53
StatusCode
AlgContextAuditor
::
initialize
() {
54
return
Auditor::initialize().andThen( [&] {
55
m_svc
=
service
(
"AlgContextSvc"
,
true
);
56
if
( !
m_svc
) {
57
error
() <<
"Invalid pointer to IAlgContextSvc"
<<
endmsg
;
58
return
StatusCode::FAILURE
;
// RETURN
59
}
60
m_algMgr
=
serviceLocator
();
61
if
( !
m_algMgr
) {
62
error
() <<
"Invalid pointer to IAlgManager"
<<
endmsg
;
63
return
StatusCode::FAILURE
;
// RETURN
64
}
65
return
StatusCode::SUCCESS
;
66
} );
67
}
68
69
StatusCode
AlgContextAuditor::finalize
() {
70
m_svc
.reset();
71
m_algMgr
.reset();
72
return
Auditor::finalize();
73
}
74
75
void
AlgContextAuditor::before
( std::string
const
& event, std::string
const
& caller,
EventContext
const
& context ) {
76
if
(
m_svc
&& ( event ==
Gaudi::IAuditor::Initialize
|| event ==
Gaudi::IAuditor::Execute
||
77
event ==
Gaudi::IAuditor::Finalize
) ) {
78
SmartIF<IAlgorithm>
& alg =
m_algMgr
->algorithm( caller,
false
);
79
if
( alg )
m_svc
->setCurrentAlg( alg, context ).ignore();
80
}
81
}
82
83
void
AlgContextAuditor::after
( std::string
const
& event, std::string
const
& caller,
EventContext
const
& context,
84
StatusCode
const
& ) {
85
if
(
m_svc
&& ( event ==
Gaudi::IAuditor::Initialize
|| event ==
Gaudi::IAuditor::Execute
||
86
event ==
Gaudi::IAuditor::Finalize
) ) {
87
SmartIF<IAlgorithm>
& alg =
m_algMgr
->algorithm( caller,
false
);
88
if
( alg )
m_svc
->unSetCurrentAlg( alg, context ).ignore();
89
}
90
}
Auditor.h
EventContext.h
IAlgContextSvc.h
IAlgManager.h
IAlgorithm.h
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition
MsgStream.h:198
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition
PluginServiceV1.h:45
AlgContextAuditor
Description: Register/Unregister the AlgContext of each algorithm before entering the algorithm and a...
Definition
AlgContextAuditor.cpp:26
AlgContextAuditor::m_algMgr
SmartIF< IAlgManager > m_algMgr
the pointer to Algorithm Manager
Definition
AlgContextAuditor.cpp:47
AlgContextAuditor::initialize
StatusCode initialize() override
Definition
AlgContextAuditor.cpp:53
AlgContextAuditor::operator=
AlgContextAuditor & operator=(const AlgContextAuditor &)=delete
AlgContextAuditor::after
void after(std::string const &, std::string const &, EventContext const &, StatusCode const &) override
Definition
AlgContextAuditor.cpp:83
AlgContextAuditor::AlgContextAuditor
AlgContextAuditor(const AlgContextAuditor &)=delete
AlgContextAuditor::AlgContextAuditor
AlgContextAuditor()=delete
delete the default/copy constructor and assignment
AlgContextAuditor::finalize
StatusCode finalize() override
Definition
AlgContextAuditor.cpp:69
AlgContextAuditor::m_svc
SmartIF< IAlgContextSvc > m_svc
the pointer to Algorithm Context Service
Definition
AlgContextAuditor.cpp:45
AlgContextAuditor::before
void before(std::string const &, std::string const &, EventContext const &) override
Definition
AlgContextAuditor.cpp:75
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition
CommonMessaging.h:109
EventContext
This class represents an entry point to all the event specific data.
Definition
EventContext.h:35
Gaudi::Auditor
Base class from which all concrete auditor classes should be derived.
Definition
Auditor.h:33
Gaudi::Auditor::service
SmartIF< T > service(std::string_view name, bool createIf=false) const
Access a service by name, creating it if it doesn't already exist.
Definition
Auditor.h:63
Gaudi::Auditor::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
Definition
Auditor.h:59
Gaudi::IAuditor::Initialize
static const std::string Initialize
Definition
IAuditor.h:47
Gaudi::IAuditor::Finalize
static const std::string Finalize
Definition
IAuditor.h:53
Gaudi::IAuditor::Execute
static const std::string Execute
Definition
IAuditor.h:51
IAlgContextSvc
An abstract interface for Algorithm Context Service.
Definition
IAlgContextSvc.h:25
SmartIF
Small smart pointer class with automatic reference counting for IInterface.
Definition
SmartIF.h:28
StatusCode
This class is used for returning status codes from appropriate routines.
Definition
StatusCode.h:64
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition
StatusCode.h:99
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition
StatusCode.h:100
GaudiAud
src
AlgContextAuditor.cpp
Generated on
for The Gaudi Framework by
1.17.0