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

  1. //----------------------------------------------------------------
  2. // $Source: /rcs/crcs/general/extend.hh,v $
  3. // Checked in by: $Author: philip $
  4. // $Date: 1996/07/03 18:27:03 $            $Revision: 1.14 $
  5. //----------------------------------------------------------------
  6. //       Copyright(c) 1992, 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. // consitute 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:
  15. //      This file contains the definition of the VeLibrary base
  16. //    class.  To use libraries include libmgr.hh instead
  17. //    of using VeCreateLibrary directly
  18. //----------------------------------------------------------------------
  19.  
  20. #ifndef EXTEND_HH
  21. #define EXTEND_HH
  22.  
  23. #include <visedge.hh>
  24. #include <libload.hh>
  25. #include <vstring.hh>
  26. #include <pathlist.hh>
  27. #include <libmgr.hh>
  28. #include <vthread.hh>    //For VeRefCount
  29.  
  30. VCLASS VeExtension;
  31.  
  32. typedef unsigned short VTExtensionID;
  33. typedef void (*VTEnumExtension)(void *context, VeExtension *);
  34.  
  35. #define kVCurrentMajorVersion        1
  36. #define kVCurrentMinorVersion        0
  37.  
  38. #define kVOlderVersionExtension        ((VTExtensionID)0)
  39. #define kVOtherVersionExtension        ((VTExtensionID)1)
  40.  
  41. #define kVLoadAdapterExtension        ((VTExtensionID)2)
  42. #define kVRuntimeExtension        ((VTExtensionID)3)
  43. #define kVDesignExtension        ((VTExtensionID)4)
  44. #define kVProjectExtension        ((VTExtensionID)5)
  45. #define kVSupervisorExtension        ((VTExtensionID)6)
  46. #define kVErrorHandlerExtension        ((VTExtensionID)7)
  47. #define kVRuntimeNameExtension        ((VTExtensionID)8)
  48. #define kVSaveExecutableExtension    ((VTExtensionID)9)
  49. #define kVLoadExecutableExtension    ((VTExtensionID)10)
  50.  
  51. VCLASS VeExtension : public VeDllBasedClass
  52. {
  53. public:
  54.  
  55.     VOPERDECL             VeExtension();
  56.  
  57.     VeString             Name() { return itsName; }
  58.  
  59.     VVIRTUALDECL(unsigned short)     MajorVersion() = 0;
  60.     VVIRTUALDECL(unsigned short)     MinorVersion() = 0;
  61.  
  62.     VVIRTUALDECL(unsigned short)     ExtensionMajorVersion() = 0;
  63.     VVIRTUALDECL(unsigned short)     ExtensionMinorVersion() = 0;
  64.  
  65.     VVIRTUALDECL(void *)         GetExtension(VTExtensionID) = 0;
  66.  
  67.  
  68. protected:
  69.  
  70.     virtual VOPERDECL         ~VeExtension();
  71.  
  72.  
  73. private:
  74.  
  75.     void        ReleaseLibrary();
  76.  
  77.     VeString    itsName;
  78.     VeRefCount    itsRefCount;
  79.     VeLibrary    *itsLibrary;
  80.  
  81.     friend class    VeExtensionManager;
  82. };
  83.  
  84. #ifdef NOTEMPLATES
  85. #    ifndef VTExtensionListDefined
  86. #        define VTExtensionListDefined
  87. #        define CLASSNAME VTExtensionList
  88. #        define ENTRYTYPE VeExtension*
  89. #        include <mst/varray.mst>
  90. #    endif
  91. #else
  92.  
  93.     #include <vdic.hh>
  94.     typedef    VeArray<VeExtension*> VTExtensionList;
  95.  
  96. #endif  // NOTEMPLATES
  97.  
  98. VCLASS VeExtensionManager;
  99.  
  100. class VeExtensionManager : public VeDllBasedClass
  101. {
  102.  
  103. public:
  104.  
  105.     VOPERDECL             VeExtensionManager();
  106.  
  107.     VVIRTUALDECL(unsigned long)     Acquire();
  108.     VVIRTUALDECL(unsigned long)     Release();
  109.  
  110.     VVIRTUALDECL(VeExtension *)     LoadExtension(const char *name);
  111.  
  112.     VVIRTUALDECL(void)         UnloadExtension(VeExtension *extension);
  113.  
  114.     VVIRTUALDECL(void *)         FindExtension(VTExtensionID id);
  115.  
  116.     VVIRTUALDECL(bool_t)         ForEachExtension(VTExtensionID id,
  117.                             VTEnumExtension enumerator,
  118.                             void *context);
  119.     VINLINEDECL(VePathList)        Path();
  120.     VINLINEDECL(void)        SetPath(VePathList newPath);
  121.     VINLINEDECL(void)        AddPath(const char *path);
  122.  
  123.     VINLINEDECL(VeLibraryMgr *)    LibraryManager();
  124.  
  125.     VINLINEDECL(VTExtensionList)    Extensions();
  126.  
  127. protected:
  128.  
  129.     virtual VOPERDECL         ~VeExtensionManager();
  130.  
  131.     VVIRTUALDECL(void)         InstallExtension(const char *name,
  132.                             VeExtension *extension);
  133. private:
  134.  
  135.     VeRefCount    itsRefCount;
  136.  
  137.     VTExtensionList    itsExtensions;
  138.  
  139.     VeLibraryMgr    *itsLibraryMgr;
  140. };
  141.  
  142. VINLINEDEF(VePathList) VeExtensionManager::Path()
  143. {
  144.     return itsLibraryMgr->Path();
  145. }
  146.  
  147. VINLINEDEF(void) VeExtensionManager::SetPath(VePathList newPath)
  148. {
  149.     itsLibraryMgr->SetPath(newPath);
  150. }
  151.  
  152. VINLINEDEF(void) VeExtensionManager::AddPath(const char *path)
  153. {
  154.     itsLibraryMgr->AddPath(path);
  155. }
  156.  
  157. VINLINEDEF(VeLibraryMgr *) VeExtensionManager::LibraryManager()
  158. {
  159.     return itsLibraryMgr;
  160. }
  161.  
  162. VINLINEDEF(VTExtensionList) VeExtensionManager::Extensions()
  163. {
  164.     return itsExtensions;
  165. }
  166.  
  167. extern "C"
  168. {
  169.     VFUNCDECL(bool_t) VeValidVersion(VeExtension *);
  170.  
  171.     typedef VeExtension * (*  VTLibraryExtension)(    unsigned short    major,
  172.                             unsigned short    minor);
  173.  
  174.     //------------------------------------------------------------------
  175.     // VeLibraryExtension should be defined inside the library
  176.     // The extension is loaded through this call
  177.     //------------------------------------------------------------------
  178.  
  179.     VFUNCDECL(VeExtension *) VeLibraryExtension(    unsigned short    major,
  180.                             unsigned short    minor);
  181. }
  182.  
  183. #endif // EXTEND_HH
  184.