home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / yacl-012.zip / base / objptr.h < prev    next >
C/C++ Source or Header  |  1995-04-08  |  3KB  |  118 lines

  1.  
  2.  
  3. #ifndef _objptr_h_ /* Mon Aug  8 14:03:31 1994 */
  4. #define _objptr_h_
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12. /*
  13.  *
  14.  *          Copyright (C) 1994, M. A. Sridhar
  15.  *  
  16.  *
  17.  *     This software is Copyright M. A. Sridhar, 1994. You are free
  18.  *     to copy, modify or distribute this software  as you see fit,
  19.  *     and to use  it  for  any  purpose, provided   this copyright
  20.  *     notice and the following   disclaimer are included  with all
  21.  *     copies.
  22.  *
  23.  *                        DISCLAIMER
  24.  *
  25.  *     The author makes no warranties, either expressed or implied,
  26.  *     with respect  to  this  software, its  quality, performance,
  27.  *     merchantability, or fitness for any particular purpose. This
  28.  *     software is distributed  AS IS.  The  user of this  software
  29.  *     assumes all risks  as to its quality  and performance. In no
  30.  *     event shall the author be liable for any direct, indirect or
  31.  *     consequential damages, even if the  author has been  advised
  32.  *     as to the possibility of such damages.
  33.  *
  34.  */
  35.  
  36.  
  37.  
  38.  
  39.  
  40. // Template specializations for the type-specific "basic operations" on
  41. // the CL_VoidPtr type.
  42.  
  43.  
  44.  
  45.  
  46.  
  47. inline CL_ObjectPtr       CL_Basics<CL_ObjectPtr>::NullValue ()
  48. {
  49.     return 0;
  50. }
  51.  
  52.  
  53. inline short CL_Basics<CL_ObjectPtr>::Compare
  54.     (const CL_ObjectPtr& o1, const CL_ObjectPtr& o2)
  55. {
  56.     return (o1 == NULL || o2 == NULL || !o2->IsA (*o1)) ?
  57.           CL_Basics<long>::Compare ( (const long&) o1, (const long&) o2)
  58.         : (o1->Compare (*o2));
  59. }
  60.  
  61.  
  62.  
  63. inline CL_String  CL_Basics<CL_ObjectPtr>::PrintableForm
  64.     (const CL_ObjectPtr& o)
  65. {
  66.     CL_String s;
  67.     if (!o)
  68.         s = "0x0";
  69.     else {
  70.         s.AssignWithFormat ("%8lx", o);
  71.         s += " -> " + o->AsString ();
  72.     }
  73.     return s;
  74. }
  75.  
  76. inline long       CL_Basics<CL_ObjectPtr>::StoreWidth (const CL_ObjectPtr&)
  77. {
  78.     return sizeof (CL_ObjectPtr);
  79. }
  80.  
  81.  
  82. inline CL_ObjectPtr&      CL_Basics<CL_ObjectPtr>::Deref (CL_VoidPtr& b)
  83. {
  84.     return (CL_ObjectPtr&) b;
  85. }
  86.  
  87. inline void       CL_Basics<CL_ObjectPtr>::Destroy (CL_VoidPtr)
  88. {
  89.     // Do nothing
  90. }
  91.  
  92.  
  93. inline void       CL_Basics<CL_ObjectPtr>::ReallyDestroy 
  94.     (const CL_ObjectPtr& p)
  95. {
  96.     delete p;
  97. }
  98.  
  99.  
  100.  
  101.  
  102. inline CL_VoidPtr    CL_Basics<CL_ObjectPtr>::MakeCopy (const CL_ObjectPtr& o)
  103. {
  104.     register CL_VoidPtr p = (const CL_VoidPtr&) o;
  105.     return p;
  106. }
  107.  
  108. inline CL_VoidPtr    CL_Basics<CL_ObjectPtr>::MakePointer
  109.     (const CL_ObjectPtr& o)
  110. {
  111.     register CL_VoidPtr p = (const CL_VoidPtr&) o;
  112.     return p;
  113. }
  114.  
  115.  
  116.  
  117. #endif /* _objptr_h_ */
  118.