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 / intuition / ITransponder.h < prev    next >
C/C++ Source or Header  |  1994-05-09  |  3KB  |  85 lines

  1. #ifndef ITransponder_H
  2. #define ITransponder_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/intuition/ITransponder.h 1.04 (04.05.94) $
  11.  **    
  12.  ******************************************************************************/
  13.  
  14. #include <APlusPlus/environment/APPObject.h>
  15. #include <APlusPlus/utility/AttrList.h>
  16.  
  17.  
  18. /******************************************************************************************
  19.          » ITransponder class «  virtual base class
  20.  
  21.    interposes between two (or even more) IntuiObjects exchanging messages about their
  22.    state represented by their attribute tags. In fact there is exactly one IntuiObject
  23.    which sends messages about its tags changed and one IntuiObject receiving these
  24.    notifications.
  25.    This class provides you with the ability to filter and work on these messages as you
  26.    like. This is achieved through the sender method being virtual.
  27.  
  28.    The IntuiObject you have your ITransponder attached to now calls 'sendNotification'
  29.    on each change of one of its attributes with the list of these class specific attribute
  30.    tags that have changed.
  31.    There you may map attributes to class specific attributes of the receiving IntuiObject,
  32.    or you may spread notifications to several other IntuiObjects.
  33.  
  34.    The reason why 'sendNotification' has not been implemented as virtual method to the
  35.    IntuiObject itself is that a seperate object avoides the need of deriving the IntuiObject
  36.    itself, and one ITransponder can interpose between several IntuiObjects.
  37.  
  38.  ******************************************************************************************/
  39. class IntuiObject;
  40. class ITransponder
  41. {
  42.    friend IntuiObject;  // needs access to sendNotification()
  43.    protected:           // you must derive for overloading sendNotification()
  44.       IntuiObject *receiver1;    // IntuiObject which will be noticed on each 'sendNotification'
  45.       ITransponder(IntuiObject *iob=NULL) { receiver1 = iob; }
  46.  
  47.       virtual void sendNotification(AttrList& )=0;  // notify
  48.  
  49.     public:
  50.       // set the IntuiObject that is to receive notifications
  51.       void setReceiver(IntuiObject *newReceiver);// { receiver1 = newReceiver; }
  52.      
  53.         static ITransponder *confirm(ITransponder *itp) { return itp; } 
  54. };
  55.  
  56. class MapITP : public ITransponder
  57. {
  58.    private:
  59.        AttrList mapAttrlist;
  60.       void sendNotification(AttrList& );
  61.       
  62.    public:
  63.       MapITP(IntuiObject *receiver,AttrList&);
  64.       virtual ~MapITP() {}
  65. };
  66.  
  67. /******************************************************************************************
  68.    example of a specialized ITransponder:
  69.  
  70.    class Prop2Canvas : public ITransponder
  71.    {
  72.       public:
  73.          virtual void sendNotification(TAGLIST)
  74.          {
  75.             mapTags( taglist,
  76.                      PGA_Top  , CV_HorizTop,
  77.                      PGA_Total, CV_HorzTotal,
  78.                      TAG_END
  79.                   );
  80.             if (receiver1) receiver1->setAttributes(taglist);
  81.          }
  82.    };
  83.  ******************************************************************************************/
  84. #endif
  85.