home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / IDIOMS.ZIP / ERECT.H < prev    next >
C/C++ Source or Header  |  1991-12-04  |  2KB  |  64 lines

  1. /* Copyright (c) 1992 by AT&T Bell Laboratories. */
  2. /* Advanced C++ Programming Styles and Idioms */
  3. /* James O. Coplien */
  4. /* All rights reserved. */
  5.  
  6. //************************************************************//
  7. //                                                            //
  8. //     F I L E :    E R E C T . H                             //
  9. //                                                            //
  10. //         Interface for class Rectangle                      //
  11. //                                                            //
  12. //************************************************************//
  13.  
  14. #define _RECTANGLE_H
  15. #ifndef _SHAPEREP_H
  16. #include "eshaprp.h"
  17. #endif
  18. #ifndef _COORDINATE_H
  19. #include "ecoord.h"
  20. #endif
  21.  
  22. // This defines the interface to the Rectangle abstraction
  23.  
  24. class Rectangle: public ShapeRep {
  25. public:
  26.     // exemplar constructors
  27.     Shape make();
  28.     Shape make(Coordinate, Coordinate);
  29.  
  30.     // default constructor
  31.     Rectangle();
  32.  
  33.     // Exemplar constructor
  34.     Rectangle(Exemplar);
  35.     void draw();
  36.  
  37.     // Things to do to Rectangles
  38.     void move(Coordinate);
  39.     void rotate(double);
  40.  
  41.     // memory management routines
  42.     void *operator new(size_t);
  43.     void operator delete(void *);
  44.     void gc(size_t = 0);
  45.     static void init();
  46. private:
  47.     // These should never be called on rectangles
  48.     Shape make(Coordinate, Coordinate, Coordinate) {
  49.         return *aShape;
  50.     }
  51.     Shape make(Coordinate) {
  52.         return *aShape;
  53.     }
  54.     Coordinate p1, p2;
  55. private:
  56.     // Memory management data structures
  57.     static char *heap;
  58.     static size_t poolInitialized;
  59.     enum { PoolSize = 5 };
  60. };
  61.  
  62. // Rectangle exemplar pointer declaration
  63. extern ShapeRep *rectangle;
  64.