home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c083 / 14.ddi / GENINC.PAK / REF.H < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-02  |  2.0 KB  |  71 lines

  1. /*------------------------------------------------------------------------*/
  2. /*                                                                        */
  3. /*  REF.H                                                                 */
  4. /*                                                                        */
  5. /*------------------------------------------------------------------------*/
  6.  
  7. /*
  8.  *      C/C++ Run Time Library - Version 6.0
  9.  *
  10.  *      Copyright (c) 1987, 1993 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. #pragma option -Vo-
  33. #if     defined(__BCOPT__) && !defined(_RTL_ALLOW_po) && !defined(__FLAT__)
  34. #pragma option -po-
  35. #endif
  36.  
  37. /*------------------------------------------------------------------------*/
  38. /*                                                                        */
  39. /*  class TReference                                                      */
  40. /*                                                                        */
  41. /*  Base class for reference counting                                     */
  42. /*                                                                        */
  43. /*------------------------------------------------------------------------*/
  44.  
  45. class _EXPCLASS TReference
  46. {
  47.  
  48. public:
  49.  
  50.     _RTLENTRY TReference(unsigned short initRef = 0) : Refs(initRef) { }
  51.     void _RTLENTRY AddReference() { Refs++; }
  52.     unsigned short _RTLENTRY References() { return Refs; }
  53.     unsigned short _RTLENTRY RemoveReference() { return --Refs; }
  54.  
  55. private:
  56.  
  57.     unsigned short Refs;    // Number of references to this block
  58.  
  59. };
  60.  
  61. #if defined( BI_OLDNAMES )
  62. #define BI_Reference TReference
  63. #endif
  64.  
  65. #pragma option -Vo.
  66. #if     defined(__BCOPT__) && !defined(_ALLOW_po) && !defined(__FLAT__)
  67. #pragma option -po.
  68. #endif
  69.  
  70. #endif  // __REF_H
  71.