00001 //----------------------------------------------------------------------------- 00002 // ---------------- 00003 // File ....: gup.h 00004 // ---------------- 00005 // Author...: Gus Grubba 00006 // Date ....: September 1998 00007 // 00008 // History .: Sep, 30 1998 - Started 00009 // 00010 //----------------------------------------------------------------------------- 00011 #pragma once 00012 00013 #ifdef GUP_EXPORTS 00014 #define GUPExport __declspec( dllexport ) 00015 #else 00016 #define GUPExport __declspec( dllimport ) 00017 #endif 00018 00019 #include "maxheap.h" 00020 #include "gupapi.h" 00021 #include "strbasic.h" 00022 00023 // forward declarations 00024 class BitmapManager; 00025 class GUP; 00026 class ClassDesc; 00027 class ISave; 00028 class ILoad; 00029 00030 //----------------------------------------------------------------------------- 00031 //----------------------------------------------------------------------------- 00032 //-- Plug-Ins Handler 00033 // 00034 00040 class GUPHandler : public InterfaceServer { 00041 00042 //-- DLL Handler ---------------------------------- 00043 00044 ClassDesc* cd; 00045 Class_ID id; 00046 GUP* instance; 00047 00048 public: 00049 00050 GUPHandler ( ); 00051 00052 GUPExport void SetCD ( ClassDesc *dll ) { cd = dll; } 00053 GUPExport ClassDesc* GetCD ( ) { return cd;} 00054 GUPExport void SetID ( Class_ID cid ) { id = cid; } 00055 GUPExport Class_ID GetID ( ) { return id;} 00056 GUPExport void SetInstance ( GUP *ins ) { instance = ins; } 00057 GUPExport GUP* GetInstance ( ) { return instance; } 00058 00059 GUPExport GUP* Gup ( ) { return instance; } 00060 00061 }; 00062 00063 //----------------------------------------------------------------------------- 00064 //----------------------------------------------------------------------------- 00065 //-- List of Loaded Plug-Ins 00066 // 00067 00076 class GUPList: public Tab<GUPHandler> { 00077 00078 public: 00079 00081 GUPExport GUPList ( ) { ; } 00087 GUPExport int FindGup ( const Class_ID id ); 00095 GUPExport GUP* CreateInstance ( const Class_ID id ); 00096 00097 }; 00098 00099 //----------------------------------------------------------------------------- 00100 //----------------------------------------------------------------------------- 00101 //-- Global Utility Plug-In Class 00102 // 00103 00133 class GUP : public InterfaceServer { 00134 00135 public: 00136 00138 GUPExport GUP ( ); 00140 GUPExport virtual ~GUP ( ); 00141 00142 //----------------------------------------------------------- 00143 //-- Plug-In Service Methods 00144 00147 GUPExport virtual HINSTANCE MaxInst ( ); 00150 GUPExport virtual HWND MaxWnd ( ); 00154 GUPExport virtual DllDir* MaxDllDir ( ); 00158 GUPExport virtual Interface* Max ( ); 00162 GUPExport virtual BitmapManager* Bmi ( ); 00170 GUPExport virtual int EnumTree ( ITreeEnumProc *proc ); 00171 00172 //----------------------------------------------------------- 00173 //-- Plug-In Service Methods (Scripting) 00174 00188 GUPExport virtual bool ExecuteStringScript ( MCHAR *string ); 00197 GUPExport virtual bool ExecuteFileScript ( MCHAR *file ); 00198 00199 //----------------------------------------------------------- 00200 //----------------------------------------------------------- 00201 //-- Plug-In Implementation Methods 00202 00203 //----------------------------------------------------------- 00204 // Start() is called at boot time. If the plug-in 00205 // desires to remain loaded, it returns GUPRESULT_KEEP. If 00206 // it returns GUPRESULT_NOKEEP, it will be discarded. If it 00207 // returns GUPRESULT_ABORT MAX will be shut down. 00208 00209 #define GUPRESULT_KEEP 0x00 00210 #define GUPRESULT_NOKEEP 0x01 00211 #define GUPRESULT_ABORT 0x03 00212 00228 GUPExport virtual DWORD Start ( ) = 0; 00229 00230 //------------------------------------------------- 00231 // Stop is called prior to discarding the plug-in 00232 // for persistent plug-ins (i.e. only those that 00233 // returned GUPRESULT_KEEP for Start() above). 00234 00240 GUPExport virtual void Stop ( ) = 0; 00241 00242 //------------------------------------------------- 00243 // Control is an entry point for external access to 00244 // GUP plug-ins. For instance, Utility plugins can 00245 // invoke their GUP plugin counterpart and have 00246 // direct access to them. 00247 // 00248 // SR NOTE64: This can return pointer-sized data, so 00249 // it has to be a DWORD_PTR. 00259 GUPExport virtual DWORD_PTR Control ( DWORD parameter ) { UNUSED_PARAM(parameter); return 0;} 00260 00261 //------------------------------------------------- 00262 // Optional Methods for saving the plug-in state 00263 // within a scene file. 00264 00270 GUPExport virtual IOResult Save ( ISave *isave ); 00276 GUPExport virtual IOResult Load ( ILoad *iload ); 00277 00278 // RK: 06/28/00, added it to support static instances 00279 GUPExport virtual void DeleteThis ( ) { } 00280 }; 00281 00282 //----------------------------------------------------------------------------- 00283 //----------------------------------------------------------------------------- 00284 //-- Main GUP Manager Class 00285 // 00286 // 00287 00300 class GUPManager: public MaxHeapOperators { 00301 00302 GUPInterface* iface; 00303 00304 int InitList ( ); 00305 bool listed; 00306 00307 public: 00308 00310 GUPExport GUPManager ( GUPInterface *i ); 00312 GUPExport ~GUPManager ( ); 00313 00314 GUPList gupList; 00315 00317 GUPExport bool Ready ( ); 00319 GUPExport bool Init ( ); 00323 GUPExport GUPInterface* Interface ( ) { return iface; } 00324 GUPExport IOResult Save ( ISave *isave ); 00325 GUPExport IOResult Load ( ILoad *iload ); 00326 00327 }; 00328 00329 //----------------------------------------------------------------------------- 00330 //-- Exported 00331 // 00332 00333 extern GUPExport void OpenGUP ( GUPInterface *i ); 00334 extern GUPExport void CloseGUP ( ); 00335 extern GUPExport GUPManager* gupManager; 00336 extern GUPExport GUP* OpenGupPlugIn ( const Class_ID id); 00337 00338 //----------------------------------------------------------------------------- 00339 //-- Cleanup 00340 00341 00342 //-- EOF: gup.h ---------------------------------------------------------------