home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / borhead.zip / REF.H < prev    next >
C/C++ Source or Header  |  1994-11-09  |  2KB  |  91 lines

  1. /*------------------------------------------------------------------------*/
  2. /*                                                                        */
  3. /*  REF.H                                                                 */
  4. /*                                                                        */
  5. /*------------------------------------------------------------------------*/
  6.  
  7. /*
  8.  *      C/C++ Run Time Library - Version 1.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. #endif
  37.  
  38. #pragma option -Vo-
  39.  
  40. #if defined(__STDC__)
  41. #pragma warn -nak
  42. #endif
  43.  
  44. #endif  /* !RC_INVOKED */
  45.  
  46.  
  47. /*------------------------------------------------------------------------*/
  48. /*                                                                        */
  49. /*  class TReference                                                      */
  50. /*                                                                        */
  51. /*  Base class for reference counting                                     */
  52. /*                                                                        */
  53. /*------------------------------------------------------------------------*/
  54.  
  55. class _EXPCLASS TReference
  56. {
  57.  
  58. public:
  59.  
  60.     _RTLENTRY TReference(unsigned short initRef = 0) : Refs(initRef) { }
  61.     void _RTLENTRY AddReference() { Refs++; }
  62.     unsigned short _RTLENTRY References() { return Refs; }
  63.     unsigned short _RTLENTRY RemoveReference() { return --Refs; }
  64.  
  65. private:
  66.  
  67.     unsigned short Refs;    // Number of references to this block
  68.  
  69. };
  70.  
  71. #if defined( BI_OLDNAMES )
  72. #define BI_Reference TReference
  73. #endif
  74.  
  75.  
  76. #if !defined(RC_INVOKED)
  77.  
  78. #if defined(__STDC__)
  79. #pragma warn .nak
  80. #endif
  81.  
  82. #if defined(__BCOPT__)
  83. #endif
  84.  
  85. #pragma option -Vo.
  86.  
  87. #endif  /* !RC_INVOKED */
  88.  
  89.  
  90. #endif  // __REF_H
  91.