00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __PLUGIN_H__
00022 #define __PLUGIN_H__
00023
00024 #include "stepInterface.h"
00025 #include "downloadInterface.h"
00026 #include "installerInterface.h"
00027 #include "infoInterface.h"
00028 #include "pluginException.h"
00029
00030 #define DownloadPlugin DownloadInterface
00031 #define StepPlugin StepInterface
00032 #define InstallerPlugin InstallerInterface
00033 #define InfoPlugin InfoInterface
00034
00035 #include <util/object.h>
00036 namespace miniXml
00037 {
00038 class Element;
00039 }
00040 namespace Spm
00041 {
00042 namespace Plugin
00043 {
00044 class Plugin : public Util::Object
00045 {
00046 friend class PluginManager;
00047 friend Plugin * convertXmlToPlugin (const miniXml::Element * pluginElement);
00048 friend struct equalDownloaderHandler;
00049 friend struct equalInstallerHandlerByUrl;
00050 friend struct equalInstallerHandlerByCompressed;
00051 private:
00052 typedef void * plugin_td;
00053 typedef void * object_td;
00054 miniXml::ustring version_;
00055 miniXml::ustring description_;
00056 boost::filesystem::path path_;
00057 miniXml::ustring author_;
00058 license_e license_;
00059 bool loaded_;
00060 bool enabled_;
00061 pluginType_e type_;
00062 plugin_td plugin_;
00063 std::map<miniXml::ustring,
00064 miniXml::ustring> pluginOptions_;
00065 void open ()
00066 throw (PluginException);
00067 void close ();
00068 object_td getObject (const miniXml::ustring & objectName)
00069 throw (PluginException);
00070
00071 void setPluginOptions (const std::map<miniXml::ustring, miniXml::ustring> & options);
00072 Plugin ();
00073 Plugin (const boost::filesystem::path & aFile);
00074 ~Plugin ();
00075
00076 Interface * getObject (const Util::PropertyList & pOptions)
00077 throw (NotActivePluginException,
00078 PluginException);
00079 Interface * getObject ()
00080 throw (NotActivePluginException,
00081 PluginException);
00082 DownloadInterface * getDownloaderObject (const Util::urlDetails & url)
00083 throw (NotActivePluginException,
00084 PluginException);
00085 InstallerInterface * getObject (Util::Compressed * compressed,
00086 const Util::PropertyList & pOptions);
00087 InfoInterface * getInfoObject (const miniXml::ustring & url);
00088 int handle (Util::Compressed * compressed,
00089 const Util::PropertyList & pOptions);
00090 int handle (const miniXml::ustring & url,
00091 const Util::PropertyList & pOptions);
00092
00093 public:
00100 static Plugin * isAPlugin (const boost::filesystem::path & aFile)
00101 throw (NotAPluginException);
00105 const miniXml::ustring & getDescription ();
00106
00110 const boost::filesystem::path & getPath ();
00111
00115 pluginType_e getType ();
00116
00120 const miniXml::ustring & getDescription () const;
00121
00125 const boost::filesystem::path & getPath () const;
00126
00130 pluginType_e getType () const;
00131
00135 const miniXml::ustring & getVersion ();
00136
00140 const miniXml::ustring & getVersion () const;
00141
00145 const miniXml::ustring & getAuthor ();
00146
00150 const miniXml::ustring & getAuthor () const;
00151
00155 const license_e & getLicense ();
00156
00160 const license_e & getLicense () const;
00161
00162
00166 bool enabled ();
00167 bool enabled () const;
00168
00172 const std::map<miniXml::ustring,
00173 miniXml::ustring> & getPluginOptions ();
00174
00178 const std::map<miniXml::ustring,
00179 miniXml::ustring> & getPluginOptions () const;
00180
00184 void enable ();
00185
00189 void disable ();
00190
00191 bool operator< (const Plugin & p) const;
00192 };
00193 }
00194 }
00195 #endif