packageManager.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/pluginManager.h>
00035 #include <util/utilException.h>
00036 #include <core/store.h>
00037 #include <boost/thread/recursive_mutex.hpp>
00038 #include <core/filesystemManager.h>
00039 #include "uninstallation.h"
00040 #include "installation.h"
00041 
00042 namespace Spm
00043 {
00044   namespace Core
00045   {
00046     class PackageManager : public boost::noncopyable
00047     {
00051     public :
00052       struct objectModified : public std::binary_function<Util::Object *,
00053                                                           miniXml::ustring,
00054                                                           void>
00055       {
00056         void operator () (Util::Object * object,
00057                           const miniXml::ustring & user) const;
00058       };
00059 
00060     private :
00061       struct endInstallation : public std::binary_function<Action*, 
00062                                                            miniXml::ustring, 
00063                                                            void>
00064       {
00065         void operator () (Action * interface,
00066                           const miniXml::ustring & user) const;
00067       };
00068 
00069       struct endUpdate : public std::binary_function<Action *,
00070                                                      InstalledVersion *,
00071                                                      void>
00072       {
00073         void operator () (Action * interface,
00074                           InstalledVersion * version) const;
00075       };
00076 
00077       struct endRemoteInstallation : public std::binary_function<Action *,
00078                                                                  miniXml::ustring,
00079                                                                  void>
00080       {
00081         void operator () (Action * interface,
00082                           const miniXml::ustring & user) const;
00083       };
00084 
00085       struct endUninstallation : public std::binary_function<Action *,
00086                                                              miniXml::ustring,
00087                                                              void>
00088       {
00089         void operator() (Action * uninstallation,
00090                          const miniXml::ustring & user) const;
00091       };
00092       
00096       PackageManager(const miniXml::ustring & userName);
00097       ElementStore * elementStore_;
00098       CategoryStore * categoryStore_;
00099       
00100       std::list<Category *> categorys_;
00101       std::list<Element *> elements_;
00102       boost::recursive_mutex categorysMutex_;
00103       boost::recursive_mutex elementsMutex_;
00104       miniXml::ustring user_;
00105       miniXml::ustring checkInstallOptions (const Util::PropertyList & pOptions);
00106       boost::shared_ptr<PackageManager> systemPackageManager_;
00107       boost::shared_ptr<Plugin::PluginManager> userPluginManager_;
00108       boost::shared_ptr<FileSystemManager> fileSystemManager_;
00109       boost::shared_ptr<DependencyManager> dependencyManager_;
00110       InstalledVersion * checkPackageToInstall (Plugin::InstallerInterface * installer,
00111                                                 const miniXml::ustring & prefix);
00112       static std::map<miniXml::ustring,
00113                       boost::shared_ptr<PackageManager> > instances_;
00114       boost::signal<void (Element *)> newElement_;
00115       boost::signal<void (Category *)> newCategory_;
00116       boost::signal<void (Plugin::InstallerInterface *)> newInstaller_;
00117       void _add(Package * p,
00118                 InstalledVersion * iv)
00119       {
00120         p->add (iv);
00121       }
00122       
00123       void remove (Element * element);
00124       void remove (Branch * branch);
00125       //void onInstallerHaveOptions(Plugin::InstallerInterface * plugin);
00126       void onInstallerHaveOptions(Installation * installer);
00127 
00128       void checkDependency (const Branch * branch);
00129       void checkDependency (const InstalledVersion * version);
00134       void checkDependency (const Element * package);
00135       
00140       void checkDependency (const Versionned * branch);
00141       
00142     public :     
00143       friend class ElementStore;
00144       friend class CategoryStore;
00145       ~PackageManager ();
00151       static boost::shared_ptr<PackageManager> & create(const miniXml::ustring & userName);
00152       
00157       Element * getElement (const miniXml::ustring & elementName);
00158 
00162       const std::list<Element *> & getElements ();
00163 
00168       Category * getCategory (const miniXml::ustring & categoryName);
00169 
00173       const std::list<Category *> & getCategorys ();
00174 
00179       void removeSet (const miniXml::ustring & name);
00180 
00185       void add (Element * package);
00186       
00191       void add (Category * category);
00192 
00197       void removeCategory (const miniXml::ustring & name);
00198 
00204       Installation * install (const miniXml::ustring & uri,
00205                               const Util::PropertyList & pList = Util::PropertyList());
00206 
00214       Uninstallation * uninstall (const miniXml::ustring & elementName,
00215                                   const miniXml::ustring & branchName = "",
00216                                   bool noDependencyCheck = false);
00217 
00223       std::list<InstalledVersion *> getElementOfFile (const miniXml::ustring & file);
00224       
00228       boost::signal<void (Element *)> & signalNewElement ();
00229 
00233       boost::signal<void (Category *)> & signalNewCategory ();
00234 
00238       boost::signal<void (Plugin::InstallerInterface *)> & signalNewInstaller ();
00239       
00240       inline const miniXml::ustring & user ()
00241       {
00242         return user_;
00243       }
00244 
00245       inline const miniXml::ustring & user () const
00246       {
00247         return user_;
00248       }
00249     };
00250   }
00251 }
00252 #endif

Generated on Sat Mar 21 17:00:14 2009 for libSpm by  doxygen 1.5.2