home *** CD-ROM | disk | FTP | other *** search
- #ifndef __CONTAIN_H
- #define __CONTAIN_H
- // ╔════════════════════════════════════════════════╗
- // ║ contain.h, contain.cpp ║
- // ╟────────────────────────────────────────────────╢
- // ║ Basic container definitions ║
- // ╟────────────────────────────────────────────────╢
- // ║ Written by Gus Smedstad ║
- // ╟────────────────────────────────────────────────╢
- // ║ Copyright 1990-91 NoGate Consulting ║
- // ╚════════════════════════════════════════════════╝
-
- #ifndef __ALLOC_H
- #include <alloc.h>
- #endif
-
- class containable {
- public:
- static const int type; // There is one copy of "type" per class.
- // NOT a member of each instance.
- virtual ~containable();
- virtual int class_type() const = 0;
- virtual int descends_from(int) const = 0;
- virtual int operator == (const containable &) const = 0;
- int operator != (const containable &arg) const
- { return !(*this == arg); };
- };
-
- class sortable : public containable {
- public:
- static const int type;
- virtual int class_type() const = 0;
- virtual int descends_from(int) const = 0;
- virtual int operator == (const containable &) const = 0;
- virtual int operator > (const sortable &) const = 0;
- int operator < (const sortable &arg) const
- { return (arg > *this); };
- int operator >= (const sortable &arg) const
- { return (*this > arg || *this == arg); };
- int operator <= (const sortable &arg) const
- { return (*this < arg || *this == arg); };
- };
-
- class hashable : public containable {
- public:
- static const int type;
- virtual unsigned hash_value() const = 0;
- virtual int class_type() const = 0;
- virtual int descends_from(int) const = 0;
- virtual int operator == (const containable &) const = 0;
- };
-
- class container {
- protected:
- unsigned object_count;
- public:
- container();
- virtual ~container();
- unsigned count() { return object_count; };
- };
-
- #endif