The Gaudi Framework
v41r0 (bdbe7744)
Toggle main menu visibility
Loading...
Searching...
No Matches
IncidentListenerTest.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
#include "
IncidentListenerTest.h
"
12
13
#include <
GaudiKernel/IIncidentSvc.h
>
14
#include <
GaudiKernel/IMessageSvc.h
>
15
#include <
GaudiKernel/IService.h
>
16
#include <
GaudiKernel/ISvcLocator.h
>
17
18
#include <
GaudiKernel/MsgStream.h
>
19
20
#include <
GaudiKernel/GaudiException.h
>
21
22
//=============================================================================
23
IncidentListenerTest::IncidentListenerTest
(
const
std::string& name,
ISvcLocator
* svcloc,
long
shots )
24
:
m_name
( name ),
m_shots
( shots ),
m_msgSvc
( svcloc ) {
25
if
( !
m_msgSvc
)
throw
GaudiException
(
"Cannot find MessageSvc"
,
m_name
,
StatusCode::FAILURE
);
26
m_incSvc
= svcloc->
service
(
"IncidentSvc"
);
27
if
( !
m_incSvc
)
throw
GaudiException
(
"Cannot find IncidentSvc"
,
m_name
,
StatusCode::FAILURE
);
28
}
29
30
IncidentListenerTest::~IncidentListenerTest
() {}
31
32
//=============================================================================
33
void
IncidentListenerTest::handle
(
const
Incident
& incident ) {
34
MsgStream
log(
m_msgSvc
,
m_name
);
35
log <<
MSG::INFO
<<
"Handling incident '"
<< incident.
type
() <<
"'"
<<
endmsg
;
36
if
( (
m_shots
> 0 ) && ( --
m_shots
== 0 ) ) {
37
log <<
MSG::INFO
<<
"deregistering"
<<
endmsg
;
38
m_incSvc
->removeListener(
this
, incident.
type
() );
39
}
40
}
GaudiException.h
IIncidentSvc.h
IMessageSvc.h
IService.h
ISvcLocator.h
IncidentListenerTest.h
MsgStream.h
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition
MsgStream.h:198
GaudiException
Define general base for Gaudi exception.
Definition
GaudiException.h:29
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition
ISvcLocator.h:42
ISvcLocator::service
virtual SmartIF< IService > & service(const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true)=0
Returns a smart pointer to a service.
Incident
Base class for all Incidents (computing events).
Definition
Incident.h:24
Incident::type
const std::string & type() const
Access to the incident type.
Definition
Incident.h:43
IncidentListenerTest::m_incSvc
SmartIF< IIncidentSvc > m_incSvc
Definition
IncidentListenerTest.h:39
IncidentListenerTest::m_msgSvc
SmartIF< IMessageSvc > m_msgSvc
Definition
IncidentListenerTest.h:38
IncidentListenerTest::IncidentListenerTest
IncidentListenerTest(const std::string &name, ISvcLocator *svcloc, long shots=-1)
Constructor.
Definition
IncidentListenerTest.cpp:23
IncidentListenerTest::~IncidentListenerTest
~IncidentListenerTest() override
Destructor.
Definition
IncidentListenerTest.cpp:30
IncidentListenerTest::handle
void handle(const Incident &incident) override
Reimplements from IIncidentListener.
Definition
IncidentListenerTest.cpp:33
IncidentListenerTest::m_name
std::string m_name
Definition
IncidentListenerTest.h:36
IncidentListenerTest::m_shots
long m_shots
Definition
IncidentListenerTest.h:37
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition
MsgStream.h:29
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition
StatusCode.h:100
MSG::INFO
@ INFO
Definition
IMessageSvc.h:22
GaudiTestSuite
src
IncidentSvc
IncidentListenerTest.cpp
Generated on
for The Gaudi Framework by
1.17.0