csutil/plugmgr.h
00001 /* 00002 Copyright (C) 1998-2001 by Jorrit Tyberghein 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public 00015 License along with this library; if not, write to the Free 00016 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00017 */ 00018 00019 #ifndef __CS_PLUGMGR_H__ 00020 #define __CS_PLUGMGR_H__ 00021 00022 #include "scf.h" 00023 #include "scopedmutexlock.h" 00024 #include "parray.h" 00025 #include "iutil/config.h" 00026 #include "iutil/plugin.h" 00027 00028 struct iComponent; 00029 struct iObjectRegistry; 00030 00035 class csPluginManager : public iPluginManager 00036 { 00037 private: 00039 csRef<csMutex> mutex; 00040 00044 class csPlugin 00045 { 00046 public: 00048 iComponent *Plugin; 00050 char *ClassID; 00051 00053 csPlugin (iComponent *iObject, const char *iClassID); 00055 virtual ~csPlugin (); 00056 }; 00057 00061 class csPluginsVector : public csPDelArray<csPlugin> 00062 { 00063 public: 00065 csPluginsVector (int iLimit, int iDelta) 00066 : csPDelArray<csPlugin> (iLimit, iDelta) {} 00068 static int CompareAddress (csPlugin* const& Item, void* Key) 00069 { 00070 return Item->Plugin == Key ? 0 : 1; 00071 } 00072 }; 00073 00077 class csPluginOption 00078 { 00079 public: 00080 char *Name; 00081 csVariantType Type; 00082 int ID; 00083 bool Value; // If Type is CSVAR_BOOL 00084 iConfig *Config; 00085 00086 csPluginOption (const char *iName, csVariantType iType, int iID, 00087 bool iValue, iConfig* iConfig) 00088 { 00089 Name = csStrNew (iName); 00090 Type = iType; 00091 ID = iID; 00092 Value = iValue; 00093 (Config = iConfig)->IncRef (); 00094 } 00095 virtual ~csPluginOption () 00096 { 00097 Config->DecRef (); 00098 delete [] Name; 00099 } 00100 }; 00101 00103 iObjectRegistry* object_reg; 00104 00106 csPluginsVector Plugins; 00107 00108 // List of all options for all plug-in modules. 00109 csPDelArray<csPluginOption> OptionList; 00110 00111 public: 00113 csPluginManager (iObjectRegistry* object_reg); 00115 virtual ~csPluginManager (); 00116 00117 SCF_DECLARE_IBASE; 00118 00120 virtual iBase *LoadPlugin (const char *iClassID, 00121 const char *iInterface = 0, int iVersion = 0, 00122 bool init = true); 00123 00127 virtual iBase *QueryPlugin (const char *iInterface, int iVersion); 00129 virtual iBase *QueryPlugin (const char* iClassID, 00130 const char *iInterface, int iVersion); 00132 virtual bool UnloadPlugin (iComponent *iObject); 00134 virtual bool RegisterPlugin (const char *iClassID, 00135 iComponent *iObject); 00137 virtual csPtr<iPluginIterator> GetPlugins (); 00139 virtual void Clear (); 00140 00142 virtual void QueryOptions (iComponent *iObject); 00143 }; 00144 00145 #endif // __CS_PLUGMGR_H__ 00146
Generated for Crystal Space by doxygen 1.2.18