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

ArSignalHandler.h

00001 /*
00002 ActivMedia Robotics Interface for Applications (ARIA)
00003 Copyright (C) 2004,2005 ActivMedia Robotics, LLC
00004 
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 ActivMedia Robotics for information about a commercial version of ARIA at 
00022 robots@activmedia.com or 
00023 ActivMedia Robotics, 19 Columbia Drive, Amherst, NH 03031; 800-639-9481
00024 
00025 */
00026 
00027 #ifndef ARSIGNALHANDLER_H
00028 #define ARSIGNALHANDLER_H
00029 
00030 
00031 #include <list>
00032 #ifdef WIN32
00033 #else
00034 #include <signal.h>
00035 #endif
00036 #include "ariaTypedefs.h"
00037 #include "ArASyncTask.h"
00038 #include "ArFunctor.h"
00039 
00040 
00042 
00079 class ArSignalHandler : public ArASyncTask
00080 {
00081 public:
00082 
00083   typedef enum
00084   {
00085     SigHUP=1, SigINT, SigQUIT, SigILL, SigTRAP, SigABRT, SigBUS, SigFPE, 
00086     SigKILL, SigUSR1, SigSEGV, SigUSR2, SigPIPE, SigALRM, SigTERM, SigSTKFLT, 
00087     SigCHLD, SigCONT, SigSTOP, SigTSTP, SigTTIN, SigTTOU, SigURG,
00088     SigXCPU, SigXFSZ, SigVTALRM, SigPROF, SigWINCH, SigIO, SigPWR
00089   } Signal;
00090 
00092   static void createHandlerNonThreaded();
00093 
00095   static void createHandlerThreaded();
00096 
00098   static void blockCommon();
00099 
00101   static void unblockAll();
00102 
00104   static void block(Signal sig);
00105 
00107   static void unblock(Signal sig);
00108 
00110   static void handle(Signal sig);
00111 
00113   static void unhandle(Signal sig);
00114 
00116   static void addHandlerCB(ArFunctor1<int> *func,
00117                                     ArListPos::Pos position);
00118 
00120   static void delHandlerCB(ArFunctor1<int> *func);
00121 
00123   static ArSignalHandler * getHandler();
00124 
00126   static const char * nameSignal(int sig);
00127 
00129   static void blockCommonThisThread();
00130 
00132   static void blockAllThisThread();
00133 
00135   virtual ~ArSignalHandler();
00136 
00137   virtual void * runThread(void *arg);
00138 
00139   static void signalCB(int sig);
00140 
00141   static void logThread(void);
00142 protected:
00143 
00144   ArSignalHandler();
00145 
00146   static void initSigMap();
00147 
00148   bool ourIgnoreQUIT;
00149 
00150   static ArSignalHandler *ourSignalHandler;
00151   static ArStrMap ourSigMap;
00152 #ifdef WIN32
00153 #else
00154   static sigset_t ourBlockSigSet;
00155   static sigset_t ourHandleSigSet;
00156 #endif
00157   static std::list<ArFunctor1<int>*> ourHandlerList;
00158 };
00159 
00160 
00161 #endif // ARSIGNALHANDLER_H

Generated on Wed Oct 19 12:56:37 2005 for Aria by  doxygen 1.4.0