installerInterface.h

Go to the documentation of this file.
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 __INSTALLER_INTERFACE_H__
00022 #define __INSTALLER_INTERFACE_H__
00023 
00024 #include "interface.h"
00025 #include "stepInterface.h"
00026 #include <list>
00027 #include <string>
00028 #include <util/compressed.h>
00029 #include <boost/signals.hpp>
00030 
00031 namespace Spm
00032 {
00033   namespace Plugin
00034   {
00039     class InstallerInterface : public Interface
00040     {
00041     protected:
00042       boost::filesystem::path __prefix;
00043       boost::filesystem::path __runningDir;
00044       Util::Compressed * __compressed;
00045       std::string __name;
00046       std::string __version;
00047       std::list<std::string> __dependency;
00048       boost::signal<void (Interface *)> __end;
00049       boost::signal<void (StepInterface *)> __changedStep;
00050       boost::signal<void (InstallerInterface *)> __begin;
00051       std::list<StepInterface *> __steps;
00052       std::list<StepInterface *>::iterator __itStep;
00053  
00054       InstallerInterface ()
00055       {
00056         __description.__pluginType = INSTALLER_TYPE;
00057         __compressed = NULL;
00058       }
00059       
00060       InstallerInterface (Util::Compressed * archive)
00061       {
00062         __description.__pluginType = INSTALLER_TYPE;
00063         __compressed = archive;
00064       }
00065 
00066       void setState (state_e pluginState)
00067       {
00068         currentState = pluginState;
00069       }
00070 
00071     public:
00072       ~InstallerInterface ()
00073       {
00074         for(__itStep = __steps.begin ();
00075             __itStep != __steps.end ();
00076             __itStep++)
00077           delete (*__itStep);
00078         __steps.clear ();
00079 
00080         if(__compressed)
00081           delete (__compressed);
00082         __compressed = NULL;
00083       }
00084 
00088       virtual void init (const std::map<std::string,std::string> & pOptions)
00089       {
00090       }
00091       
00095       virtual void postInstall (const std::map<std::string,std::string> & pOptions)
00096       {
00097       }
00098 
00103       virtual void install (const std::map<std::string,std::string> & pOptions)
00104       {
00105         __begin (this);
00106         init (pOptions);
00107         for (__itStep = __steps.begin ();
00108              __itStep != __steps.end ();
00109              __itStep++)
00110           {
00111             __changedStep ((*__itStep));
00112             (*__itStep)->run (__runningDir.string ());
00113           }
00114         postInstall (pOptions);
00115         __end(this);
00116       }
00117 
00121       virtual const StepInterface * getActualStep ()
00122       {
00123         return *__itStep;
00124       }
00125 
00129       virtual const std::list<boost::filesystem::path> getInstalledElement () = 0;
00130 
00134       virtual std::map<std::string,
00135                        std::string> getUsedOptions () = 0;
00136 
00141       virtual bool handle (Util::Compressed * compressed) = 0;
00142 
00147       virtual bool handle (const std::string & url)
00148       {
00149         return false;
00150       }
00151 
00155       const boost::filesystem::path & getPrefix ()
00156       {
00157         return __prefix;
00158       }
00159       
00163       virtual const std::string & getPackageName ()
00164       {
00165         return __name;
00166       }
00167 
00171       virtual const std::string & getPackageVersion ()
00172       {
00173         return __version;
00174       }
00175 
00179       virtual const std::list<std::string> & getDependency ()
00180       {
00181         return __dependency;
00182       }
00183 
00184       boost::signal<void (Interface *)> & signalEnd ()
00185       {
00186         return __end;
00187       }
00188 
00189       boost::signal<void (StepInterface *)> & signalChangedStep ()
00190       {
00191         return __changedStep;
00192       }
00193     };
00194   }
00195 }
00196 
00197 #endif

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