The Gaudi Framework  v40r0 (475e45c1)
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 const * 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::string > getInterfaceNames () 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 () const override
 Reference Interface instance
More...
 
unsigned long release () const 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 Member Functions inherited from implements< IIncidentListener >
unsigned long decRef () const override
 
- Protected Attributes inherited from implements< IIncidentListener >
std::atomic_ulong m_refCount
 Reference counter
More...
 

Detailed Description

Definition at line 23 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 ), 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 }

◆ ~IncidentListenerTest()

IncidentListenerTest::~IncidentListenerTest ( )
override

Destructor.

Definition at line 30 of file IncidentListenerTest.cpp.

30 {}

Member Function Documentation

◆ handle()

void IncidentListenerTest::handle ( const Incident incident)
override

Reimplements from IIncidentListener.

Definition at line 33 of file IncidentListenerTest.cpp.

33  {
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 }

Member Data Documentation

◆ m_incSvc

SmartIF<IIncidentSvc> IncidentListenerTest::m_incSvc
private

Definition at line 39 of file IncidentListenerTest.h.

◆ m_msgSvc

SmartIF<IMessageSvc> IncidentListenerTest::m_msgSvc
private

Definition at line 38 of file IncidentListenerTest.h.

◆ m_name

std::string IncidentListenerTest::m_name
private

Definition at line 36 of file IncidentListenerTest.h.

◆ m_shots

long IncidentListenerTest::m_shots
private

Definition at line 37 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:22
IncidentListenerTest::m_name
std::string m_name
Definition: IncidentListenerTest.h:36
GaudiException
Definition: GaudiException.h:29
IncidentListenerTest::m_incSvc
SmartIF< IIncidentSvc > m_incSvc
Definition: IncidentListenerTest.h:39
ISvcLocator::service
virtual SmartIF< IService > & service(const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true)=0
Returns a smart pointer to a service.
IncidentListenerTest::m_msgSvc
SmartIF< IMessageSvc > m_msgSvc
Definition: IncidentListenerTest.h:38
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:198
MsgStream
Definition: MsgStream.h:29
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
Incident::type
const std::string & type() const
Access to the incident type.
Definition: Incident.h:43
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:100
IncidentListenerTest::m_shots
long m_shots
Definition: IncidentListenerTest.h:37