plugin.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. #ifndef PLUGIN_H_DEFINED
  2. #define PLUGIN_H_DEFINED
  3. /*******************************************************************
  4. *
  5. * DESCRIPTION: DLL Plugin classes
  6. *
  7. * AUTHOR: Dan Silva
  8. *
  9. * HISTORY: 11/30/94 Started coding
  10. *
  11. *******************************************************************/
  12. typedef unsigned long ulong;
  13. #include <plugapi.h>
  14. //---------------------------------------------------------
  15. // This is the interface to a DLL
  16. // Each DLL may implement any number of classes.
  17. //
  18. class DllDesc {
  19. public:
  20. HINSTANCE handle;
  21. TSTR fname;
  22. const TCHAR* (*vDescription)(); // copy of this string can be stored in the DLL dir
  23. int (*vNumClasses)(); // How many classes does this DLL implement?
  24. ClassDesc* (*vClassDesc)(int i); // Hands back a ClassDesc for the ith class
  25. CoreExport DllDesc();
  26. CoreExport void Free() { FreeLibrary(handle); }
  27. CoreExport const TCHAR* Description() { return (*vDescription)(); };
  28. CoreExport int NumberOfClasses() { return (*vNumClasses)(); };
  29. ClassDesc* operator[](int i) { return (*vClassDesc)(i); };
  30. int operator==( const DllDesc& dd ) const { return 0; }
  31. };
  32. /*-----------------------------------------------------------------
  33. We will build one big DllDir on startup.
  34. As we do this, we will build a set of lists, one for each SuperClass.
  35. For a given super class, we want to
  36. (a) Enumerate all public subclasses
  37. (b) Enumerate all subclasses
  38. (c) Find the subClass for a given subClass ID.
  39. --------------------------------------------------------------*/
  40. class ClassEntry {
  41. int dllNumber; // index into the master Dll list
  42. int classNum; // index of the class within the DLL
  43. int isPublic;
  44. int useCount; // used for enumerating classes in summary info
  45. Class_ID classID;
  46. TSTR name;
  47. TSTR category;
  48. ClassDesc *cd;
  49. // The following are use to store the last rollup state for a
  50. // given class. 'scroll' is the scroll amount of the command panel
  51. // and pageState is the open close state for up to 32 rollup pages. (when the bit is set that means the rollup page is closed)
  52. int scroll;
  53. DWORD pageState;
  54. public:
  55. CoreExport ClassEntry();
  56. CoreExport ClassEntry(const ClassEntry &ce);
  57. CoreExport ClassEntry(ClassDesc *cld, int dllN, int index);
  58. CoreExport void Set(ClassDesc *cld, int dllN, int index);
  59. int DllNumber() { return dllNumber; }
  60. int IsPublic() { return isPublic; }
  61. Class_ID ClassID() { return classID; }
  62. TSTR &ClassName() { return name; }
  63. TSTR &Category() { return category; }
  64. int GetScroll() {return scroll;}
  65. void SetScroll(int s) {scroll = s;}
  66. BOOL GetPageState(int i) {return (pageState&(1<<i))?TRUE:FALSE;}
  67. void SetPageState(int i,BOOL state) {if (state) pageState |= (1<<i); else pageState &= ~(1<<i);}
  68. int UseCount() { return useCount; }
  69. void IncUseCount () { useCount++; }
  70. void SetUseCount(int i) { useCount = i; }
  71. ClassDesc *CD() { return cd; }
  72. CoreExport int ClassEntry::IsAccType(int accType);
  73. CoreExport ClassEntry& operator=( const ClassEntry &ce );
  74. int operator==( const ClassEntry &ce ) const { return 0; }
  75. };
  76. // access type.
  77. #define ACC_PUBLIC 1
  78. #define ACC_PRIVATE 2
  79. #define ACC_ALL (ACC_PUBLIC|ACC_PRIVATE)
  80. typedef ClassEntry* PClassEntry;
  81. typedef Tab<PClassEntry> SubClassTab;
  82. class SubClassList {
  83. int iEnum;
  84. ulong superID;
  85. SubClassTab subClList;
  86. public:
  87. CoreExport ~SubClassList();
  88. SubClassList(ulong sid=0) { superID = sid; }
  89. ClassEntry& operator[](int i){ return(*subClList[i]);}
  90. CoreExport int FindClass(Class_ID subClassID); // Get a class by its class ID
  91. CoreExport int FindClass(const TCHAR *name); // Get a class by its class name
  92. CoreExport void AddClass(ClassDesc *cld, int dllNum, int index);
  93. CoreExport int Count(int accType);
  94. ulong SuperID() { return superID; }
  95. int operator==(const SubClassList &sl) {return(0);}
  96. // Enumerate.
  97. CoreExport int GetFirst(int accType); // get first ClassDesc of accType
  98. CoreExport int GetNext(int accType); // get next ClassDesc of accType (NULL for End)
  99. int operator==( const SubClassList& lst ) const { return 0; }
  100. };
  101. typedef SubClassList* PSubClassList;
  102. typedef Tab<PSubClassList> ListOfClassLists;
  103. /* ClassDirectory: A list of SubClassLists, one for each pluggable
  104. super class */
  105. class ClassDirectory {
  106. ListOfClassLists cl;
  107. public:
  108. CoreExport ~ClassDirectory();
  109. CoreExport SubClassList* GetClassList(SClass_ID superClassID);
  110. CoreExport ClassDesc* FindClass(SClass_ID superClassID, Class_ID subClassID);
  111. CoreExport ClassEntry *FindClassEntry(SClass_ID superClassID, Class_ID subClassID);
  112. SubClassList& operator[](int i){ return(*cl[i]);}
  113. CoreExport void AddSuperClass(SClass_ID superClassID);
  114. // returns 0 if class already exists
  115. // returns -1 if superclass was unknown
  116. CoreExport int AddClass(ClassDesc *cdesc, int dllNum, int index);
  117. int Count() { return cl.Count(); }
  118. };
  119. /* DllDirectory: A list DllDescriptors, one for every DLL loaded
  120. Also contains the ClassDirectory of all classes implemented in these
  121. DLL's */
  122. typedef DllDesc *PDllDesc;
  123. class DllDir {
  124. Tab<PDllDesc> dll; // list of Descriptors for all the loaded DLL's
  125. ClassDirectory classDir; // All the classes implemented in these DLL's
  126. int AddDll(const DllDesc *dllDesc);
  127. public:
  128. CoreExport ~DllDir();
  129. CoreExport void UnloadAllDlls();
  130. int Count() { return dll.Count(); }
  131. DllDesc& operator[](int i) { return(*dll[i]); }
  132. CoreExport int LoadDllsFromDir(TCHAR *directory, TCHAR * wildcard, HWND hwnd=NULL);
  133. ClassDirectory& ClassDir() { return classDir; }
  134. };
  135. #endif // PLUGIN_H_DEFINED