home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1996 November / VPR9611B.ISO / vabasic / ntclnt.exe / DISK8 / data.8 / datab / INCLUDE / REFCNT.HH < prev    next >
Text File  |  1996-07-29  |  2KB  |  88 lines

  1. //-----------------------------------------------------------------------------
  2. // $Source: /rcs/crcs/general/refcnt.hh,v $
  3. // Checked in by $Author: alaind $
  4. // $Date: 1996/04/17 17:53:11 $                   $Revision: 1.5 $
  5. //-----------------------------------------------------------------------------
  6. //             Copyright (c) 1994, Visual Edge Software Ltd.
  7. //
  8. // ALL RIGHTS RESERVED.  This notice is intended as a precaution against
  9. // inadvertent publication, and shall not be deemed to constitute an
  10. // acknowledgment that publication has occurred nor to imply any waiver of
  11. // confidentiality.  The year included in the notice is the year of the
  12. // creation of the work.
  13. //-----------------------------------------------------------------------------
  14. // DESCRIPTION:
  15. //    This class provides reference counting support for VePrimary objects.
  16. //-----------------------------------------------------------------------------
  17.  
  18. #ifndef REFCNT_HH
  19. #define REFCNT_HH
  20.  
  21. #include <visedge.hh>
  22. #include <object.hh>
  23.  
  24. typedef long        VTRefCount;
  25.  
  26. class VeRefPrimary : public VePrimary
  27. {
  28.     public:
  29.  
  30.     VOPERDECL VeRefPrimary();
  31.  
  32.     VTRefCount Acquire()
  33.     {
  34.         ++itsRefCount;
  35.         return itsRefCount.Value();
  36.     }
  37.  
  38.     VTRefCount Release()
  39.     {
  40.         if(!itsRefCount.IsReferenced() ||
  41.            (--itsRefCount == FALSE))
  42.             return RefTransition();
  43.         else
  44.             return itsRefCount.Value();
  45.     }
  46.  
  47.     protected:
  48.  
  49.     virtual VOPERDECL ~VeRefPrimary();
  50.  
  51.     VVIRTUALDECL(VTRefCount)    RefTransition();
  52.  
  53.     VeRefCount    itsRefCount;
  54. };
  55.  
  56. class VeRefObject : public VeObject
  57. {
  58.     public:
  59.     RTTI_H(VeClass, VeObject);
  60.  
  61.     VOPERDECL VeRefObject();
  62.  
  63.     VTRefCount Acquire()
  64.     {
  65.         ++itsRefCount;
  66.         return itsRefCount.Value();
  67.     }
  68.  
  69.     VTRefCount Release()
  70.     {
  71.         if(!itsRefCount.IsReferenced() ||
  72.            (--itsRefCount == FALSE))
  73.             return RefTransition();
  74.         else
  75.             return itsRefCount.Value();
  76.     }
  77.  
  78.     protected:
  79.  
  80.     virtual VOPERDECL ~VeRefObject();
  81.  
  82.     VVIRTUALDECL(VTRefCount)    RefTransition();
  83.  
  84.     VeRefCount    itsRefCount;
  85. };
  86.  
  87. #endif // REFCNT_HH
  88.