home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / Found / FWFoundU / Sources / FWRefCnt.cpp < prev   
Encoding:
Text File  |  1995-11-08  |  2.0 KB  |  75 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWRefCnt.cpp
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    (c) 1993, 1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWFound.hpp"
  11.  
  12. #ifndef FWREFCNT_H
  13. #include "FWRefCnt.h"
  14. #endif
  15.  
  16. #ifndef FWDEBUG_H
  17. #include "FWDebug.h"
  18. #endif
  19.  
  20. #if FW_LIB_EXPORT_PRAGMAS
  21. #pragma lib_export on
  22. #endif
  23.  
  24. //========================================================================================
  25. // RunTime Info
  26. //========================================================================================
  27.  
  28. FW_DEFINE_CLASS_M0(FW_MRefCount)
  29.  
  30. //========================================================================================
  31. //    class FW_MRefCount
  32. //========================================================================================
  33.  
  34. //----------------------------------------------------------------------------------------
  35. //    FW_MRefCount::FW_MRefCount
  36. //----------------------------------------------------------------------------------------
  37.  
  38. FW_MRefCount::FW_MRefCount() :
  39.     fRefCount(1)
  40. {
  41. }
  42.  
  43. //----------------------------------------------------------------------------------------
  44. //    FW_MRefCount::~FW_MRefCount
  45. //----------------------------------------------------------------------------------------
  46.  
  47. FW_MRefCount::~FW_MRefCount()
  48. {
  49. }
  50.  
  51. //----------------------------------------------------------------------------------------
  52. //    FW_MRefCount::Acquire
  53. //----------------------------------------------------------------------------------------
  54.  
  55. long FW_MRefCount::Acquire()
  56. {
  57.     return ++fRefCount;
  58. }
  59.  
  60. //----------------------------------------------------------------------------------------
  61. //    FW_MRefCount::Release
  62. //----------------------------------------------------------------------------------------
  63.  
  64. long FW_MRefCount::Release()
  65. {
  66.     FW_ASSERT(fRefCount > 0);
  67.     
  68.     long result = --fRefCount;
  69.     
  70.     if (result == 0)
  71.         delete this;
  72.     
  73.     return result;
  74. }
  75.