The Gaudi Framework
v41r0 (bdbe7744)
Toggle main menu visibility
Loading...
Searching...
No Matches
IncidentListenerTestAlg.cpp
Go to the documentation of this file.
1
/***********************************************************************************\
2
* (c) Copyright 1998-2024 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
#include "
IncidentListenerTestAlg.h
"
12
13
#include "
IncidentListenerTest.h
"
14
15
#include <
GaudiKernel/IIncidentSvc.h
>
16
#include <
GaudiKernel/Incident.h
>
17
18
// Static Factory declaration
19
DECLARE_COMPONENT
(
IncidentListenerTestAlg
)
20
21
std::string
IncidentListenerTestAlg::s_incidentType
=
"TestIncident"
;
22
23
std::string&
IncidentListenerTestAlg::incident
() {
return
s_incidentType
; }
24
25
//=============================================================================
26
StatusCode
IncidentListenerTestAlg::initialize
() {
27
StatusCode
sc =
Algorithm::initialize
();
28
if
( sc.
isFailure
() )
return
sc;
29
30
// get a the incident service
31
m_incSvc
=
service
(
"IncidentSvc"
,
true
);
32
33
// instantiate listeners
34
m_listener
[0].reset(
new
IncidentListenerTest
(
"Listener 0"
,
serviceLocator
() ) );
35
m_listener
[1].reset(
new
IncidentListenerTest
(
"Listener 1"
,
serviceLocator
(), 3 ) );
36
m_listener
[2].reset(
new
IncidentListenerTest
(
"Listener 2"
,
serviceLocator
() ) );
37
m_listener
[3].reset(
new
IncidentListenerTest
(
"Listener 3"
,
serviceLocator
() ) );
38
m_listener
[4].reset(
new
IncidentListenerTest
(
"EventBoundary"
,
serviceLocator
() ) );
39
m_listener
[5].reset(
new
IncidentListenerTest
(
"Generic Listener"
,
serviceLocator
() ) );
40
41
info
() <<
"Registering incident listeners"
<<
endmsg
;
42
43
const
bool
rethrow =
false
;
44
const
bool
singleShot =
true
;
45
const
long
priority = -10;
46
m_incSvc
->addListener(
m_listener
[3].get(),
incident
(), priority, rethrow, singleShot );
47
48
m_incSvc
->addListener(
m_listener
[0].get(),
incident
() );
49
m_incSvc
->addListener(
m_listener
[1].get(),
incident
() );
50
m_incSvc
->addListener(
m_listener
[2].get(),
incident
() );
51
52
m_incSvc
->addListener(
m_listener
[4].get(), IncidentType::BeginEvent );
53
m_incSvc
->addListener(
m_listener
[4].get(), IncidentType::EndEvent );
54
55
m_incSvc
->addListener(
m_listener
[5].get() );
56
57
return
StatusCode::SUCCESS
;
58
}
59
60
//=============================================================================
61
StatusCode
IncidentListenerTestAlg::execute
() {
62
info
() <<
"Firing incident"
<<
endmsg
;
63
m_incSvc
->fireIncident(
Incident
(
name
(),
incident
() ) );
64
return
StatusCode::SUCCESS
;
65
}
66
67
//=============================================================================
68
StatusCode
IncidentListenerTestAlg::finalize
() {
69
info
() <<
"Finalize"
<<
endmsg
;
70
return
Algorithm::finalize
();
71
}
IIncidentSvc.h
Incident.h
IncidentListenerTest.h
IncidentListenerTestAlg.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
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition
CommonMessaging.h:115
Gaudi::Algorithm::initialize
StatusCode initialize() override
the default (empty) implementation of IStateful::initialize() method
Definition
Algorithm.h:175
Gaudi::Algorithm::finalize
StatusCode finalize() override
the default (empty) implementation of IStateful::finalize() method
Definition
Algorithm.h:181
Gaudi::Algorithm::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
Definition
Algorithm.cpp:562
Gaudi::Algorithm::name
const std::string & name() const override
The identifying name of the algorithm object.
Definition
Algorithm.cpp:518
Gaudi::Algorithm::service
SmartIF< IService > service(std::string_view name, const bool createIf=true, const bool quiet=false) const
Return a pointer to the service identified by name (or "type/name").
Definition
Algorithm.cpp:621
Incident
Base class for all Incidents (computing events).
Definition
Incident.h:24
IncidentListenerTestAlg
Definition
IncidentListenerTestAlg.h:20
IncidentListenerTestAlg::s_incidentType
static std::string s_incidentType
Definition
IncidentListenerTestAlg.h:31
IncidentListenerTestAlg::m_listener
std::array< std::unique_ptr< IncidentListenerTest >, 6 > m_listener
Definition
IncidentListenerTestAlg.h:33
IncidentListenerTestAlg::execute
StatusCode execute() override
Definition
IncidentListenerTestAlg.cpp:61
IncidentListenerTestAlg::m_incSvc
SmartIF< IIncidentSvc > m_incSvc
Definition
IncidentListenerTestAlg.h:32
IncidentListenerTestAlg::finalize
StatusCode finalize() override
Definition
IncidentListenerTestAlg.cpp:68
IncidentListenerTestAlg::initialize
StatusCode initialize() override
Definition
IncidentListenerTestAlg.cpp:26
IncidentListenerTestAlg::incident
static std::string & incident()
Definition
IncidentListenerTestAlg.cpp:23
IncidentListenerTest
Definition
IncidentListenerTest.h:23
StatusCode
This class is used for returning status codes from appropriate routines.
Definition
StatusCode.h:64
StatusCode::isFailure
bool isFailure() const
Definition
StatusCode.h:118
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition
StatusCode.h:99
GaudiTestSuite
src
IncidentSvc
IncidentListenerTestAlg.cpp
Generated on
for The Gaudi Framework by
1.17.0