home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / Borland / Cplus45 / BC45 / INC.PAK / REF.H < prev    next >
C/C++ Source or Header  |  1995-08-29  |  2KB  |  97 lines

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