The Gaudi Framework  v41r0 (bdbe7744)
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\***********************************************************************************/
12
14
17
18// Static Factory declaration
20
21std::string IncidentListenerTestAlg::s_incidentType = "TestIncident";
22
24
25//=============================================================================
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
58}
59
60//=============================================================================
62 info() << "Firing incident" << endmsg;
63 m_incSvc->fireIncident( Incident( name(), incident() ) );
65}
66
67//=============================================================================
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
#define DECLARE_COMPONENT(type)
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
StatusCode initialize() override
the default (empty) implementation of IStateful::initialize() method
Definition Algorithm.h:175
StatusCode finalize() override
the default (empty) implementation of IStateful::finalize() method
Definition Algorithm.h:181
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
const std::string & name() const override
The identifying name of the algorithm object.
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").
Base class for all Incidents (computing events).
Definition Incident.h:24
std::array< std::unique_ptr< IncidentListenerTest >, 6 > m_listener
SmartIF< IIncidentSvc > m_incSvc
static std::string & incident()
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
bool isFailure() const
Definition StatusCode.h:118
constexpr static const auto SUCCESS
Definition StatusCode.h:99