home *** CD-ROM | disk | FTP | other *** search
/ Dream 57 / Amiga_Dream_57.iso / Amiga / Programmation / c / Extensions / APPSource.lha / APlusPlus / libsource / MessageC.cxx < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-29  |  1.6 KB  |  76 lines

  1. /******************************************************************************
  2.  **
  3.  **   C++ Class Library for the Amiga⌐ system software.
  4.  **
  5.  **   Copyright (C) 1994 by Armin Vogt  **  EMail: armin@uni-paderborn.de
  6.  **   All Rights Reserved.
  7.  **
  8.  **   $Source: apphome:RCS/libsource/MessageC.cxx,v $
  9.  **   $Revision: 1.7 $
  10.  **   $Date: 1994/07/27 11:51:09 $
  11.  **   $Author: Armin_Vogt $
  12.  **
  13.  ******************************************************************************/
  14.  
  15.  
  16. #include <string.h>
  17. #include <APlusPlus/exec/List.h>
  18. #include <APlusPlus/exec/MessageC.h>
  19.  
  20.  
  21. static const char rcs_id[] = "$Id: MessageC.cxx,v 1.7 1994/07/27 11:51:09 Armin_Vogt Exp Armin_Vogt $";
  22.  
  23.  
  24. MessageC::MessageC()
  25. {
  26.    memset(this,0,sizeof(*this));
  27.    signRemoved(); mn_Node.ln_Type = NT_FREEMSG;
  28. }
  29.  
  30. MessageC::~MessageC()
  31. {
  32.    mn_Node.ln_Type = NT_DEATHMESSAGE;
  33. }
  34.  
  35. void MessageC::signRemoved()
  36. {
  37.    mn_Node.ln_Succ = mn_Node.ln_Pred = (struct Node*)(struct Message*)this;
  38. }
  39.  
  40. BOOL MessageC::isRemoved()
  41. {
  42.    return ((NodeC*)this)->isLonelyNode();
  43. }
  44.  
  45. MsgState MessageC::getMsgState()
  46. {
  47.    switch (mn_Node.ln_Type)
  48.    {
  49.       case NT_MESSAGE :
  50.  
  51.          if (isRemoved()) return MSG_IN_PROCESS; else return MSG_SENT;
  52.          break;
  53.  
  54.       case NT_REPLYMSG :
  55.  
  56.          if (isRemoved()) return MSG_FREE; else return MSG_REPLIED;
  57.          break;
  58.    }
  59.    return MSG_FREE;
  60. }
  61.  
  62. void MessageC::setReplyPort(struct MsgPort *port)
  63. {
  64.    if (getMsgState()&MSG_FREE) mn_ReplyPort = port;
  65. }
  66.  
  67. BOOL MessageC::replyMsg()
  68. {
  69.    if (getMsgState()&MSG_SENT)
  70.    {
  71.       ReplyMsg(this);
  72.       return TRUE;
  73.    }
  74.    else return FALSE;
  75. }
  76.