Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8228 in orxonox.OLD for trunk/src/util


Ignore:
Timestamp:
Jun 8, 2006, 11:19:08 AM (19 years ago)
Author:
patrick
Message:

trunk: merged the network branche back to trunk with command: svn merge branches/network trunk -r8150:HEAD

Location:
trunk/src/util
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/util/signal_handler.cc

    r8068 r8228  
    1717#include <assert.h>
    1818
     19SignalHandler * SignalHandler::singletonRef = NULL;
     20
    1921#ifndef __WIN32__
    20 
    21 SignalHandler * SignalHandler::singletonRef = NULL;
    2222
    2323SignalHandler::SignalHandler()
     
    5959void SignalHandler::sigHandler( int sig )
    6060{
     61  for ( SignalCallbackList::iterator it = SignalHandler::getInstance()->callbackList.begin(); it != SignalHandler::getInstance()->callbackList.end(); it++  )
     62  {
     63    (*(it->cb))( it->someData );
     64  }
     65 
    6166  std::string sigName = "UNKNOWN";
    6267
     
    113118}
    114119
     120void SignalHandler::registerCallback( SignalCallback cb, void * someData )
     121{
     122  SignalCallbackRec rec;
     123  rec.cb = cb;
     124  rec.someData = someData;
     125 
     126  callbackList.push_back(rec);
     127}
     128
    115129#endif /* __WIN32__ */
  • trunk/src/util/signal_handler.h

    r7440 r8228  
    1717};
    1818
     19typedef bool (*SignalCallback)( void * someData );
    1920
    2021#ifndef __WIN32__
     
    2728};
    2829
     30struct SignalCallbackRec
     31{
     32  SignalCallback cb;
     33  void * someData;
     34};
     35
    2936
    3037typedef std::list<SignalRec> SignalRecList;
     38typedef std::list<SignalCallbackRec> SignalCallbackList;
    3139
    3240class SignalHandler
     
    3543    SignalHandler();
    3644  public:
    37     inline static SignalHandler* getInstance() { if (!SignalHandler::singletonRef) SignalHandler::singletonRef = new SignalHandler();
    38       return SignalHandler::singletonRef; }
     45    inline static SignalHandler* getInstance() { if (!SignalHandler::singletonRef) SignalHandler::singletonRef = new SignalHandler(); return SignalHandler::singletonRef; }
     46     
     47    void registerCallback( SignalCallback cb, void * someData );
    3948
    4049    void doCatch( std::string appName, GdbRunType type = GDB_RUN_WRITE_TO_FILE );
     
    4655    void catchSignal( int sig );
    4756    SignalRecList sigRecList;
     57   
     58    SignalCallbackList callbackList;
    4859
    4960    static SignalHandler * singletonRef;
     
    5869{
    5970 public:
    60   inline static SignalHandler* getInstance() {};
     71   inline static SignalHandler* getInstance() { if (!SignalHandler::singletonRef) SignalHandler::singletonRef = new SignalHandler(); return SignalHandler::singletonRef; };
    6172  void doCatch( std::string appName, GdbRunType type = GDB_RUN_WRITE_TO_FILE ) {};
    6273  void dontCatch() {};
     74  void registerCallback( SignalCallback cb, void * someData ) {};
    6375};
    6476#endif
Note: See TracChangeset for help on using the changeset viewer.