home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / VSCPPv8.zip / VACPP / IBMCPP / samples / IOC / GRAPH / GRAPH.H < prev    next >
Text File  |  1995-03-15  |  2KB  |  79 lines

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