home *** CD-ROM | disk | FTP | other *** search
/ PC Media 7 / PC MEDIA CD07.iso / share / prog / cm / cmobjref.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-09-06  |  1.8 KB  |  49 lines

  1. // CmObjRef.h
  2. // -----------------------------------------------------------------
  3. // Compendium - C++ Container Class Library
  4. // Copyright (C) 1992-1994, Glenn M. Poorman, All rights reserved
  5. // -----------------------------------------------------------------
  6. // Object reference definition used internally by the reserve.
  7. // -----------------------------------------------------------------
  8.  
  9. #ifndef _CMOBJREF_H
  10. #define _CMOBJREF_H
  11.  
  12. #include <cm/include/cmobject.h>
  13.  
  14. class CmObjectReference : public CmObject {     // Reference definition.
  15. public:
  16.   CmObjectReference(int);                       // Reference constructor.
  17.   CmObjectReference(CmObject*);                 // Reference constructor.
  18.   CmObjectReference(int, CmObject*);            // Reference constructor.
  19.  
  20.   int       key   () const;                     // Return key.
  21.   CmObject* object() const;                     // Return object ptr.
  22.  
  23.   CMOBJECT_DEFINE(CmObjectReference, CmObject)  // Define base functions.
  24.  
  25.   Bool     isEqual(CmObject*) const;            // Reference compare.
  26.   int      compare(CmObject*) const;            // Reference compare.
  27.   unsigned hash   (unsigned ) const;            // Hash reference.
  28.  
  29.   enum { KEYS=0, OBJECTS=1 };                   // Compare type values.
  30.  
  31.   static void compareBy(int);                   // Set compare policy.
  32.   static int  compareBy();                      // Get compare policy.
  33.  
  34. private:
  35.   int        _key;                              // Key value.
  36.   CmObject  *_object;                           // Object pointer.
  37.   static int _compareBy;                        // Compare policy.
  38. };
  39.  
  40. // "key" returns the key value.
  41. inline int CmObjectReference::key() const
  42. { return _key; }
  43.  
  44. // "object" returns the object pointer.
  45. inline CmObject* CmObjectReference::object() const
  46. { return _object; }
  47.  
  48. #endif
  49.