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

  1. /*****************************************************************************
  2.  ***   $Source: /rcs/crcs/general/refpntr.hh,v $
  3.  ***   Checked int by: $Author: dan $
  4.  ***   $Date: 1996/07/14 05:05:25 $
  5.  ***   $Revision: 1.8 $
  6.  *****************************************************************************
  7.  ***                                       ***
  8.  ***          Copyright (c) 1994, Visual Edge Software Ltd.           ***
  9.  ***                                        ***
  10.  ***   All rights reserved.  This notice is  intended  as  a  precaution   ***
  11.  ***   against    inadvertent publication, and shall not be deemed to con-   ***
  12.  ***   stitute an acknowledgment that publication has  occurred     nor  to   ***
  13.  ***   imply  any  waiver  of confidentiality.    The year included in the   ***
  14.  ***   notice is the year of the creation of the work.               ***
  15.  ***                                        ***
  16.  *****************************************************************************/
  17.  
  18. #ifndef REFPNTR_HH
  19. #define REFPNTR_HH
  20.  
  21. #include <dllclass.hh>
  22. #include <refcnt.hh>
  23.  
  24. class VeBaseReference : public VeDllBasedClass
  25. {
  26.     public:
  27.  
  28.     VeBaseReference()
  29.     {
  30.         itsObject = 0;
  31.     }
  32.     
  33.     VeBaseReference(VeRefPrimary *obj)
  34.     {
  35.         itsObject = obj;
  36.         if(itsObject)
  37.             itsObject->Acquire();
  38.     }
  39.  
  40.     VeBaseReference(const VeBaseReference &ref)
  41.     {
  42.         itsObject = ref.itsObject;
  43.         if(itsObject)
  44.             itsObject->Acquire();
  45.     }
  46.  
  47.     ~VeBaseReference()
  48.     {
  49.         if(itsObject)
  50.             itsObject->Release();
  51.     }
  52.  
  53.     VeBaseReference& operator= (VeRefPrimary *obj)
  54.     {
  55.         if(obj)
  56.             obj->Acquire();
  57.  
  58.         if(itsObject)
  59.             itsObject->Release();
  60.  
  61.         itsObject = obj;
  62.  
  63.         return *this;
  64.     }
  65.  
  66.     VeBaseReference& operator= (const VeBaseReference ©)
  67.     {
  68.         if(copy.itsObject)
  69.             copy.itsObject->Acquire();
  70.  
  71.         if(itsObject)
  72.             itsObject->Release();
  73.  
  74.         itsObject = copy.itsObject;
  75.  
  76.         return *this;
  77.     }
  78.  
  79.     bool_t operator== (VeRefPrimary *obj)
  80.     {
  81.         return itsObject == obj;
  82.     }
  83.  
  84.     bool_t operator!= (VeRefPrimary *obj)
  85.     {
  86.         return itsObject != obj;
  87.     }
  88.  
  89.     operator VeRefPrimary *() const
  90.     {
  91.         return itsObject;
  92.     }
  93.  
  94.     VeRefPrimary* operator->()
  95.     {
  96.         return itsObject;
  97.     }
  98.  
  99.     bool_t IsValid() const 
  100.     {
  101.         if(itsObject)
  102.             return TRUE;
  103.         else
  104.             return FALSE;
  105.     }
  106.  
  107.     protected:
  108.  
  109.     VeRefPrimary    *itsObject;
  110. };
  111.  
  112. class VeBaseObjReference : public VeDllBasedClass
  113. {
  114.     public:
  115.  
  116.     VeBaseObjReference()
  117.     {
  118.         itsObject = 0;
  119.     }
  120.     
  121.     VeBaseObjReference(VeRefObject *obj)
  122.     {
  123.         itsObject = obj;
  124.         if(itsObject)
  125.             itsObject->Acquire();
  126.     }
  127.  
  128.     VeBaseObjReference(const VeBaseObjReference &ref)
  129.     {
  130.         itsObject = ref.itsObject;
  131.         if(itsObject)
  132.             itsObject->Acquire();
  133.     }
  134.  
  135.     ~VeBaseObjReference()
  136.     {
  137.         if(itsObject)
  138.             itsObject->Release();
  139.     }
  140.  
  141.     VeBaseObjReference& operator= (VeRefObject *obj)
  142.     {
  143.         if(obj)
  144.             obj->Acquire();
  145.  
  146.         if(itsObject)
  147.             itsObject->Release();
  148.  
  149.         itsObject = obj;
  150.  
  151.         return *this;
  152.     }
  153.  
  154.     VeBaseObjReference& operator= (const VeBaseObjReference ©)
  155.     {
  156.         if(copy.itsObject)
  157.             copy.itsObject->Acquire();
  158.  
  159.         if(itsObject)
  160.             itsObject->Release();
  161.  
  162.         itsObject = copy.itsObject;
  163.  
  164.         return *this;
  165.     }
  166.  
  167.     bool_t operator== (VeRefObject *obj)
  168.     {
  169.         return itsObject == obj;
  170.     }
  171.  
  172.     bool_t operator!= (VeRefObject *obj)
  173.     {
  174.         return itsObject != obj;
  175.     }
  176.  
  177.     operator VeRefObject *() const
  178.     {
  179.         return itsObject;
  180.     }
  181.  
  182.     VeRefObject* operator->()
  183.     {
  184.         return itsObject;
  185.     }
  186.  
  187.     bool_t IsValid() const 
  188.     {
  189.         if(itsObject)
  190.             return TRUE;
  191.         else
  192.             return FALSE;
  193.     }
  194.  
  195.     protected:
  196.  
  197.     VeRefObject    *itsObject;
  198. };
  199.  
  200. #endif // REFPNTR_HH
  201.