Gaudi Framework, version v23r8

Home   Generated: Fri May 31 2013
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Types | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Gaudi::Utils::SignalMonitorSvc Class Reference

Implementation of Gaudi::ISignalMonitor. More...

Inheritance diagram for Gaudi::Utils::SignalMonitorSvc:
Inheritance graph
[legend]
Collaboration diagram for Gaudi::Utils::SignalMonitorSvc:
Collaboration graph
[legend]

Public Types

typedef struct sigaction handler_t
 
- Public Types inherited from extends1< Service, Gaudi::ISignalMonitor >
typedef extends1 base_class
 Typedef to this class.
 
typedef extend_interfaces1
< Gaudi::ISignalMonitor
extend_interfaces_base
 Typedef to the base of this class.
 
typedef
extend_interfaces_base::ext_iids 
interfaces
 MPL set of all the implemented interfaces.
 
- Public Types inherited from extend_interfaces1< Gaudi::ISignalMonitor >
typedef
Gaudi::ISignalMonitor::iid::iids::type 
ext_iids
 MPL set of interfaces extended by this one.
 

Public Member Functions

void monitorSignal (int signum, bool propagate)
 Declare a signal to be monitored.
 
void ignoreSignal (int signum)
 Remove the specific signal handler for the requested signal, restoring the previous signal handler.
 
bool gotSignal (int signum) const
 Check if the given signal has been received.
 
void setSignal (int signum)
 Set the flag for the given signal, as if the signal was received.
 
void clearSignal (int signum)
 Clear the flag for the given signal, so that a new occurrence can be identified.
 
 SignalMonitorSvc (const std::string &name, ISvcLocator *svcLoc)
 Initialize internal variables of the service and set the instance pointer.
 
virtual ~SignalMonitorSvc ()
 Stop monitoring signals and clear the instance pointer.
 
- Public Member Functions inherited from extends1< Service, Gaudi::ISignalMonitor >
 extends1 (A1 a1, A2 a2, A3 a3)
 Templated constructor with 3 arguments.
 
 extends1 (A1 a1, A2 a2)
 Templated constructor with 2 arguments.
 
 extends1 (A1 a1)
 Templated constructor with 1 argument.
 
 extends1 ()
 Default constructor.
 
virtual void * i_cast (const InterfaceID &tid) const
 Implementation of IInterface::i_cast.
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)
 Implementation of IInterface::queryInterface.
 
virtual std::vector< std::stringgetInterfaceNames () const
 Implementation of IInterface::getInterfaceNames.
 
virtual ~extends1 ()
 Virtual destructor.
 
- Public Member Functions inherited from Service
virtual unsigned long release ()
 Release Interface instance.
 
virtual const std::stringname () const
 Retrieve name of the service.
 
virtual StatusCode configure ()
 
virtual StatusCode initialize ()
 
virtual StatusCode start ()
 
virtual StatusCode stop ()
 
virtual StatusCode finalize ()
 
virtual StatusCode terminate ()
 
virtual Gaudi::StateMachine::State FSMState () const
 
virtual Gaudi::StateMachine::State targetFSMState () const
 
virtual StatusCode reinitialize ()
 
virtual StatusCode restart ()
 
virtual StatusCode sysInitialize ()
 Initialize Service.
 
virtual StatusCode sysStart ()
 Initialize Service.
 
virtual StatusCode sysStop ()
 Initialize Service.
 
virtual StatusCode sysFinalize ()
 Finalize Service.
 
virtual StatusCode sysReinitialize ()
 Re-initialize the Service.
 
virtual StatusCode sysRestart ()
 Re-initialize the Service.
 
virtual StatusCode setProperty (const Property &p)
 
virtual StatusCode setProperty (const std::string &s)
 
virtual StatusCode setProperty (const std::string &n, const std::string &v)
 
virtual StatusCode getProperty (Property *p) const
 
virtual const PropertygetProperty (const std::string &name) const
 
virtual StatusCode getProperty (const std::string &n, std::string &v) const
 
virtual const std::vector
< Property * > & 
getProperties () const
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 
 Service (const std::string &name, ISvcLocator *svcloc)
 Standard Constructor.
 
SmartIF< ISvcLocator > & serviceLocator () const
 Retrieve pointer to service locator.
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified for the job.
 
template<class T >
StatusCode service (const std::string &name, const T *&psvc, bool createIf=true) const
 Access a service by name, creating it if it doesn't already exist.
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 
template<class T >
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist.
 
template<class T >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property.
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties.
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked.
 
