source: golgotha/src/maxtool/sdk_inc/plugin.h

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