packageSystem.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 __PACKAGE_SYSTEM_H__
00022 #define __PACKAGE_SYSTEM_H__
00023 
00024 #include "category.h"
00025 #include "set.h"
00026 #include "package.h"
00027 #include "coreException.h"
00028 #include <list>
00029 #include <map>
00030 #include <boost/utility.hpp>
00031 #include <boost/shared_ptr.hpp>
00032 #include <plugin/installerInterface.h>
00033 #include <plugin/pluginException.h>
00034 #include <plugin/pluginSystem.h>
00035 #include <util/utilException.h>
00036 #include <store.h>
00037 
00038 namespace Spm
00039 {
00040   namespace Core
00041   {
00042     class PackageSystem 
00043     {
00047     public :
00048       struct objectModified : public std::binary_function<Util::Object *,
00049       std::string,
00050       void>
00051       {
00052         void operator () (Util::Object * object,
00053                           const std::string & user) const;
00054       };
00055 
00056     private :
00057       struct endInstallation : public std::binary_function<Plugin::Interface*, 
00058                                                            std::string, 
00059                                                            void>
00060       {
00061         void operator () (Plugin::Interface * interface,
00062                           const std::string & user) const;
00063       };
00064 
00065       struct endUpdate : public std::binary_function<Plugin::Interface *,
00066                                                      Branch *,
00067                                                      void>
00068       {
00069         void operator () (Plugin::Interface * interface,
00070                           Branch * branch) const;
00071       };
00072 
00073       struct endRemoteInstallation : public std::binary_function<Plugin::Interface *,
00074                                                                  std::string,
00075                                                                  void>
00076       {
00077         void operator () (Plugin::Interface * interface,
00078                           const std::string & user) const;
00079       };
00080       
00084       PackageSystem(const std::string & userName);
00085       Store * __store;
00086       std::list<Category *> categorys;
00087       std::list<Element *> elements;
00088       std::string __user;
00089       std::string checkInstallOptions (const std::map<std::string,
00090                                        std::string> & pOptions)
00091         throw (NoRightException,
00092                UnknownCategoryException,
00093                UnknownElementException,
00094                UnknownSetException,
00095                UnknownBranchException);
00096       boost::shared_ptr<PackageSystem> __systemPackageSystem;
00097       boost::shared_ptr<Plugin::PluginSystem> __userPluginSystem;
00098       Branch * checkPackageToInstall (Plugin::InstallerInterface * installer,
00099                                       const std::string & prefix)
00100         throw (AlreadyExistingBranchException,
00101                UnknownElementException,
00102                UnknownBranchException);
00103       static std::map<std::string,
00104                       boost::shared_ptr<PackageSystem> > __instances;
00105       boost::signal<void (Element *)> __newElement;
00106       boost::signal<void (Category *)> __newCategory;
00107       boost::signal<void (Plugin::InstallerInterface *)> __newInstaller;
00108 
00109     public :     
00110       friend class Store;
00111       ~PackageSystem ();
00117       static boost::shared_ptr<PackageSystem> create(const std::string & userName);
00118       
00123       Element * getElement (const std::string & elementName)
00124         throw (UnknownElementException);
00125 
00129       const std::list<Element *> & getElements ();
00130 
00135       Category * getCategory (const std::string & categoryName)
00136         throw (UnknownCategoryException);
00137 
00141       const std::list<Category *> & getCategorys ();
00142 
00147       void removeSet (const std::string & name)
00148         throw (UnknownElementException);
00149 
00154       void add (Element * package)
00155         throw (Util::NullPointerException,
00156                AlreadyExistingSetException);
00157       
00162       void add (Category * category)
00163         throw (Util::NullPointerException,
00164                AlreadyExistingCategoryException);
00165 
00170       void removeCategory (const std::string & name)
00171         throw (UnknownCategoryException);
00172 
00179       Plugin::InstallerInterface * install (const std::string url,
00180                                             std::map<std::string,
00181                                             std::string> installerOptions)
00182         throw (AlreadyExistingBranchException,
00183                Plugin::NoPluginHandlerException,
00184                UnknownCategoryException,
00185                UnknownSetException,
00186                UnknownElementException,
00187                UnknownBranchException,
00188                NoRightException);
00189 
00195       void uninstall (const std::string & elementName,
00196                       const std::string & branchName = "")
00197         throw (UnknownElementException);
00198 
00204       Branch * getBranchOfFile (const std::string & file)
00205         throw (FileNotFoundException);
00206 
00211       void checkDependency (const std::string & elementName)
00212         throw (DependencyException);
00213       
00214       boost::signal<void (Element *)> & signalNewElement ();
00215       boost::signal<void (Category *)> & signalNewCategory ();
00216       boost::signal<void (Plugin::InstallerInterface *)> & signalNewInstaller ();
00217       
00218       inline const std::string & user ()
00219       {
00220         return __user;
00221       }
00222 
00223       inline const std::string & user () const
00224       {
00225         return __user;
00226       }
00227     };
00228 
00232     typedef struct isInDependency : public std::binary_function<Element *, std::string, bool>
00233     {
00234       bool operator() (Element * element,
00235                        const std::string & categoryName) const;
00236     };
00240   }
00241 }
00242 #endif

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