home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 5 / FreshFish_July-August1994.bin / bbs / gnu / aplusplus-1.01-src.lha / src / amiga / aplusplus-1.01 / include / aplusplus / exec / SignalResponder.h < prev    next >
C/C++ Source or Header  |  1994-05-04  |  2KB  |  58 lines

  1. #ifndef APP_SignalResponder_H
  2. #define APP_SignalResponder_H
  3. /******************************************************************************
  4.  **
  5.  **    C++ Class Library for the Amiga© system software.
  6.  **
  7.  **    Copyright (C) 1994 by Armin Vogt  **  EMail: armin@uni-paderborn.de
  8.  **    All Rights Reserved.
  9.  **
  10.  **    $VER: apphome:APlusPlus/exec/SignalResponder.h 1.04 (04.05.94) $
  11.  **    
  12.  ******************************************************************************/
  13.  
  14.  
  15. #include <APlusPlus/exec/PriorityList.h>
  16. #include <APlusPlus/environment/APPObject.h>
  17.  
  18.  
  19. /******************************************************************************************
  20.       » SignalResponder class «  virtual base class
  21.  
  22.    Each SignalResponder object is chained into a list of SignalResponder objects
  23.    and waits for its individual signal bit to be set. The virtual method actionCallback()
  24.    is called on the event of that signal being set.
  25.  ******************************************************************************************/
  26.  
  27. class SignalResponder : private PriorityNode, public APPObject
  28. {
  29.    private:
  30.         static ULONG waitSignalSet;            // signal mask for Wait()
  31.       static PriorityList sigRespChain;    // connects all SignalResponder objects
  32.         
  33.         ULONG waitSignal; 
  34.         BOOL hasAllocatedSig;                    // TRUE if 'this' has allocated a new signal
  35.       UBYTE waitSigNr;                            // bit number of the signal 'this' catches
  36.  
  37.       void initSR(BYTE signal_nr,BYTE pri);
  38.  
  39.       BOOL applyNodeC(APTR any);   // listnode apply inherited from NodeC
  40.  
  41.    public:
  42.       // set a SRSP to an already allocated signal.
  43.       SignalResponder(UBYTE signal_nr,BYTE pri) { initSR(signal_nr, pri); }
  44.       // allocate a signal for this SRSP.
  45.       SignalResponder(BYTE pri);
  46.       ~SignalResponder();      // must be virtual for inheritance
  47.  
  48.       static void WaitSignal();
  49.  
  50.       virtual void actionCallback() = 0;     // overload this with your own action
  51.  
  52.       void changeSignalBit(UBYTE signal_nr);
  53. };
  54.  
  55.  
  56. #define SIGNALRESPONDER_ALLOCSIGNAL_FAILED (SIGRESPONDER_CLASS+1)
  57. #endif
  58.