SATResolver.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef ZYPP_SOLVER_DETAIL_SAT_RESOLVER_H
00023 #define ZYPP_SOLVER_DETAIL_SAT_RESOLVER_H
00024
00025 extern "C"
00026 {
00027 #include <satsolver/solver.h>
00028 #include <satsolver/pool.h>
00029 }
00030
00031 #include <iosfwd>
00032 #include <list>
00033 #include <map>
00034 #include <string>
00035
00036 #include "zypp/base/ReferenceCounted.h"
00037 #include "zypp/base/PtrTypes.h"
00038 #include "zypp/ResPool.h"
00039 #include "zypp/base/SerialNumber.h"
00040 #include "zypp/ProblemTypes.h"
00041 #include "zypp/ResolverProblem.h"
00042 #include "zypp/ProblemSolution.h"
00043 #include "zypp/Capability.h"
00044 #include "zypp/solver/detail/SolverQueueItem.h"
00045
00046
00048 namespace zypp
00049 {
00050
00051 namespace solver
00052 {
00053
00054 namespace detail
00055 {
00056
00057
00059
00060
00066 class SATResolver : public base::ReferenceCounted, private base::NonCopyable {
00067
00068 private:
00069 ResPool _pool;
00070 Pool *_SATPool;
00071 Solver *_solv;
00072 Queue _jobQueue;
00073
00074
00075 PoolItemList _problem_items;
00076
00077
00078 PoolItemList _items_to_install;
00079 PoolItemList _items_to_remove;
00080 PoolItemList _items_to_lock;
00081 PoolItemList _items_to_keep;
00082
00083
00084 PoolItemList _result_items_to_install;
00085 PoolItemList _result_items_to_remove;
00086
00087 bool _fixsystem;
00088 bool _allowdowngrade;
00089 bool _allowarchchange;
00090 bool _allowvendorchange;
00091 bool _allowuninstall;
00092 bool _updatesystem;
00093 bool _noupdateprovide;
00094 bool _dosplitprovides;
00095 bool _onlyRequires;
00096 bool _ignorealreadyrecommended;
00097 bool _distupgrade;
00098 bool _distupgrade_removeunsupported;
00099 bool _solveSrcPackages;
00100
00101
00102 std::string SATprobleminfoString (Id problem, std::string &detail, Id &ignoreId);
00103 void resetItemTransaction (PoolItem item);
00104
00105
00106 void solverInit(const PoolItemList & weakItems);
00107
00108 bool solving(const CapabilitySet & requires_caps = CapabilitySet(),
00109 const CapabilitySet & conflict_caps = CapabilitySet());
00110
00111 void solverEnd();
00112
00113 void setLocks();
00114
00115 void setSystemRequirements();
00116
00117
00118
00119
00120
00121
00122
00123 sat::Solvable mapSolvable (const Id &id);
00124 PoolItem mapItem (const PoolItem &item);
00125
00126 public:
00127
00128 SATResolver (const ResPool & pool, Pool *SATPool);
00129 virtual ~SATResolver();
00130
00131
00132
00133 virtual std::ostream & dumpOn( std::ostream & str ) const;
00134 friend std::ostream& operator<<(std::ostream& str, const SATResolver & obj)
00135 { return obj.dumpOn (str); }
00136
00137 ResPool pool (void) const;
00138 void setPool (const ResPool & pool) { _pool = pool; }
00139
00140
00141 bool resolvePool(const CapabilitySet & requires_caps,
00142 const CapabilitySet & conflict_caps,
00143 const PoolItemList & weakItems,
00144 const std::set<Repository> & upgradeRepos
00145 );
00146
00147 bool resolveQueue(const SolverQueueItemList &requestQueue,
00148 const PoolItemList & weakItems
00149 );
00150
00151 void doUpdate();
00152
00153 ResolverProblemList problems ();
00154 void applySolutions (const ProblemSolutionList &solutions);
00155
00156 void addPoolItemToInstall (PoolItem item);
00157 void addPoolItemsToInstallFromList (PoolItemList & rl);
00158
00159 void addPoolItemToLock (PoolItem item);
00160 void addPoolItemToKeep (PoolItem item);
00161
00162 void addPoolItemToRemove (PoolItem item);
00163 void addPoolItemsToRemoveFromList (PoolItemList & rl);
00164
00165 bool fixsystem () const {return _fixsystem;}
00166 void setFixsystem ( const bool fixsystem) { _fixsystem = fixsystem;}
00167
00168 bool ignorealreadyrecommended () const {return _ignorealreadyrecommended;}
00169 void setIgnorealreadyrecommended ( const bool ignorealreadyrecommended) { _ignorealreadyrecommended = ignorealreadyrecommended;}
00170
00171 bool distupgrade () const {return _distupgrade;}
00172 void setDistupgrade ( const bool distupgrade) { _distupgrade = distupgrade;}
00173
00174 bool distupgrade_removeunsupported () const {return _distupgrade_removeunsupported;}
00175 void setDistupgrade_removeunsupported ( const bool distupgrade_removeunsupported) { _distupgrade_removeunsupported = distupgrade_removeunsupported;}
00176
00177 bool allowdowngrade () const {return _allowdowngrade;}
00178 void setAllowdowngrade ( const bool allowdowngrade) { _allowdowngrade = allowdowngrade;}
00179
00180 bool allowarchchange () const {return _allowarchchange;}
00181 void setAllowarchchange ( const bool allowarchchange) { _allowarchchange = allowarchchange;}
00182
00183 bool allowvendorchange () const {return _allowvendorchange;}
00184 void setAllowvendorchange ( const bool allowvendorchange) { _allowvendorchange = allowvendorchange;}
00185
00186 bool allowuninstall () const {return _allowuninstall;}
00187 void setAllowuninstall ( const bool allowuninstall) { _allowuninstall = allowuninstall;}
00188
00189 bool updatesystem () const {return _updatesystem;}
00190 void setUpdatesystem ( const bool updatesystem) { _updatesystem = updatesystem;}
00191
00192 bool noupdateprovide () const {return _noupdateprovide;}
00193 void setNoupdateprovide ( const bool noupdateprovide) { _noupdateprovide = noupdateprovide;}
00194
00195 bool dosplitprovides () const {return _dosplitprovides;}
00196 void setDosplitprovides ( const bool dosplitprovides) { _dosplitprovides = dosplitprovides;}
00197
00198 bool onlyRequires () const {return _onlyRequires;}
00199 void setOnlyRequires ( const bool onlyRequires) { _onlyRequires = onlyRequires;}
00200
00201 bool solveSrcPackages() const { return _solveSrcPackages; }
00202 void setSolveSrcPackages( bool state_r ) { _solveSrcPackages = state_r; }
00203
00204 PoolItemList problematicUpdateItems( void ) const { return _problem_items; }
00205
00206 PoolItemList resultItemsToInstall () { return _result_items_to_install; }
00207 PoolItemList resultItemsToRemove () { return _result_items_to_remove; }
00208 PoolItemList problematicUpdateItems() { return _problem_items; }
00209
00210 };
00211
00213 };
00216 };
00219 };
00221
00222 #endif // ZYPP_SOLVER_DETAIL_SAT_RESOLVER_H