home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / samples / ioc / graph / graph.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  2.8 KB  |  84 lines

  1. /**********************************************************************
  2. *                                                                     *
  3. *  IBM(R) VisualAge(TM) for C++ for Windows(R), Version 3.5           *
  4. *                                                                     *
  5. *  PID: 5622-880                                                      *
  6. *  - Licensed Material - Program-Property of IBM                      *
  7. *  (C) Copyright IBM Corp. 1991, 1995 - All Right Reserved.           *
  8. *                                                                     *
  9. *  US Government Users Restricted Rights - Use, duplication or        *
  10. *  disclosure restricted by GSA ADP Schedule Contract with IBM Corp.  *
  11. *                                                                     *
  12. *  VisualAge, and IBM are trademarks or registered trademarks of      *
  13. *  International Business Machines Corporation.                       *
  14. *  Windows is a registered trademark of Microsoft Corporation.        *
  15. *                                                                     *
  16. **********************************************************************/
  17.  
  18. #include <istring.hpp>
  19. #include <iostream.h>
  20.  
  21.  
  22. class Graphics
  23. {
  24.  
  25. protected:
  26.  
  27.  
  28.   IString ivId;    //*** graphics ID ****/
  29.   int     ivKey;   //*** graphics key ****/
  30.  
  31. public:
  32.  
  33.  
  34.   Graphics (int graphicsKey, IString id) : ivKey(graphicsKey),
  35.                                            ivId(id)
  36.                                            { }
  37.  
  38.  
  39.   ~Graphics()
  40.     {
  41.      cout << this->ivId
  42.            << " will now be deleted ... "
  43.           << endl;
  44.     }
  45.  
  46.  
  47.   IBoolean operator== (Graphics const& graphics) const
  48.     {
  49.      return (this->ivId == graphics.ivId);
  50.     }
  51.  
  52.  
  53.   IString const& id() const
  54.     {
  55.      return ivId;
  56.     }
  57.  
  58.  
  59.   virtual        void           draw() const =0;
  60.  
  61.   /**** This member function returns the graphic's key ****/
  62.   /*    Note that we are returning the int by reference,  */
  63.   /*    because this member function will be used by the  */
  64.   /*    key(...) function, which must return a reference. */
  65.   /********************************************************/
  66.   int const& graphicsKey() const
  67.     {
  68.      return ivKey;
  69.     }
  70.  
  71. };
  72.  
  73. /****************       key function       *********************/
  74. /****   note that this interface must always be used with:  ****/
  75. /****              Keytype const& key(....)                 ****/
  76. /****                                                       ****/
  77. /****   We are providing this key function for the element  ****/
  78. /****   type Graphics  and not for the managed pointer.     ****/
  79. /***************************************************************/
  80.   inline int const& key (Graphics const& graphics)
  81.     {
  82.      return graphics.graphicsKey();
  83.     }
  84.