The Gaudi Framework  master (594c33fa)
IncidentListenerTest Class Reference

#include </builds/gaudi/Gaudi/GaudiTestSuite/src/IncidentSvc/IncidentListenerTest.h>

Inheritance diagram for IncidentListenerTest:
Collaboration diagram for IncidentListenerTest:

Public Member Functions

 IncidentListenerTest (const std::string &name, ISvcLocator *svcloc, long shots=-1)
 Constructor. More...
 
 ~IncidentListenerTest () override
 Destructor. More...
 
void handle (const Incident &incident) override
 Reimplements from IIncidentListener. More...
 
- Public Member Functions inherited from implements< IIncidentListener >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::stringgetInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 implements ()=default
 Default constructor. More...
 
 implements (const implements &)
 Copy constructor (zero the reference count) More...
 
implementsoperator= (const implements &)
 Assignment operator (do not touch the reference count). More...
 
unsigned long addRef () override
 Reference Interface instance
More...
 
unsigned long release () override
 Release Interface instance
More...
 
unsigned long refCount () const override
 Current reference count
More...
 

Private Attributes

std::string m_name
 
long m_shots
 
SmartIF< IMessageSvcm_msgSvc
 
SmartIF< IIncidentSvcm_incSvc
 

Additional Inherited Members

- Public Types inherited from implements< IIncidentListener >
using base_class = implements< Interfaces... >
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces... >
 Typedef to the base of this class. More...
 
using iids = typename extend_interfaces_base::ext_iids
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type
 take union of the ext_iids of all Interfaces... More...
 
- Protected Attributes inherited from implements< IIncidentListener >
std::atomic_ulong m_refCount
 Reference counter
More...
 

Detailed Description

Definition at line 24 of file IncidentListenerTest.h.

Constructor & Destructor Documentation

◆ IncidentListenerTest()

IncidentListenerTest::IncidentListenerTest ( const std::string name,
ISvcLocator svcloc,
long  shots = -1 
)

Constructor.

Definition at line 23 of file IncidentListenerTest.cpp.

24  : m_name( name ), m_shots( shots ) {
25  m_msgSvc = svcloc; // default message service
26  if ( !m_msgSvc ) throw GaudiException( "Cannot find MessageSvc", m_name, StatusCode::FAILURE );
27  m_incSvc = svcloc->service( "IncidentSvc" );
28  if ( !m_incSvc ) throw GaudiException( "Cannot find IncidentSvc", m_name, StatusCode::FAILURE );
29 }

◆ ~IncidentListenerTest()

IncidentListenerTest::~IncidentListenerTest ( )
override

Destructor.

Definition at line 31 of file IncidentListenerTest.cpp.

31 {}

Member Function Documentation

◆ handle()

void IncidentListenerTest::handle ( const Incident incident)
override

Reimplements from IIncidentListener.

Definition at line 34 of file IncidentListenerTest.cpp.

34  {
36  log << MSG::INFO << "Handling incident '" << incident.type() << "'" << endmsg;
37  if ( ( m_shots > 0 ) && ( --m_shots == 0 ) ) {
38  log << MSG::INFO << "deregistering" << endmsg;
39  m_incSvc->removeListener( this, incident.type() );
40  }
41 }

Member Data Documentation

◆ m_incSvc

SmartIF<IIncidentSvc> IncidentListenerTest::m_incSvc
private

Definition at line 40 of file IncidentListenerTest.h.

◆ m_msgSvc

SmartIF<IMessageSvc> IncidentListenerTest::m_msgSvc
private

Definition at line 39 of file IncidentListenerTest.h.

◆ m_name

std::string IncidentListenerTest::m_name
private

Definition at line 37 of file IncidentListenerTest.h.

◆ m_shots

long IncidentListenerTest::m_shots
private

Definition at line 38 of file IncidentListenerTest.h.


The documentation for this class was generated from the following files:
Gaudi.Configuration.log
log
Definition: Configuration.py:28
MSG::INFO
@ INFO
Definition: IMessageSvc.h:25
IncidentListenerTest::m_name
std::string m_name
Definition: IncidentListenerTest.h:37
GaudiException
Definition: GaudiException.h:31
IncidentListenerTest::m_incSvc
SmartIF< IIncidentSvc > m_incSvc
Definition: IncidentListenerTest.h:40
IncidentListenerTest::m_msgSvc
SmartIF< IMessageSvc > m_msgSvc
Definition: IncidentListenerTest.h:39
ISvcLocator::service
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:97
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:203
MsgStream
Definition: MsgStream.h:34
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
Incident::type
const std::string & type() const
Access to the incident type.
Definition: Incident.h:48
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
IncidentListenerTest::m_shots
long m_shots
Definition: IncidentListenerTest.h:38