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 bool _cleandepsOnRemove;
00101
00102
00103 std::string SATprobleminfoString (Id problem, std::string &detail, Id &ignoreId);
00104 void resetItemTransaction (PoolItem item);
00105
00106
00107 void solverInit(const PoolItemList & weakItems);
00108
00109 bool solving(const CapabilitySet & requires_caps = CapabilitySet(),
00110 const CapabilitySet & conflict_caps = CapabilitySet());
00111
00112 void solverEnd();
00113
00114 void setLocks();
00115
00116 void setSystemRequirements();
00117
00118
00119
00120
00121
00122
00123
00124 sat::Solvable mapSolvable (const Id &id);
00125 PoolItem mapItem (const PoolItem &item);
00126
00127 public:
00128
00129 SATResolver (const ResPool & pool, Pool *SATPool);
00130 virtual ~SATResolver();
00131
00132
00133
00134 virtual std::ostream & dumpOn( std::ostream & str ) const;
00135 friend std::ostream& operator<<(std::ostream& str, const SATResolver & obj)
00136 { return obj.dumpOn (str); }
00137
00138 ResPool pool (void) const;
00139 void setPool (const ResPool & pool) { _pool = pool; }
00140
00141
00142 bool resolvePool(const CapabilitySet & requires_caps,
00143 const CapabilitySet & conflict_caps,
00144 const PoolItemList & weakItems,
00145 const std::set<Repository> & upgradeRepos
00146 );
00147
00148 bool resolveQueue(const SolverQueueItemList &requestQueue,
00149 const PoolItemList & weakItems
00150 );
00151
00152 void doUpdate();
00153
00154 ResolverProblemList problems ();
00155 void applySolutions (const ProblemSolutionList &solutions);
00156
00157 void addPoolItemToInstall (PoolItem item);
00158 void addPoolItemsToInstallFromList (PoolItemList & rl);
00159
00160 void addPoolItemToLock (PoolItem item);
00161 void addPoolItemToKeep (PoolItem item);
00162
00163 void addPoolItemToRemove (PoolItem item);
00164 void addPoolItemsToRemoveFromList (PoolItemList & rl);
00165
00166 bool fixsystem () const {return _fixsystem;}
00167 void setFixsystem ( const bool fixsystem) { _fixsystem = fixsystem;}
00168
00169 bool ignorealreadyrecommended () const {return _ignorealreadyrecommended;}
00170 void setIgnorealreadyrecommended ( const bool ignorealreadyrecommended) { _ignorealreadyrecommended = ignorealreadyrecommended;}
00171
00172 bool distupgrade () const {return _distupgrade;}
00173 void setDistupgrade ( const bool distupgrade) { _distupgrade = distupgrade;}
00174
00175 bool distupgrade_removeunsupported () const {return _distupgrade_removeunsupported;}
00176 void setDistupgrade_removeunsupported ( const bool distupgrade_removeunsupported) { _distupgrade_removeunsupported = distupgrade_removeunsupported;}
00177
00178 bool allowdowngrade () const {return _allowdowngrade;}
00179 void setAllowdowngrade ( const bool allowdowngrade) { _allowdowngrade = allowdowngrade;}
00180
00181 bool allowarchchange () const {return _allowarchchange;}
00182 void setAllowarchchange ( const bool allowarchchange) { _allowarchchange = allowarchchange;}
00183
00184 bool allowvendorchange () const {return _allowvendorchange;}
00185 void setAllowvendorchange ( const bool allowvendorchange) { _allowvendorchange = allowvendorchange;}
00186
00187 bool allowuninstall () const {return _allowuninstall;}
00188 void setAllowuninstall ( const bool allowuninstall) { _allowuninstall = allowuninstall;}
00189
00190 bool updatesystem () const {return _updatesystem;}
00191 void setUpdatesystem ( const bool updatesystem) { _updatesystem = updatesystem;}
00192
00193 bool noupdateprovide () const {return _noupdateprovide;}
00194 void setNoupdateprovide ( const bool noupdateprovide) { _noupdateprovide = noupdateprovide;}
00195
00196 bool dosplitprovides () const {return _dosplitprovides;}
00197 void setDosplitprovides ( const bool dosplitprovides) { _dosplitprovides = dosplitprovides;}
00198
00199 bool onlyRequires () const {return _onlyRequires;}
00200 void setOnlyRequires ( const bool onlyRequires) { _onlyRequires = onlyRequires;}
00201
00202 bool solveSrcPackages() const { return _solveSrcPackages; }
00203 void setSolveSrcPackages( bool state_r ) { _solveSrcPackages = state_r; }
00204
00205 bool cleandepsOnRemove() const { return _cleandepsOnRemove; }
00206 void setCleandepsOnRemove( bool state_r ) { _cleandepsOnRemove = state_r; }
00207
00208 PoolItemList problematicUpdateItems( void ) const { return _problem_items; }
00209
00210 PoolItemList resultItemsToInstall () { return _result_items_to_install; }
00211 PoolItemList resultItemsToRemove () { return _result_items_to_remove; }
00212 PoolItemList problematicUpdateItems() { return _problem_items; }
00213
00214 };
00215
00217 };
00220 };
00223 };
00225
00226 #endif // ZYPP_SOLVER_DETAIL_SAT_RESOLVER_H