signal_handler.h

00001 /***************************************************************************
00002                           signal_handler.h  -  description
00003                              -------------------
00004     begin                : Fre Mär 14 2003
00005     copyright            : (C) 2003 by Bernd Roessler
00006     email                : roessler@informatik.uni-hamburg.de
00007  ***************************************************************************/
00008 
00009 #ifndef SIGNAL_HANDLER_H
00010 #define SIGNAL_HANDLER_H
00011 
00012 #include "event_handler.h"
00013 #include <signal.h>
00014 
00019 class Signal_Handler {
00020 public: 
00021         ~Signal_Handler();
00022 
00023   // Entry point.
00024   static Signal_Handler* instance (void);
00025 
00026   // Register an event handler <eh> for <signum>
00027   // and return a pointer to any existing <Event_Handler>
00028   // that was previously registered to handle <signum>.
00029   Event_Handler* register_handler (int signum, Event_Handler *eh);
00030 
00031   // Remove the <Event_Handler> for <signum>
00032   // by setting the slot in the <signal_handlers_>
00033   // table to NULL.
00034   void remove_handler (int signum);
00035 
00036 private:
00037   // Ensure we're a Singleton.
00038   Signal_Handler (void);
00039 
00040   // Singleton pointer.
00041   static Signal_Handler* instance_;
00042 
00043   // Entry point adapter installed into <sigaction>
00044   // (must be a static method or a stand-alone
00045   // extern "C" function).
00046   static void dispatcher (int signum);
00047 
00048   // Table of pointers to concrete <Event_Handler>s
00049   // registered by applications.  NSIG is the number of
00050   // signals defined in </usr/include/sys/signal.h>.
00051   static Event_Handler* signal_handlers_[NSIG];
00052 
00053 };
00054 
00055 #endif


tams Tim Baier bhandlib v0.25
Generated Wed Aug 16 14:57:09 2006 by doxygen 1.4.7