home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / msdos / pascal / rehack / contain / contain.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-06-02  |  2.1 KB  |  62 lines

  1. #ifndef __CONTAIN_H
  2. #define __CONTAIN_H
  3. // ╔════════════════════════════════════════════════╗
  4. // ║ contain.h, contain.cpp                         ║
  5. // ╟────────────────────────────────────────────────╢
  6. // ║ Basic container definitions                    ║
  7. // ╟────────────────────────────────────────────────╢
  8. // ║ Written by Gus Smedstad                        ║
  9. // ╟────────────────────────────────────────────────╢
  10. // ║ Copyright 1990-91 NoGate Consulting            ║
  11. // ╚════════════════════════════════════════════════╝
  12.  
  13. #ifndef __ALLOC_H
  14. #include <alloc.h>
  15. #endif
  16.  
  17. class containable {
  18. public:
  19.   static const int type;  // There is one copy of "type" per class.
  20.                           // NOT a member of each instance.
  21.   virtual     ~containable();
  22.   virtual int class_type() const = 0;
  23.   virtual int descends_from(int) const = 0;
  24.   virtual int operator == (const containable &) const = 0;
  25.           int operator != (const containable &arg) const
  26.               { return !(*this == arg); };
  27.  };
  28.  
  29. class sortable : public containable {
  30. public:
  31.   static const int  type;
  32.   virtual int       class_type() const = 0;
  33.   virtual int       descends_from(int) const = 0;
  34.   virtual int       operator == (const containable &) const = 0;
  35.   virtual int       operator > (const sortable &) const = 0;
  36.           int       operator <  (const sortable &arg) const
  37.                { return (arg > *this); };
  38.           int       operator >= (const sortable &arg) const
  39.                { return (*this > arg || *this == arg); };
  40.           int       operator <= (const sortable &arg) const
  41.                { return (*this < arg || *this == arg); };
  42.  };
  43.  
  44. class hashable : public containable {
  45. public:
  46.   static const int type;
  47.   virtual unsigned hash_value() const = 0;
  48.   virtual int      class_type() const = 0;
  49.   virtual int      descends_from(int) const = 0;
  50.   virtual int      operator == (const containable &) const = 0;
  51.  };
  52.  
  53. class container {
  54. protected:
  55.   unsigned object_count;
  56. public:
  57.   container();
  58.   virtual ~container();
  59.   unsigned count() { return object_count; };
  60.  };
  61.  
  62. #endif