home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / borland / cb / setup / cbuilder / data.z / REF.H < prev    next >
C/C++ Source or Header  |  1997-02-28  |  2KB  |  98 lines

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