home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Internet 2000 May / MICD_2000_05.iso / CBuilder5 / INSTALL / DATA1.CAB / Program_Built_Files / Include / ref.h < prev    next >
C/C++ Source or Header  |  2000-02-01  |  2KB  |  80 lines

  1. /*------------------------------------------------------------------------*/
  2. /*                                                                        */
  3. /*  REF.H                                                                 */
  4. /*                                                                        */
  5. /*------------------------------------------------------------------------*/
  6.  
  7. /*
  8.  *      C/C++ Run Time Library - Version 10.0
  9.  *
  10.  *      Copyright (c) 1987, 2000 by Inprise Corporation
  11.  *      All Rights Reserved.
  12.  *
  13.  */
  14.  
  15. /* $Revision:   9.1  $ */
  16.  
  17. #ifndef __cplusplus
  18. #error Must use C++ for REF.H
  19. #endif
  20.  
  21. #ifndef __REF_H
  22. #define __REF_H
  23.  
  24. /*
  25.  *
  26.  * Base class for reference counting
  27.  *
  28.  */
  29.  
  30. #if !defined(___DEFS_H)
  31. #include <_defs.h>
  32. #endif
  33.  
  34. #if !defined(RC_INVOKED)
  35.  
  36. #if defined(__STDC__)
  37. #pragma warn -nak
  38. #endif
  39.  
  40. #endif  /* !RC_INVOKED */
  41.  
  42.  
  43. /*------------------------------------------------------------------------*/
  44. /*                                                                        */
  45. /*  class TReference                                                      */
  46. /*                                                                        */
  47. /*  Base class for reference counting                                     */
  48. /*                                                                        */
  49. /*------------------------------------------------------------------------*/
  50.  
  51. class _EXPCLASS TReference
  52. {
  53.  
  54. public:
  55.  
  56.     _RTLENTRY TReference(unsigned short initRef = 0) : Refs(initRef) { }
  57.     void _RTLENTRY AddReference() { Refs++; }
  58.     unsigned short _RTLENTRY References() { return Refs; }
  59.     unsigned short _RTLENTRY RemoveReference() { return --Refs; }
  60.  
  61. private:
  62.  
  63.     unsigned short Refs;    // Number of references to this block
  64.  
  65. };
  66.  
  67. #if defined( BI_OLDNAMES )
  68. #define BI_Reference TReference
  69. #endif
  70.  
  71. #if !defined(RC_INVOKED)
  72.  
  73. #if defined(__STDC__)
  74. #pragma warn .nak
  75. #endif
  76.  
  77. #endif  /* !RC_INVOKED */
  78.  
  79. #endif  // __REF_H
  80.