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

  1. //------------------------------------------------------------------------
  2. // $Source: /rcs/crcs/general/vobjref.hh,v $
  3. // Checked in by: $Author: alaind $
  4. // $Date: 1996/04/17 17:52:34 $             $Revision: 1.3 $
  5. //------------------------------------------------------------------------
  6. //       Copyright(c) 1993, Visual Edge Software Ltd.
  7. //
  8. // ALL RIGHTS RESERVED. This notice is intended as a precaution
  9. // against inadvertent publication, and shall not be deemed to
  10. // constitute an acknowledgment that publication has occurred
  11. // nor to imply any waiver of confidentiality. The year included
  12. // in the notice is the year of the creation of the work.
  13. //------------------------------------------------------------------------
  14. // DESCRIPTION:    A VeObjectRef is used to pass an object with its class
  15. //        name. Using the class name, class information can
  16. //        be obtained from the class registry.
  17. //        Instances of this class can be passed by value very
  18. //        efficiently. 
  19. //         VeObjectRef maintains a reference-counted internal 
  20. //        representation    that is shared among objects.  
  21. //------------------------------------------------------------------------
  22.  
  23. #ifndef VOBJREF_HH
  24. #define VOBJREF_HH
  25.  
  26. #include <visedge.hh>
  27. #include <dllclass.hh>
  28. #include <vthread.hh>    //For VeRefCount
  29.  
  30. VCLASS VobType;
  31.  
  32. VCLASS VeObjectRef : public VeDllBasedClass
  33. {
  34. public:
  35.     VOPERDECL VeObjectRef(void *object, VobType *type = 0);
  36.     VOPERDECL VeObjectRef(const VeObjectRef &);
  37.     VOPERDECL VeObjectRef();
  38.  
  39.     VOPERDECL ~VeObjectRef();
  40.  
  41.     VMETHODDECL(void *) Object() const;
  42.     VMETHODDECL(VobType *) Type() const;
  43.  
  44.     VMETHODDECL(void) Set(void *object, VobType *type = 0);
  45.  
  46.     VMETHODDECL(VeObjectRef &) operator= (const VeObjectRef&);
  47.  
  48.  
  49. protected:
  50.  
  51. private:
  52.     //-----------------------------------------------------
  53.     // The actual data is shared as often as possible.
  54.     //-----------------------------------------------------
  55.     struct ObjectData {
  56.         ObjectData() : type(0), object(0) {}
  57.         VeRefCount       refcount;
  58.         VobType     *type;
  59.         void           *object;
  60.     } * itsRep; 
  61. };
  62.  
  63. #ifdef NOTEMPLATES
  64. #       ifndef VTObjectRefListDefined
  65. #               define VTObjectRefListDefined
  66. #               define CLASSNAME   VTObjectRefList
  67. #               define ENTRYTYPE   VeObjectRef*
  68. #               include <mst/varray.mst>
  69. #       endif
  70.  
  71. #else
  72. #       include <varray.hh>
  73.         typedef VeArray<VeObjectRef*> VTObjectRefList;
  74. #endif
  75.  
  76. #endif //VOBJREF_HH
  77.