Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

PMManager.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                                                                      |
00003 |                      __   __    ____ _____ ____                      |
00004 |                      \ \ / /_ _/ ___|_   _|___ \                     |
00005 |                       \ V / _` \___ \ | |   __) |                    |
00006 |                        | | (_| |___) || |  / __/                     |
00007 |                        |_|\__,_|____/ |_| |_____|                    |
00008 |                                                                      |
00009 |                               core system                            |
00010 |                                                        (C) SuSE GmbH |
00011 \----------------------------------------------------------------------/
00012 
00013    File:       PMManager.h
00014 
00015    Author:     Michael Andres <ma@suse.de>
00016    Maintainer: Michael Andres <ma@suse.de>
00017 
00018 /-*/
00019 #ifndef PMManager_h
00020 #define PMManager_h
00021 
00022 #include <iosfwd>
00023 #include <set>
00024 #include <map>
00025 #include <list>
00026 
00027 #include <y2util/Pathname.h>
00028 
00029 #include <y2pm/PMObject.h>
00030 #include <y2pm/PMSelectable.h>
00031 #include <y2pm/PMObjectContainerIter.h>
00032 
00033 #include <y2pm/PkgDep.h>
00034 #include <y2pm/PkgSet.h>
00035 
00037 //
00038 //      CLASS NAME : PMManager
00042 class PMManager {
00043 
00044   friend std::ostream & operator<<( std::ostream & str, const PMManager & obj );
00045 
00046   PMManager & operator=( const PMManager & );
00047   PMManager            ( const PMManager & );
00048 
00049   public:
00050 
00051     typedef std::set<PMSelectablePtr>  PMSelectableVec;
00052 
00053   private:
00054 
00055     typedef std::map<std::string,PMSelectablePtr> PMSelectablePool;
00056 
00057     PMSelectablePool _itemPool;
00058     PMSelectableVec _items;
00059 
00060     PkgSet* installed;
00061     PkgSet* available;
00062     PkgSet* toinstall;
00063     PkgSet* nowinstalled;
00064 
00065     void invalidateSolverSets();
00066 
00067   private:
00068 
00069     typedef std::list<PMSelectable::SavedState> SavedList;
00070 
00071     SavedList _savedList;
00072 
00073   public:
00074 
00078     virtual void SaveState();
00079 
00083     virtual bool RestoreState();
00084 
00088     virtual bool DiffState() const;
00089 
00093     virtual void ClearSaveState();
00094 
00095   private:
00096 
00101     virtual PMObjectPtr assertObjectType( const PMObjectPtr & object_r ) const = 0;
00102 
00108     virtual PMSelectablePtr newSelectable( const PkgName & name_r ) const;
00109 
00113     virtual void prePSI() {;}
00117     virtual void postPSI() {;}
00121     virtual void prePAC() {;}
00125     virtual void postPAC() {;}
00129     virtual void prePRC() {;}
00133     virtual void postPRC() {;}
00134 
00135   private:
00136 
00140     PMSelectablePtr poolLookup( const std::string & name_r ) const;
00141 
00145     PMSelectablePtr poolProvide( const std::string & name_r );
00146 
00153     void poolAdjust();
00154 
00155     void clearAll();
00156 
00157     void checkPool() const;
00158 
00159   public:
00160 
00161     PMManager();
00162     virtual ~PMManager();
00163 
00164   public:
00165 
00169     void poolSetInstalled( PMObjectContainerIter iter_r );
00170 
00174     void poolAddCandidates( PMObjectContainerIter iter_r );
00175 
00179     void poolRemoveCandidates( PMObjectContainerIter iter_r );
00180 
00185     void poolSortCandidates();
00186 
00187   public:
00188 
00192     unsigned size() const { return _items.size(); }
00193 
00197     bool empty() const { return _items.empty(); }
00198 
00202     PMSelectableVec::const_iterator begin() const { return _items.begin(); }
00203 
00207     PMSelectableVec::const_iterator end() const { return _items.end(); }
00208 
00212     PMSelectableVec::const_reverse_iterator rbegin() const { return _items.rbegin(); }
00213 
00217     PMSelectableVec::const_reverse_iterator rend() const { return _items.rend(); }
00218 
00222     PMSelectablePtr getItem( const std::string & name_t ) const { return poolLookup( name_t ); }
00223 
00227     PMSelectablePtr operator [] ( const std::string & name_r ) const { return getItem( name_r ); }
00228 
00229   public:
00230 
00234     void setNothingSelected();
00235 
00236   public:
00237 
00244     bool anyMatch( PMSelectable::Test_method fnc_r ) const;
00245 
00252     bool anyMatch( PMSelectable::Test_fnc fnc_r ) const;
00253 
00257     bool anythingByUser() const { return anyMatch( &PMSelectable::by_user ); }
00258 
00262     bool anythingToDelete() const { return anyMatch( &PMSelectable::to_delete ); }
00263 
00267     bool anythingToInstall() const { return anyMatch( &PMSelectable::to_install ); }
00268 
00269   public:
00270     // solver Part
00271 
00283     bool solveInstall(PkgDep::ResultList& good, PkgDep::ErrorResultList& bad, bool filter_conflicts_with_installed = false);
00284 
00298     //bool solveUpgrade(PkgDep::ResultList& good, PkgDep::ErrorResultList& bad, PkgDep::SolvableList &to_remove);
00299 
00300 
00301 //    bool solveEverythingRight(PkgDep::ResultList& good, PkgDep::ErrorResultList& bad, PkgDep::SolvableList &to_remove);
00302 
00308     bool solveConsistent(PkgDep::ErrorResultList& bad);
00309 
00314     //void setMaxRemoveThreshold(unsigned nr);
00315 
00316   private:
00317 
00318     void buildSets(PkgSet& installed, PkgSet& available, PkgSet& to_install);
00319 
00320   public:
00321 
00325     virtual void writeSettings();
00326 
00330     virtual void readSettings();
00331 
00332   protected:
00333 
00339     virtual Pathname settingsFile() const { return Pathname(); }
00340 };
00341 
00343 
00344 #endif // PMManager_h

Generated on Fri Nov 9 14:30:31 2007 for yast2-packagemanager by doxygen 1.3.6