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_RESOLVER_H
00023 #define ZYPP_SOLVER_DETAIL_RESOLVER_H
00024
00025 #include <iosfwd>
00026 #include <list>
00027 #include <map>
00028 #include <string>
00029
00030 #include "zypp/base/ReferenceCounted.h"
00031 #include "zypp/base/PtrTypes.h"
00032
00033 #include "zypp/ResPool.h"
00034
00035 #include "zypp/solver/detail/Types.h"
00036 #include "zypp/solver/detail/ResolverQueue.h"
00037 #include "zypp/solver/detail/ResolverContext.h"
00038
00039 #include "zypp/ProblemTypes.h"
00040 #include "zypp/ResolverProblem.h"
00041 #include "zypp/ProblemSolution.h"
00042 #include "zypp/UpgradeStatistics.h"
00043
00044 #include "zypp/CapSet.h"
00045
00046
00048 namespace zypp
00049 {
00050
00051 namespace solver
00052 {
00053
00054 namespace detail
00055 {
00056
00058
00059
00060
00061 class Resolver : public base::ReferenceCounted, private base::NonCopyable {
00062
00063 private:
00064 ResPool _pool;
00065
00066 unsigned _timeout_seconds;
00067 unsigned _maxSolverPasses;
00068 bool _verifying;
00069 bool _testing;
00070
00071
00072
00073
00074
00075
00076 bool _tryAllPossibilities;
00077 bool _skippedPossibilities;
00078
00079
00080
00081 QueueItemList _initial_items;
00082 PoolItemList _items_to_install;
00083 PoolItemList _items_to_establish;
00084 PoolItemList _items_to_remove;
00085 PoolItemList _items_to_verify;
00086
00087
00088 PoolItemList _update_items;
00089
00090
00091 CapSet _extra_caps;
00092 CapSet _extra_conflicts;
00093
00094
00095
00096
00097 IgnoreMap _ignoreConflicts;
00098
00099 IgnoreMap _ignoreRequires;
00100
00101 IgnoreMap _ignoreObsoletes;
00102
00103 PoolItemList _ignoreArchitecture;
00104
00105 PoolItemList _ignoreInstalledItem;
00106
00107 PoolItemList _ignoreArchitectureItem;
00108
00109
00110 ResolverQueueList _pending_queues;
00111 ResolverQueueList _pruned_queues;
00112 ResolverQueueList _complete_queues;
00113 ResolverQueueList _deferred_queues;
00114 ResolverQueueList _invalid_queues;
00115
00116 int _valid_solution_count;
00117
00118 ResolverContext_Ptr _best_context;
00119
00120 ResolverContext_Ptr _establish_context;
00121 bool _timed_out;
00122
00123 std::set<Source_Ref> _subscribed;
00124
00125 Arch _architecture;
00126
00127 bool _forceResolve;
00128
00129
00130 bool _upgradeMode;
00131 bool _preferHighestVersion;
00132
00133
00134
00135 bool doesObsoleteCapability (PoolItem_Ref candidate, const Capability & cap);
00136 bool doesObsoleteItem (PoolItem_Ref candidate, PoolItem_Ref installed);
00137
00138 public:
00139
00140 Resolver (const ResPool & pool);
00141 virtual ~Resolver();
00142
00143
00144
00145 virtual std::ostream & dumpOn( std::ostream & str ) const;
00146 friend std::ostream& operator<<(std::ostream& str, const Resolver & obj)
00147 { return obj.dumpOn (str); }
00148
00149
00150
00151 QueueItemList initialItems () const { return _initial_items; }
00152
00153 ResolverQueueList pendingQueues () const { return _pending_queues; }
00154 ResolverQueueList prunedQueues () const { return _pruned_queues; }
00155 ResolverQueueList completeQueues () const { return _complete_queues; }
00156 ResolverQueueList deferredQueues () const { return _deferred_queues; }
00157 ResolverQueueList invalidQueues () const { return _invalid_queues; }
00158
00159 ResolverContext_Ptr bestContext (void) const { return _best_context; }
00160
00163 ResolverContext_Ptr context (void) const;
00164
00165
00166
00167 void setTimeout (int seconds) { _timeout_seconds = seconds; }
00168 void setMaxSolverPasses (int count) { _maxSolverPasses = count; }
00169 int timeout () { return _timeout_seconds; }
00170 int maxSolverPasses () { return _maxSolverPasses; }
00171
00172 ResPool pool (void) const;
00173 void setPool (const ResPool & pool) { _pool = pool; }
00174
00175 void addSubscribedSource (Source_Ref source);
00176
00177 void addPoolItemToInstall (PoolItem_Ref item);
00178 void addPoolItemsToInstallFromList (PoolItemList & rl);
00179
00180 void addPoolItemToRemove (PoolItem_Ref item);
00181 void addPoolItemsToRemoveFromList (PoolItemList & rl);
00182
00183 void addPoolItemToEstablish (PoolItem_Ref item);
00184 void addPoolItemsToEstablishFromList (PoolItemList & rl);
00185
00186 void addPoolItemToVerify (PoolItem_Ref item);
00187
00188 void addExtraCapability (const Capability & capability);
00189 void addExtraConflict (const Capability & capability);
00190
00191 void addIgnoreConflict (const PoolItem_Ref item,
00192 const Capability & capability);
00193 void addIgnoreRequires (const PoolItem_Ref item,
00194 const Capability & capability);
00195 void addIgnoreObsoletes (const PoolItem_Ref item,
00196 const Capability & capability);
00197 void addIgnoreInstalledItem (const PoolItem_Ref item);
00198 void addIgnoreArchitectureItem (const PoolItem_Ref item);
00199
00200 void setForceResolve (const bool force) { _forceResolve = force; }
00201 const bool forceResolve() { return _forceResolve; }
00202 void setPreferHighestVersion (const bool highestVersion) { _preferHighestVersion = highestVersion; }
00203 const bool preferHighestVersion() { return _preferHighestVersion; }
00204
00205 bool verifySystem (bool considerNewHardware = false);
00206 void establishState (ResolverContext_Ptr context = NULL);
00207 bool establishPool (void);
00208 void freshenState( ResolverContext_Ptr context = NULL, bool resetAfterSolve = true );
00209 bool freshenPool( bool resetAfterSolve = true );
00210 bool resolveDependencies (const ResolverContext_Ptr context = NULL);
00211 bool resolvePool( bool tryAllPossibilities = false );
00212
00213 bool transactResObject( ResObject::constPtr robj,
00214 bool install = true,
00215 bool recursive = false);
00216 bool transactResKind( Resolvable::Kind kind );
00217 void transactReset( ResStatus::TransactByValue causer );
00218
00219 void doUpgrade( zypp::UpgradeStatistics & opt_stats_r );
00220 PoolItemList problematicUpdateItems( void ) const { return _update_items; }
00221
00222
00223 ResolverProblemList problems (const bool ignoreValidSolution = false) const;
00224 void applySolutions (const ProblemSolutionList &solutions);
00225
00226 std::list<std::string> problemDescription( void ) const;
00227
00228
00229 void undo(void);
00230
00231
00232 void reset (void);
00233
00234 Arch architecture() const { return _architecture; }
00235 void setArchitecture( const Arch & arch) { _architecture = arch; }
00236
00237 bool testing(void) const { return _testing; }
00238 void setTesting( bool testing ) { _testing = testing; }
00239 };
00240
00242 };
00245 };
00248 };
00250
00251 #endif // ZYPP_SOLVER_DETAIL_RESOLVER_H