Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages | Examples

ArSignalHandler.h

00001 /*
00002 MobileRobots Advanced Robotics Interface for Applications (ARIA)
00003 Copyright (C) 2004, 2005 ActivMedia Robotics LLC
00004 Copyright (C) 2006, 2007 MobileRobots Inc.
00005 
00006      This program is free software; you can redistribute it and/or modify
00007      it under the terms of the GNU General Public License as published by
00008      the Free Software Foundation; either version 2 of the License, or
00009      (at your option) any later version.
00010 
00011      This program is distributed in the hope that it will be useful,
00012      but WITHOUT ANY WARRANTY; without even the implied warranty of
00013      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014      GNU General Public License for more details.
00015 
00016      You should have received a copy of the GNU General Public License
00017      along with this program; if not, write to the Free Software
00018      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 
00020 If you wish to redistribute ARIA under different terms, contact 
00021 MobileRobots for information about a commercial version of ARIA at 
00022 robots@mobilerobots.com or 
00023 MobileRobots Inc, 19 Columbia Drive, Amherst, NH 03031; 800-639-9481
00024 */
00025 
00026 #ifndef ARSIGNALHANDLER_H
00027 #define ARSIGNALHANDLER_H
00028 
00029 
00030 #include <list>
00031 #ifdef WIN32
00032 #else
00033 #include <signal.h>
00034 #endif
00035 #include "ariaTypedefs.h"
00036 #include "ArASyncTask.h"
00037 #include "ArFunctor.h"
00038 
00039 
00041 
00078 class ArSignalHandler : public ArASyncTask
00079 {
00080 public:
00081 
00082   typedef enum
00083   {
00084     SigHUP=1, SigINT, SigQUIT, SigILL, SigTRAP, SigABRT, SigBUS, SigFPE, 
00085     SigKILL, SigUSR1, SigSEGV, SigUSR2, SigPIPE, SigALRM, SigTERM, SigSTKFLT, 
00086     SigCHLD, SigCONT, SigSTOP, SigTSTP, SigTTIN, SigTTOU, SigURG,
00087     SigXCPU, SigXFSZ, SigVTALRM, SigPROF, SigWINCH, SigIO, SigPWR
00088   } Signal;
00089 
00091   AREXPORT static void createHandlerNonThreaded();
00092 
00094   AREXPORT static void createHandlerThreaded();
00095 
00097   AREXPORT static void blockCommon();
00098 
00100   AREXPORT static void unblockAll();
00101 
00103   AREXPORT static void block(Signal sig);
00104 
00106   AREXPORT static void unblock(Signal sig);
00107 
00109   AREXPORT static void handle(Signal sig);
00110 
00112   AREXPORT static void unhandle(Signal sig);
00113 
00115   AREXPORT static void addHandlerCB(ArFunctor1<int> *func,
00116                     ArListPos::Pos position);
00117 
00119   AREXPORT static void delHandlerCB(ArFunctor1<int> *func);
00120 
00122   AREXPORT static void delAllHandlerCBs(void);
00123 
00125   AREXPORT static ArSignalHandler * getHandler();
00126 
00128   AREXPORT static const char * nameSignal(int sig);
00129 
00131   AREXPORT static void blockCommonThisThread();
00132 
00134   AREXPORT static void blockAllThisThread();
00135 
00137   virtual ~ArSignalHandler();
00138 
00139   AREXPORT virtual void * runThread(void *arg);
00140 
00141   AREXPORT static void signalCB(int sig);
00142 
00143   AREXPORT static void logThread(void);
00144 protected:
00145 
00146   ArSignalHandler();
00147 
00148   static void initSigMap();
00149 
00150   bool ourIgnoreQUIT;
00151 
00152   static ArSignalHandler *ourSignalHandler;
00153   static ArStrMap ourSigMap;
00154 #ifdef WIN32
00155 #else
00156   static sigset_t ourBlockSigSet;
00157   static sigset_t ourHandleSigSet;
00158 #endif
00159   static std::list<ArFunctor1<int>*> ourHandlerList;
00160 };
00161 
00162 
00163 #endif // ARSIGNALHANDLER_H

Generated on Tue Feb 20 10:51:41 2007 for Aria by  doxygen 1.4.0