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
00047 namespace zypp
00048 {
00049
00050 namespace sat
00051 {
00052 class Transaction;
00053 }
00054
00056 namespace solver
00057 {
00058
00059 namespace detail
00060 {
00061
00062
00064
00065
00071 class SATResolver : public base::ReferenceCounted, private base::NonCopyable {
00072
00073 private:
00074 ResPool _pool;
00075 Pool *_SATPool;
00076 Solver *_solv;
00077 Queue _jobQueue;
00078
00079
00080 PoolItemList _problem_items;
00081
00082
00083 PoolItemList _items_to_install;
00084 PoolItemList _items_to_remove;
00085 PoolItemList _items_to_lock;
00086 PoolItemList _items_to_keep;
00087
00088
00089 PoolItemList _result_items_to_install;
00090 PoolItemList _result_items_to_remove;
00091
00092 bool _fixsystem;
00093 bool _allowdowngrade;
00094 bool _allowarchchange;
00095 bool _allowvendorchange;
00096 bool _allowuninstall;
00097 bool _updatesystem;
00098 bool _noupdateprovide;
00099 bool _dosplitprovides;
00100 bool _onlyRequires;
00101 bool _ignorealreadyrecommended;
00102 bool _distupgrade;
00103 bool _distupgrade_removeunsupported;
00104 bool _solveSrcPackages;
00105 bool _cleandepsOnRemove;
00106
00107
00108 std::string SATprobleminfoString (Id problem, std::string &detail, Id &ignoreId);
00109 void resetItemTransaction (PoolItem item);
00110
00111
00112 void solverInit(const PoolItemList & weakItems);
00113
00114 bool solving(const CapabilitySet & requires_caps = CapabilitySet(),
00115 const CapabilitySet & conflict_caps = CapabilitySet());
00116
00117 void solverEnd();
00118
00119 void setLocks();
00120
00121 void setSystemRequirements();
00122
00123
00124
00125
00126
00127
00128
00129 sat::Solvable mapSolvable (const Id &id);
00130 PoolItem mapItem (const PoolItem &item);
00131
00132 public:
00133
00134 SATResolver (const ResPool & pool, Pool *SATPool);
00135 virtual ~SATResolver();
00136
00137
00138
00139 virtual std::ostream & dumpOn( std::ostream & str ) const;
00140 friend std::ostream& operator<<(std::ostream& str, const SATResolver & obj)
00141 { return obj.dumpOn (str); }
00142
00143 ResPool pool (void) const;
00144 void setPool (const ResPool & pool) { _pool = pool; }
00145
00146
00147 bool resolvePool(const CapabilitySet & requires_caps,
00148 const CapabilitySet & conflict_caps,
00149 const PoolItemList & weakItems,
00150 const std::set<Repository> & upgradeRepos
00151 );
00152
00153 bool resolveQueue(const SolverQueueItemList &requestQueue,
00154 const PoolItemList & weakItems
00155 );
00156
00157 void doUpdate();
00158
00159 ResolverProblemList problems ();
00160 void applySolutions (const ProblemSolutionList &solutions);
00161
00162
00163 sat::Transaction getTransaction();
00164
00165 void addPoolItemToInstall (PoolItem item);
00166 void addPoolItemsToInstallFromList (PoolItemList & rl);
00167
00168 void addPoolItemToLock (PoolItem item);
00169 void addPoolItemToKeep (PoolItem item);
00170
00171 void addPoolItemToRemove (PoolItem item);
00172 void addPoolItemsToRemoveFromList (PoolItemList & rl);
00173
00174 bool fixsystem () const {return _fixsystem;}
00175 void setFixsystem ( const bool fixsystem) { _fixsystem = fixsystem;}
00176
00177 bool ignorealreadyrecommended () const {return _ignorealreadyrecommended;}
00178 void setIgnorealreadyrecommended ( const bool ignorealreadyrecommended) { _ignorealreadyrecommended = ignorealreadyrecommended;}
00179
00180 bool distupgrade () const {return _distupgrade;}
00181 void setDistupgrade ( const bool distupgrade) { _distupgrade = distupgrade;}
00182
00183 bool distupgrade_removeunsupported () const {return _distupgrade_removeunsupported;}
00184 void setDistupgrade_removeunsupported ( const bool distupgrade_removeunsupported) { _distupgrade_removeunsupported = distupgrade_removeunsupported;}
00185
00186 bool allowdowngrade () const {return _allowdowngrade;}
00187 void setAllowdowngrade ( const bool allowdowngrade) { _allowdowngrade = allowdowngrade;}
00188
00189 bool allowarchchange () const {return _allowarchchange;}
00190 void setAllowarchchange ( const bool allowarchchange) { _allowarchchange = allowarchchange;}
00191
00192 bool allowvendorchange () const {return _allowvendorchange;}
00193 void setAllowvendorchange ( const bool allowvendorchange) { _allowvendorchange = allowvendorchange;}
00194
00195 bool allowuninstall () const {return _allowuninstall;}
00196 void setAllowuninstall ( const bool allowuninstall) { _allowuninstall = allowuninstall;}
00197
00198 bool updatesystem () const {return _updatesystem;}
00199 void setUpdatesystem ( const bool updatesystem) { _updatesystem = updatesystem;}
00200
00201 bool noupdateprovide () const {return _noupdateprovide;}
00202 void setNoupdateprovide ( const bool noupdateprovide) { _noupdateprovide = noupdateprovide;}
00203
00204 bool dosplitprovides () const {return _dosplitprovides;}
00205 void setDosplitprovides ( const bool dosplitprovides) { _dosplitprovides = dosplitprovides;}
00206
00207 bool onlyRequires () const {return _onlyRequires;}
00208 void setOnlyRequires ( const bool onlyRequires) { _onlyRequires = onlyRequires;}
00209
00210 bool solveSrcPackages() const { return _solveSrcPackages; }
00211 void setSolveSrcPackages( bool state_r ) { _solveSrcPackages = state_r; }
00212
00213 bool cleandepsOnRemove() const { return _cleandepsOnRemove; }
00214 void setCleandepsOnRemove( bool state_r ) { _cleandepsOnRemove = state_r; }
00215
00216 PoolItemList problematicUpdateItems( void ) const { return _problem_items; }
00217
00218 PoolItemList resultItemsToInstall () { return _result_items_to_install; }
00219 PoolItemList resultItemsToRemove () { return _result_items_to_remove; }
00220 PoolItemList problematicUpdateItems() { return _problem_items; }
00221
00222 };
00223
00225 };
00228 };
00231 };
00233
00234 #endif // ZYPP_SOLVER_DETAIL_SAT_RESOLVER_H