home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 9 / CDACTUAL9.iso / progs / CB / DATA.Z / REF.H < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-18  |  2.2 KB  |  92 lines

  1. /*------------------------------------------------------------------------*/
  2. /*                                                                        */
  3. /*  REF.H                                                                 */
  4. /*                                                                        */
  5. /*------------------------------------------------------------------------*/
  6.  
  7. /* $Copyright: 1987$ */
  8. /* $Revision:   8.1  $ */
  9.  
  10. #ifndef __cplusplus
  11. #error Must use C++ for REF.H
  12. #endif
  13.  
  14. #ifndef __REF_H
  15. #define __REF_H
  16.  
  17. /*
  18.  *
  19.  * Base class for reference counting
  20.  *
  21.  */
  22.  
  23. #if !defined(___DEFS_H)
  24. #include <_defs.h>
  25. #endif
  26.  
  27.  
  28. #if !defined(RC_INVOKED)
  29.  
  30. #if defined(__BCOPT__)
  31. #if !defined(_RTL_ALLOW_po) && !defined(__FLAT__)
  32. #pragma option -po-     // disable Object data calling convention
  33. #endif
  34. #endif
  35.  
  36. #pragma option -Vo-
  37.  
  38. #if defined(__STDC__)
  39. #pragma warn -nak
  40. #endif
  41.  
  42. #endif  /* !RC_INVOKED */
  43.  
  44.  
  45. /*------------------------------------------------------------------------*/
  46. /*                                                                        */
  47. /*  class TReference                                                      */
  48. /*                                                                        */
  49. /*  Base class for reference counting                                     */
  50. /*                                                                        */
  51. /*------------------------------------------------------------------------*/
  52.  
  53. class _EXPCLASS TReference
  54. {
  55.  
  56. public:
  57.  
  58.     _RTLENTRY TReference(unsigned short initRef = 0) : Refs(initRef) { }
  59.     void _RTLENTRY AddReference() { Refs++; }
  60.     unsigned short _RTLENTRY References() { return Refs; }
  61.     unsigned short _RTLENTRY RemoveReference() { return --Refs; }
  62.  
  63. private:
  64.  
  65.     unsigned short Refs;    // Number of references to this block
  66.  
  67. };
  68.  
  69. #if defined( BI_OLDNAMES )
  70. #define BI_Reference TReference
  71. #endif
  72.  
  73.  
  74. #if !defined(RC_INVOKED)
  75.  
  76. #if defined(__STDC__)
  77. #pragma warn .nak
  78. #endif
  79.  
  80. #if defined(__BCOPT__)
  81. #if !defined(_RTL_ALLOW_po) && !defined(__FLAT__)
  82. #pragma option -po.     // restore Object data calling convention
  83. #endif
  84. #endif
  85.  
  86. #pragma option -Vo.
  87.  
  88. #endif  /* !RC_INVOKED */
  89.  
  90.  
  91. #endif  // __REF_H
  92.