Crystal Space: csutil/plugmgr.h Source File (Crystal Space Public API Reference)

| ## Public API Reference

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# csutil/plugmgr.h

Go to the documentation of this file.

    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
    00026 #include "csextern.h"
    00027 #include "csutil/parray.h"
    00028 #include "csutil/scf.h"
    00029 #include "csutil/scf_implementation.h"
    00030 #include "csutil/thread.h"
    00031 #include "iutil/plugin.h"
    00032 #include "iutil/pluginconfig.h"
    00033
    00034 struct iComponent;
    00035 struct iObjectRegistry;
    00036
    00041 class CS_CRYSTALSPACE_EXPORT csPluginManager :
    00042   public scfImplementation1<csPluginManager, iPluginManager>
    00043 {
    00044 private:
    00046   csRef<csMutex> mutex;
    00047
    00051   class CS_CRYSTALSPACE_EXPORT csPlugin
    00052   {
    00053   public:
    00055     iComponent *Plugin;
    00057     char *ClassID;
    00058
    00060     csPlugin (iComponent *iObject, const char *iClassID);
    00062     virtual ~csPlugin ();
    00063   };
    00064
    00068   class CS_CRYSTALSPACE_EXPORT csPluginsVector : public csPDelArray<csPlugin>
    00069   {
    00070   public:
    00072     csPluginsVector (int l, int d) : csPDelArray<csPlugin> (l, d) {}
    00074     static int CompareAddress (csPlugin* const& Item, iComponent* const& Key)
    00075     { return Item->Plugin == Key ? 0 : 1; }
    00076   };
    00077
    00081   class CS_CRYSTALSPACE_EXPORT csPluginOption
    00082   {
    00083   public:
    00084     char *Name;
    00085     csVariantType Type;
    00086     int ID;
    00087     bool Value;                         // If Type is CSVAR_BOOL
    00088     csRef<iPluginConfig> Config;
    00089
    00090     csPluginOption (const char *iName, csVariantType iType, int iID,
    00091       bool iValue, iPluginConfig* cfg)
    00092     {
    00093       Name = csStrNew (iName);
    00094       Type = iType;
    00095       ID = iID;
    00096       Value = iValue;
    00097       Config = cfg;
    00098     }
    00099     virtual ~csPluginOption ()
    00100     {
    00101       delete [] Name;
    00102     }
    00103   };
    00104
    00106   iObjectRegistry* object_reg;
    00107
    00109   csPluginsVector Plugins;
    00110
    00111   // List of all options for all plug-in modules.
    00112   csPDelArray<csPluginOption> OptionList;
    00113
    00114 public:
    00116   csPluginManager (iObjectRegistry* object_reg);
    00118   virtual ~csPluginManager ();
    00119
    00121   virtual iBase *LoadPlugin (const char *iClassID, bool init = true);
    00122
    00126   virtual iBase *QueryPlugin (const char *iInterface, int iVersion);
    00128   virtual iBase *QueryPlugin (const char* iClassID,
    00129           const char *iInterface, int iVersion);
    00131   virtual bool UnloadPlugin (iComponent *iObject);
    00133   virtual bool RegisterPlugin (const char *iClassID,
    00134           iComponent *iObject);
    00136   virtual csPtr<iPluginIterator> GetPlugins ();
    00138   virtual void Clear ();
    00139
    00141   virtual void QueryOptions (iComponent *iObject);
    00142 };
    00143
    00144 #endif // __CS_PLUGMGR_H__
    00145