00001 /* -*- Mode: c++ -*- */ 00002 /* 00003 * this is part of Spm 00004 * 00005 * Copyright (c) 2005 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 __STEP_INTERFACE_H__ 00022 #define __STEP_INTERFACE_H__ 00023 00024 #include "interface.h" 00025 #include <list> 00026 #include <util/def.h> 00027 #include <boost/filesystem/path.hpp> 00028 #include <util/utilException.h> 00029 00030 #define SPM_STEP_PLUGIN(plugin) \ 00031 extern "C" \ 00032 { \ 00033 Spm::Plugin::pluginDescription_t getSpmPluginDescription () \ 00034 { \ 00035 return plugin ().getDescription (); \ 00036 } \ 00037 \ 00038 plugin * getSpmPlugin (const Spm::Util::PropertyList & pOptions) \ 00039 { \ 00040 return new plugin (pOptions); \ 00041 } \ 00042 \ 00043 plugin * getSpmPluginInfo () \ 00044 { \ 00045 return new plugin (); \ 00046 } \ 00047 } 00048 00049 namespace Spm 00050 { 00051 namespace Plugin 00052 { 00057 class InstallException : public Exception 00058 { 00059 protected: 00060 InstallException () 00061 { 00062 } 00063 00064 public : 00065 InstallException (const miniXml::ustring & msg) 00066 { 00067 errMsg_ = msg; 00068 } 00069 }; 00070 00075 class StepInterface : public Interface 00076 { 00077 protected : 00078 miniXml::ustring stepDescription_; 00079 double fractionDone_; 00080 std::map<miniXml::ustring, 00081 miniXml::ustring> __usedOptions; 00082 00083 StepInterface (const Util::PropertyList & pList) : Interface (pList) 00084 { 00085 fractionDone_ = -1; 00086 } 00087 00088 StepInterface () 00089 { 00090 fractionDone_ = -1; 00091 } 00092 00093 public : 00094 virtual ~StepInterface (){}; 00099 virtual void run (const boost::filesystem::path & dir) = 0; 00100 00104 const miniXml::ustring & getStepDescription () 00105 { 00106 return stepDescription_; 00107 } 00108 00112 const miniXml::ustring & getStepDescription () const 00113 { 00114 return stepDescription_; 00115 } 00116 00120 virtual double getFractionDone () 00121 { 00122 return fractionDone_; 00123 } 00124 00128 virtual double getFractionDone () const 00129 { 00130 return fractionDone_; 00131 } 00132 00137 bool handle (const miniXml::ustring & uri) 00138 { 00139 return true; 00140 } 00141 00145 const std::map<miniXml::ustring, 00146 miniXml::ustring> & getOptions () 00147 { 00148 return __usedOptions; 00149 } 00150 00154 virtual std::list<boost::filesystem::path> getListOfFiles () = 0; 00155 }; 00156 } 00157 } 00158 00159 #endif