- Public Member Functions inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
 CommonMessaging (const A1 &a1, const A2 &a2, const A3 &a3)
 Templated constructor with 3 arguments.
 
 CommonMessaging (const A1 &a1, const A2 &a2)
 Templated constructor with 2 arguments.
 
 CommonMessaging (const A1 &a1)
 Templated constructor with 1 argument.
 
 CommonMessaging ()
 Default constructor.
 
virtual ~CommonMessaging ()
 Virtual destructor.
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service.
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream.
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts.
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS)
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL)
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING)
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO)
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG)
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE)
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO)
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream
 
- Public Member Functions inherited from extend_interfaces1< Gaudi::ISignalMonitor >
virtual ~extend_interfaces1 ()
 Virtual destructor.
 
- Public Member Functions inherited from Gaudi::ISignalMonitor
 DeclareInterfaceID (ISignalMonitor, 1, 0)
 InterfaceID.
 
- Public Member Functions inherited from IInterface
virtual unsigned long addRef ()=0
 Increment the reference count of Interface instance.
 
virtual unsigned long release ()=0
 Release Interface instance.
 
virtual unsigned long refCount () const =0
 Current reference count.
 
virtual ~IInterface ()
 Virtual destructor.
 

Private Types

enum  MonitoringMode { ignored, trap, propagate }
 Possible monitoring modes. More...
 

Private Member Functions

void i_handle (int signum)
 

Static Private Member Functions

static void setInstance (SignalMonitorSvc *i)
 
static SignalMonitorSvcinstance ()
 Method to get the singleton instance.
 
static void dispatcher (int signum)
 Signal handler function.
 

Private Attributes

MonitoringMode m_monitored [NSIG]
 Array of flags to keep track of monitored signals.
 
sig_atomic_t m_caught [NSIG]
 Array of flags for received signals.
 
handler_t m_defaultAction
 Helper variable for default signal action.
 
handler_t m_oldActions [NSIG]
 List of replaced signal actions (for the recovery when disable the monitoring).
 

Static Private Attributes

static SignalMonitorSvcs_instance = 0
 Pointer to the current instance.
 

Additional Inherited Members

- Static Public Member Functions inherited from IInterface
static const InterfaceIDinterfaceID ()
 Return an instance of InterfaceID identifying the interface.
 
- Protected Member Functions inherited from Service
virtual ~Service ()
 Standard Destructor.
 
int outputLevel () const
 get the Service's output level
 
- Protected Attributes inherited from Service
IntegerProperty m_outputLevel
 Service output level.
 
Gaudi::StateMachine::State m_state
 Service state.
 
Gaudi::StateMachine::State m_targetState
 Service state.
 

Detailed Description

Implementation of Gaudi::ISignalMonitor.

If instantiated, intercepts the system signals and keep track of the recorded ones.

The signal to be monitored have to be declared via the method monitorSignal(). It can be interrogated to check if a signal has been received.

Definition at line 26 of file SignalMonitorSvc.cpp.

Member Typedef Documentation

typedef struct sigaction Gaudi::Utils::SignalMonitorSvc::handler_t

Definition at line 31 of file SignalMonitorSvc.cpp.

Member Enumeration Documentation

enum Gaudi::Utils::SignalMonitorSvc::MonitoringMode
private

Possible monitoring modes.

Enumerator:
ignored 
trap 
propagate 

Definition at line 112 of file SignalMonitorSvc.cpp.

{
ignored, //< the signal is not monitored
trap, //< the signal is monitored and not propagated to previously registered handlers
propagate //< the signal is monitored and propagated to previously registered handlers
};

Constructor & Destructor Documentation

Gaudi::Utils::SignalMonitorSvc::SignalMonitorSvc ( const std::string name,
ISvcLocator svcLoc 
)
inline

Initialize internal variables of the service and set the instance pointer.

Definition at line 85 of file SignalMonitorSvc.cpp.

: base_class(name, svcLoc) {
#ifdef _WIN32
m_defaultAction = SIG_DFL;
#else
m_defaultAction.sa_handler = SIG_DFL;
sigemptyset(&m_defaultAction.sa_mask);
m_defaultAction.sa_flags = 0;
#endif
for(int i = 0; i < NSIG; ++i){
m_caught[i] = 0;
}
setInstance(this);
}
virtual Gaudi::Utils::SignalMonitorSvc::~SignalMonitorSvc ( )
inlinevirtual

Stop monitoring signals and clear the instance pointer.

Definition at line 103 of file SignalMonitorSvc.cpp.

{
for (int i = 0; i < NSIG; ++i) {
}
}

Member Function Documentation

void Gaudi::Utils::SignalMonitorSvc::clearSignal ( int  signum)
inlinevirtual

Clear the flag for the given signal, so that a new occurrence can be identified.

