plugin.h

Go to the documentation of this file.
00001 /* -*- Mode: c++ -*- */
00002 /*
00003  *  this is part of Spm
00004  *
00005  *  Copyright (c) 2005-2007 Guillaume Chevallereau
00006  *
00007  *  This program is free software. You can redistribute it and/or modify it 
00008  *  under the terms of the GNU General Public License as published by the 
00009  *  Free Software Foundation. Either version 2 of the license or (at your 
00010  *  option) any later version.
00011  *
00012  *  This program is distributed in the hope that it will be usefull but WITHOUT
00013  *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
00014  *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for 
00015  *  more details.
00016  *
00017  *  You should have received a copy of the GNU General Public License along 
00018  *  with this program; if not, write to the Free Software Foundation, Inc., 
00019  *  59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
00020  */
00021 #ifndef __PLUGIN_H__
00022 #define __PLUGIN_H__
00023 
00024 #include "pluginDef.h"
00025 #include "stepInterface.h"
00026 #include "downloadInterface.h"
00027 #include "installerInterface.h"
00028 #include "pluginException.h"
00029 #include <miniXml.h>
00030 
00031 #define DownloadPlugin DownloadInterface 
00032 #define StepPlugin StepInterface 
00033 #define InstallerPlugin InstallerInterface
00034 
00035 #include <string>
00036 #include <util/object.h>
00037 namespace Spm
00038 {
00039   namespace Plugin
00040   {
00044     typedef void * plugin_td;
00045     typedef void * object_td;
00046     typedef Interface* (*GetModule)(std::map<std::string,std::string> options);
00047     typedef DownloadInterface* (*GetDownloadModule)(const Util::urlDetails & url);
00048     typedef Interface* (*GetTryModule)();
00049     typedef pluginDescription_t (*GetModuleDescription)();
00050     typedef InstallerInterface* (*GetInstallerModule)(Util::Compressed * compressed);
00054     class Plugin : public Util::Object
00055     {
00056       friend class PluginSystem;
00057       friend Plugin * convertXmlToPlugin (const miniXml::Element * pluginElement);
00058     private:
00059       std::string __version;
00060       std::string __description;
00061       boost::filesystem::path __path;
00062       std::string __author;
00063       license_e __license;
00064       bool __loaded;
00065       bool __enabled;
00066       pluginType_e __type;
00067       plugin_td __plugin;
00068       void open ()
00069         throw (PluginException);
00070       void close ();
00071       object_td getObject (const std::string & objectName)
00072         throw (PluginException);
00073       std::map<std::string,
00074                std::string> __pluginOptions;
00078       void setPluginOptions (const std::map<std::string, std::string> & options);
00079 
00080     public:
00081       Plugin ();
00085       Plugin (const boost::filesystem::path & aFile);
00086       
00093       static Plugin * isAPlugin (const boost::filesystem::path & aFile)
00094         throw (NotAPluginException);
00095 
00096       ~Plugin ();
00097       
00101       const std::string & getDescription ();
00102       
00103       const boost::filesystem::path & getPath ();
00104 
00108       pluginType_e getType ();
00109 
00110       const std::string & getDescription () const;
00111       
00112       const boost::filesystem::path & getPath () const;
00113 
00114       pluginType_e getType () const;
00115 
00119       const std::string & getVersion ();
00120       
00124       const std::string & getVersion () const;
00125 
00129       const std::string & getAuthor ();
00130       
00134       const std::string & getAuthor () const;
00135 
00139       const license_e & getLicense ();
00140       
00144       const license_e & getLicense () const;
00145 
00150       Interface * getObject (const std::map<std::string,std::string> & pOptions) 
00151         throw (NotActivePluginException,
00152                PluginException);
00153 
00157       Interface * getObject () 
00158         throw (NotActivePluginException,
00159                PluginException);
00160 
00165       DownloadInterface * getDownloaderObject (const Util::urlDetails & url) 
00166         throw (NotActivePluginException,
00167                PluginException);
00168 
00173       InstallerInterface * getObject (Util::Compressed * compressed)
00174         throw (NotActivePluginException,
00175                PluginException);
00176       
00180       bool isEnable ();
00181       bool isEnable () const;
00182 
00186       const std::map<std::string,
00187                      std::string> & getPluginOptions ();
00188 
00192       const std::map<std::string,
00193                      std::string> & getPluginOptions () const;
00194 
00198       void enable ();
00199 
00203       void disable ();
00204 
00205       bool operator< (const Plugin & p) const;
00206     };
00207   }
00208 }
00209 #endif

Generated on Wed Jul 4 15:27:21 2007 for libSpm by  doxygen 1.4.6