The Gaudi Framework  master (181af51f)
Loading...
Searching...
No Matches
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.
 
 ~IncidentListenerTest () override
 Destructor.
 
void handle (const Incident &incident) override
 Reimplements from IIncidentListener.
 
- Public Member Functions inherited from implements< IIncidentListener >
void const * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast.
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface.
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames.
 
 implements ()=default
 Default constructor.
 
 implements (const implements &)
 Copy constructor (zero the reference count)
 
implementsoperator= (const implements &)
 Assignment operator (do not touch the reference count).
 
unsigned long addRef () const override
 Reference Interface instance.
 
unsigned long release () const override
 Release Interface instance.
 
unsigned long refCount () const override
 Current reference count.
 

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
 Typedef to this class.
 
using extend_interfaces_base
 Typedef to the base of this class.
 
using iids
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids
 take union of the ext_iids of all Interfaces...
 
- 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.
 

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}
virtual SmartIF< IService > & service(const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true)=0
Returns a smart pointer to a service.
SmartIF< IIncidentSvc > m_incSvc
SmartIF< IMessageSvc > m_msgSvc
constexpr static const auto FAILURE
Definition StatusCode.h:100

◆ ~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 {
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}
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
const std::string & type() const
Access to the incident type.
Definition Incident.h:43
@ INFO
Definition IMessageSvc.h:22

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: