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 / MessageC.h < prev    next >
C/C++ Source or Header  |  1994-05-04  |  3KB  |  72 lines

  1. #ifndef APP_MessageC_H
  2. #define APP_MessageC_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/MessageC.h 1.04 (04.05.94) $
  11.  **    
  12.  ******************************************************************************/
  13.  
  14.  
  15. extern "C"
  16. {
  17. #include <exec/ports.h>
  18. }
  19.  
  20. #include <APlusPlus/exec/List.h>
  21.  
  22.  
  23. /******************************************************************************************
  24.       » MessageC class «
  25.  
  26.    enhances the EXEC Message structure with some useful methods.
  27.    Most times another EXEC structure that incorporates a 'struct Message' is interpreted 
  28.     as a MessageC object in casting it to MessageC. Therefore additional class members must 
  29.     not obtain memory since these will not be initialised when only a cast interpretes an 
  30.      'struct Message' incorporating EXEC structure.
  31.  
  32.  ******************************************************************************************/
  33. enum MsgState  // message state returned by 'getMsgState()'
  34. {
  35.     MSG_FREE=1,         // message at your disposal
  36.    MSG_SENT=2,         // message is in the destination msgport queue (NT_MESSAGE)
  37.    MSG_IN_PROCESS=6,   // message is removed from the destination msgport queue (NT_MESSAGE). Note below.
  38.    MSG_REPLIED=9       // message is in the sender msgport queue or already removed from (NT_REPLYMSG)
  39. };
  40. // Note that MSG_IN_PROCESS can only be recognized for messages sent between APP MsgPort objects!
  41. // A MSG_IN_PROCESS is also a MSG_SENT, as is a MSG_REPLIED also a MSG_FREE 
  42. // (==> getMsgState()&MSG_SENT == TRUE also for MSG_IN_PROCESS and 
  43. //      getMsgState()&MSG_FREE == TRUE also for MSG_REPLIED, but getMsgState()!=MSG_FREE
  44.  
  45.  
  46. class TimedMsgPort;
  47. class MessageC : public Message
  48. {
  49.     friend TimedMsgPort;
  50.     protected:
  51.       BOOL isRemoved();
  52.       // states wether the msg is in a port msg queue or not. Do not use this, instead use getMsgState()
  53.  
  54.       void signRemoved();
  55.       // afterwards 'isRemoved()' returns TRUE. Apply only after GetMsg().
  56.  
  57.    public:
  58.       MessageC();        // initialise the message to state MSG_FREE
  59.       ~MessageC();    // removes a queued message. Only delete MSG_FREE messages!
  60.         
  61.       MsgState getMsgState();    // determine the state of the message (see above).
  62.         
  63.         struct MsgPort *getReplyPort() { return mn_ReplyPort; }
  64.         void setReplyPort(struct MsgPort *port) { if (getMsgState()&MSG_FREE) mn_ReplyPort = port; }
  65.             
  66.         BOOL replyMsg();    // returns TRUE if reply was allowed i.e. message was no reply msg. at all
  67.         
  68.       operator struct Message* () { return (struct Message*)this; }
  69. };
  70.  
  71. #endif
  72.