Implements Gaudi::ISignalMonitor.

Definition at line 80 of file SignalMonitorSvc.cpp.

{
m_caught[signum] = 0;
}
void Gaudi::Utils::SignalMonitorSvc::dispatcher ( int  signum)
staticprivate

Signal handler function.

Definition at line 161 of file SignalMonitorSvc.cpp.

{
if (instance()) instance()->i_handle(signum);
}
bool Gaudi::Utils::SignalMonitorSvc::gotSignal ( int  signum) const
inlinevirtual

Check if the given signal has been received.

Implements Gaudi::ISignalMonitor.

Definition at line 70 of file SignalMonitorSvc.cpp.

{
return m_caught[signum] != 0;
}
void Gaudi::Utils::SignalMonitorSvc::i_handle ( int  signum)
inlineprivate

Definition at line 126 of file SignalMonitorSvc.cpp.

{
m_caught[signum] = 1;
if ( m_monitored[signum] == propagate &&
#ifdef _WIN32
m_oldActions[signum] != SIG_DFL
#else
m_oldActions[signum].sa_handler != SIG_DFL
#endif
) {
#ifdef _WIN32
m_oldActions[signum](signum);
#else
m_oldActions[signum].sa_handler(signum);
#endif
}
}
void Gaudi::Utils::SignalMonitorSvc::ignoreSignal ( int  signum)
inlinevirtual

Remove the specific signal handler for the requested signal, restoring the previous signal handler.

Implements Gaudi::ISignalMonitor.

Definition at line 57 of file SignalMonitorSvc.cpp.

{
if (m_monitored[signum]) {
#ifdef _WIN32
(void) signal(signum, m_oldActions[signum]);
#else
sigaction(signum, &m_oldActions[signum], 0);
#endif
m_monitored[signum] = ignored;
}
}
static SignalMonitorSvc* Gaudi::Utils::SignalMonitorSvc::instance ( )
inlinestaticprivate

Method to get the singleton instance.

Bypass the serviceLocator for efficiency.

Definition at line 152 of file SignalMonitorSvc.cpp.

{
return s_instance;
}
void Gaudi::Utils::SignalMonitorSvc::monitorSignal ( int  signum,
bool  propagate 
)
inlinevirtual

Declare a signal to be monitored.

It installs a signal handler for the requested signal.

Implements Gaudi::ISignalMonitor.

Definition at line 36 of file SignalMonitorSvc.cpp.

{
if (!m_monitored[signum]) {
handler_t oldact;
#ifdef _WIN32
sa = SignalMonitorSvc::dispatcher;
oldact = signal(signum, sa);
#else
sa.sa_handler = SignalMonitorSvc::dispatcher;
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
sigaction(signum, &sa, &oldact);
#endif
m_oldActions[signum] = oldact;
m_monitored[signum] = (propagate) ? SignalMonitorSvc::propagate
: SignalMonitorSvc::trap;
}
}
static void Gaudi::Utils::SignalMonitorSvc::setInstance ( SignalMonitorSvc i)
inlinestaticprivate

Definition at line 146 of file SignalMonitorSvc.cpp.

{
}
void Gaudi::Utils::SignalMonitorSvc::setSignal ( int  signum)
inlinevirtual

Set the flag for the given signal, as if the signal was received.

Implements Gaudi::ISignalMonitor.

Definition at line 75 of file SignalMonitorSvc.cpp.

{
m_caught[signum] = 1;
}

Member Data Documentation

sig_atomic_t Gaudi::Utils::SignalMonitorSvc::m_caught[NSIG]
private

Array of flags for received signals.

Definition at line 120 of file SignalMonitorSvc.cpp.

handler_t Gaudi::Utils::SignalMonitorSvc::m_defaultAction
private

Helper variable for default signal action.

Definition at line 122 of file SignalMonitorSvc.cpp.

MonitoringMode Gaudi::Utils::SignalMonitorSvc::m_monitored[NSIG]
private

Array of flags to keep track of monitored signals.

Definition at line 118 of file SignalMonitorSvc.cpp.

handler_t Gaudi::Utils::SignalMonitorSvc::m_oldActions[NSIG]
private

List of replaced signal actions (for the recovery when disable the monitoring).

Definition at line 124 of file SignalMonitorSvc.cpp.

Gaudi::Utils::SignalMonitorSvc * Gaudi::Utils::SignalMonitorSvc::s_instance = 0
staticprivate

Pointer to the current instance.

Definition at line 144 of file SignalMonitorSvc.cpp.


The documentation for this class was generated from the following file:

Generated at Fri May 31 2013 15:09:27 for Gaudi Framework, version v23r8 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004