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

ArSignalHandler_WIN.cpp

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 /*
00028 ActivMedia Robotics Interface for Applications (ARIA)
00029 Copyright (C) 2002, ActivMedia Robotics, LLC
00030 
00031 
00032      This program is free software; you can redistribute it and/or modify
00033      it under the terms of the GNU General Public License as published by
00034      the Free Software Foundation; either version 2 of the License, or
00035      (at your option) any later version.
00036 
00037      This program is distributed in the hope that it will be useful,
00038      but WITHOUT ANY WARRANTY; without even the implied warranty of
00039      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00040      GNU General Public License for more details.
00041 
00042      You should have received a copy of the GNU General Public License
00043      along with this program; if not, write to the Free Software
00044      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00045 
00046 If you wish to redistribute ARIA under different terms, contact 
00047 ActivMedia Robotics for information about a commercial version of ARIA at 
00048 robots@activmedia.com or 
00049 ActivMedia Robotics, 44 Concord Street, Peterborough, NH 03458; 603-924-9100
00050 
00051 */
00052 
00053 #include "ArExport.h"
00054 #include "ariaOSDef.h"
00055 #include "ArSignalHandler.h"
00056 #include "ArLog.h"
00057 
00058 
00059 ArSignalHandler *ArSignalHandler::ourSignalHandler=0;
00060 ArStrMap ArSignalHandler::ourSigMap;
00061 std::list<ArFunctor1<int>*> ArSignalHandler::ourHandlerList;
00062 
00063 
00064 void ArSignalHandler::signalCB(int sig)
00065 {
00066   std::list<ArFunctor1<int>*>::iterator iter;
00067 
00068   for (iter=ourHandlerList.begin(); iter != ourHandlerList.end(); ++iter)
00069     (*iter)->invoke(sig);
00070   if (ourHandlerList.begin() == ourHandlerList.end())
00071     ArLog::log(ArLog::Terse, "ArSignalHandler::runThread: No handler function. Unhandled signal '%s'", ourSigMap[sig].c_str());
00072 }  
00073 
00074 void ArSignalHandler::createHandlerNonThreaded()
00075 {
00076 }
00077 
00078 void ArSignalHandler::createHandlerThreaded()
00079 {
00080   getHandler()->create(false);
00081 }
00082 
00083 void ArSignalHandler::blockCommon()
00084 {
00085 }
00086 
00087 void ArSignalHandler::unblockAll()
00088 {
00089 }
00090 
00091 void ArSignalHandler::block(Signal sig)
00092 {
00093 }
00094 
00095 void ArSignalHandler::unblock(Signal sig)
00096 {
00097 }
00098 
00099 void ArSignalHandler::handle(Signal sig)
00100 {
00101 }
00102 
00103 void ArSignalHandler::unhandle(Signal sig)
00104 {
00105 }
00106 
00107 void ArSignalHandler::addHandlerCB(ArFunctor1<int> *func,
00108                                             ArListPos::Pos position)
00109 {
00110   if (position == ArListPos::FIRST)
00111     ourHandlerList.push_front(func);
00112   else if (position == ArListPos::LAST)
00113     ourHandlerList.push_back(func);
00114   else
00115     ArLog::log(ArLog::Terse, 
00116                "ArSignalHandler::addHandler: Invalid position.");
00117 }
00118 
00119 void ArSignalHandler::delHandlerCB(ArFunctor1<int> *func)
00120 {
00121   ourHandlerList.remove(func);
00122 }
00123 
00124 ArSignalHandler * ArSignalHandler::getHandler()
00125 {
00126   if (!ourSignalHandler)
00127     ourSignalHandler=new ArSignalHandler;
00128 
00129   return(ourSignalHandler);
00130 }
00131 
00132 void ArSignalHandler::blockCommonThisThread()
00133 {
00134 }
00135 
00136 void ArSignalHandler::blockAllThisThread()
00137 {
00138 }
00139 
00140 ArSignalHandler::ArSignalHandler()
00141 {
00142   setThreadName("ArSignalHandler");
00143   initSigMap();
00144 }
00145 
00146 ArSignalHandler::~ArSignalHandler()
00147 {
00148 }
00149 
00150 void * ArSignalHandler::runThread(void *arg)
00151 {
00152   threadStarted();
00153   return(0);
00154 }
00155 
00156 void ArSignalHandler::initSigMap()
00157 {
00158   ourSigMap[SigHUP]="SIGHUP";
00159   ourSigMap[SigINT]="SIGINT";
00160   ourSigMap[SigQUIT]="SIGQUIT";
00161   ourSigMap[SigILL]="SIGILL";
00162   ourSigMap[SigTRAP]="SIGTRAP";
00163   ourSigMap[SigABRT]="SIGABRT";
00164   //ourSigMap[SigIOT]="SIGIOT";
00165   ourSigMap[SigBUS]="SIGBUS";
00166   ourSigMap[SigFPE]="SIGFPE";
00167   ourSigMap[SigKILL]="SIGKILL";
00168   ourSigMap[SigUSR1]="SIGUSR1";
00169   ourSigMap[SigSEGV]="SIGSEGV";
00170   ourSigMap[SigUSR2]="SIGUSR2";
00171   ourSigMap[SigPIPE]="SIGPIPE";
00172   ourSigMap[SigALRM]="SIGALRM";
00173   ourSigMap[SigTERM]="SIGTERM";
00174   //ourSigMap[SigSTKFLT]="SIGSTKFLT";
00175   ourSigMap[SigCHLD]="SIGCHLD";
00176   ourSigMap[SigCONT]="SIGCONT";
00177   ourSigMap[SigSTOP]="SIGSTOP";
00178   ourSigMap[SigTSTP]="SIGTSTP";
00179   ourSigMap[SigTTIN]="SIGTTIN";
00180   ourSigMap[SigTTOU]="SIGTTOU";
00181   ourSigMap[SigURG]="SIGURG";
00182   ourSigMap[SigXCPU]="SIGXCPU";
00183   ourSigMap[SigXFSZ]="SIGXFSZ";
00184   ourSigMap[SigVTALRM]="SIGVTALRM";
00185   ourSigMap[SigPROF]="SIGPROF";
00186   ourSigMap[SigWINCH]="SIGWINCH";
00187   ourSigMap[SigIO]="SIGIO";
00188   ourSigMap[SigPWR]="SIGPWR";
00189 }
00190 
00191 const char * ArSignalHandler::nameSignal(int sig)
00192 {
00193   return(ourSigMap[sig].c_str());
00194 }
00195 
00196 void ArSignalHandler::logThread(void)
00197 {
00198   if (ourSignalHandler != NULL)
00199     ourSignalHandler->logThreadInfo();
00200   else
00201     ArLog::log(ArLog::Normal, "No signal handler thread running");
00202 }

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