CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

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 "csextern.h"
00023 #include "scf.h"
00024 #include "scopedmutexlock.h"
00025 #include "parray.h"
00026 #include "iutil/config.h"
00027 #include "iutil/plugin.h"
00028 
00029 struct iComponent;
00030 struct iObjectRegistry;
00031 
00036 class CS_CSUTIL_EXPORT csPluginManager : public iPluginManager
00037 {
00038 private:
00040   csRef<csMutex> mutex;
00041 
00045   class CS_CSUTIL_EXPORT csPlugin
00046   {
00047   public:
00049     iComponent *Plugin;
00051     char *ClassID;
00052 
00054     csPlugin (iComponent *iObject, const char *iClassID);
00056     virtual ~csPlugin ();
00057   };
00058 
00062   class CS_CSUTIL_EXPORT csPluginsVector : public csPDelArray<csPlugin>
00063   {
00064   public:
00066     csPluginsVector (int l, int d) : csPDelArray<csPlugin> (l, d) {}
00068     static int CompareAddress (csPlugin* const& Item, iComponent* const& Key)
00069     { return Item->Plugin == Key ? 0 : 1; }
00070   };
00071 
00075   class CS_CSUTIL_EXPORT csPluginOption
00076   {
00077   public:
00078     char *Name;
00079     csVariantType Type;
00080     int ID;
00081     bool Value;                         // If Type is CSVAR_BOOL
00082     iConfig *Config;
00083 
00084     csPluginOption (const char *iName, csVariantType iType, int iID,
00085       bool iValue, iConfig* iConfig)
00086     {
00087       Name = csStrNew (iName);
00088       Type = iType;
00089       ID = iID;
00090       Value = iValue;
00091       (Config = iConfig)->IncRef ();
00092     }
00093     virtual ~csPluginOption ()
00094     {
00095       Config->DecRef ();
00096       delete [] Name;
00097     }
00098   };
00099 
00101   iObjectRegistry* object_reg;
00102 
00104   csPluginsVector Plugins;
00105 
00106   // List of all options for all plug-in modules.
00107   csPDelArray<csPluginOption> OptionList;
00108 
00109 public:
00111   csPluginManager (iObjectRegistry* object_reg);
00113   virtual ~csPluginManager ();
00114 
00115   SCF_DECLARE_IBASE;
00116 
00118   virtual iBase *LoadPlugin (const char *iClassID,
00119         const char *iInterface = 0, int iVersion = 0,
00120         bool init = true);
00121 
00125   virtual iBase *QueryPlugin (const char *iInterface, int iVersion);
00127   virtual iBase *QueryPlugin (const char* iClassID,
00128           const char *iInterface, int iVersion);
00130   virtual bool UnloadPlugin (iComponent *iObject);
00132   virtual bool RegisterPlugin (const char *iClassID,
00133           iComponent *iObject);
00135   virtual csPtr<iPluginIterator> GetPlugins ();
00137   virtual void Clear ();
00138 
00140   virtual void QueryOptions (iComponent *iObject);
00141 };
00142 
00143 #endif // __CS_PLUGMGR_H__
00144 

Generated for Crystal Space by doxygen 1.2.18