fluxbox/src/FbTk/SignalHandler.hh

71 lines
2.3 KiB
C++
Raw Normal View History

// SignalHandler.hh for FbTk
2002-11-26 16:01:28 +00:00
// Copyright (c) 2002 Henrik Kinnunen (fluxgen@linuxmail.org)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
2003-01-05 23:34:38 +00:00
// $Id: SignalHandler.hh,v 1.4 2003/01/05 23:34:38 fluxgen Exp $
2002-11-26 16:01:28 +00:00
#ifndef FBTK_SIGNALHANDLER_HH
#define FBTK_SIGNALHANDLER_HH
#include <signal.h>
namespace FbTk {
class SignalEventHandler {
public:
2002-12-01 13:42:15 +00:00
virtual void handleSignal(int signum) = 0;
2002-11-26 16:01:28 +00:00
};
/**
2002-12-01 13:42:15 +00:00
Handles system signals, singleton.
2003-01-05 23:34:38 +00:00
Usage: inherit the class SignalEventHandler and then register
2002-12-01 13:42:15 +00:00
it to SignalHandler by calling registerHandler with
a signal number
2002-11-26 16:01:28 +00:00
*/
class SignalHandler {
public:
2002-12-01 13:42:15 +00:00
/// get singleton object
static SignalHandler *instance();
/**
Register an event handler
@return true on success else false
@param signum signal number
@param eh event handler
@param oldhandler_ret return handler to old sighandler
*/
bool registerHandler(int signum, SignalEventHandler *eh, SignalEventHandler **oldhandler_ret = 0);
/**
removes the signum handler
@param signum signal number
*/
void removeHandler(int signum);
2002-11-26 16:01:28 +00:00
private:
2002-12-01 13:42:15 +00:00
SignalHandler();
2002-11-26 16:01:28 +00:00
2002-12-01 13:42:15 +00:00
static void handleSignal(int signum);
2002-11-26 16:01:28 +00:00
2002-12-01 13:42:15 +00:00
static SignalEventHandler *s_signal_handler[NSIG]; ///< NSIG defined in signal.h
2002-11-26 16:01:28 +00:00
};
}; // end namespace FbTk
#endif // FBTK_SIGNALHANDLER_HH