home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C ++ / Frameworks / MacZoop 1.6.5 / Basic Classes / Z Headers / ZComrade.h < prev    next >
Encoding:
Text File  |  1997-03-10  |  2.3 KB  |  82 lines  |  [TEXT/CWIE]

  1. /*************************************************************************************************
  2. *
  3. *
  4. *            ObjectMacZapp    -- a standard Mac OOP application template
  5. *
  6. *
  7. *
  8. *            ZComrade.h        -- an object that can maintain loose links between objects
  9. *
  10. *
  11. *
  12. *
  13. *
  14. *            © 1996, Graham Cox
  15. *
  16. *
  17. *
  18. *
  19. *************************************************************************************************/
  20.  
  21. #undef OLDROUTINENAMES
  22.  
  23. #pragma once
  24.  
  25. #ifndef __ZCOMRADE__
  26. #define __ZCOMRADE__
  27.  
  28. class    ZComrade;
  29. class    ZMessage;
  30. class    ZComradeList;
  31.  
  32.  
  33.  
  34. class ZComrade
  35. {
  36.     private:
  37.         ZComradeList*        talkers;
  38.         ZComradeList*        listeners;
  39.         
  40.     public:
  41.         ZComrade();
  42.         virtual ~ZComrade();
  43.         
  44.         virtual void    SendMessage( long aMessage, void* msgData );
  45.         virtual void    SendMessage( ZMessage* aMessage );
  46.         virtual void    ReceiveMessage( ZComrade* aSender, long theMessage, void* msgData );
  47.         virtual void    ReceiveMessage( ZComrade* aSender, ZMessage* aMessage );
  48.         virtual void    ListenTo( ZComrade* aSender );
  49.         virtual void    StopListeningTo( ZComrade* aSender );
  50.         
  51.     protected:
  52.     
  53.         virtual void    AddTalker( ZComrade* aTalker );
  54.         virtual void    AddListener( ZComrade* aListener );
  55.         virtual void    RemoveTalker( ZComrade* aTalker );
  56.         virtual void    RemoveListener( ZComrade* aListener );
  57. };
  58.  
  59. /*
  60.  
  61. What are comrades for? If you are familiar with TCL or another framework, this is like a
  62. collaborator. It allows objects to communicate through a standard interface (the comrade
  63. interface) without the objects needing to know explicitly what the various talkers and
  64. listeners actually are- in other words, it is a loose binding between objects.
  65.  
  66. Comrades are very useful- for example if you want two windows to represent some common data,
  67. you can make both windows become listeners of the data object. The data transmits a message
  68. when it changes, and both windows can update their views accordingly. Thus problems with
  69. keeping duplicates of the data disappear.
  70.  
  71. In MacZoop, many objects are subclassed from ZComrade- all Commanders, windows, arrays, etc
  72. are comrades. Use the "Show Hierarchy Window" command in CodeWarrior to see how everything
  73. fits together. Neat, huh?
  74.  
  75. Note:- ZMessage is currently not actually declared anywhere, thus leaving it up to the
  76. user/programmer of MacZoop to implement whatever is needed. This may change in the future.
  77.  
  78. */
  79.  
  80.  
  81.  
  82. #endif