00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef ZYPP_SOLVER_DETAIL_RESOLVERCONTEXT_H
00027 #define ZYPP_SOLVER_DETAIL_RESOLVERCONTEXT_H
00028
00029 #include "zypp/ResPool.h"
00030 #include "zypp/PoolItem.h"
00031 #include "zypp/Capability.h"
00032 #include "zypp/Repository.h"
00033
00034 #include "zypp/solver/detail/Types.h"
00035 #include "zypp/solver/detail/ResolverInfo.h"
00036
00038 namespace zypp
00039 {
00040
00041 namespace solver
00042 {
00043
00044 namespace detail
00045 {
00046
00047 typedef void (*ResolverContextFn) (ResolverContext_Ptr ctx, void *data);
00048 typedef void (*MarkedPoolItemFn) (PoolItem_Ref item, const ResStatus & status, void *data);
00049 typedef void (*MarkedPoolItemPairFn) (PoolItem_Ref item1, const ResStatus & status1, PoolItem_Ref item2, const ResStatus & status2, void *data);
00050 typedef std::multimap<PoolItem_Ref,Capability> IgnoreMap;
00051 typedef std::map<Repository ,int> RepositoryCounter;
00052
00054
00055
00056 class ResolverContext : public base::ReferenceCounted, private base::NonCopyable {
00057
00058
00059 private:
00060
00061 ResolverContext_Ptr _parent;
00062 ResolverContext_Ptr _establish_context;
00063
00064 typedef std::map<PoolItem_Ref,ResStatus> Context;
00065 Context _context;
00066
00067 ResPool _pool;
00068
00069 ResolverInfoList _log;
00070
00071 unsigned long long _download_size;
00072 unsigned long long _install_size;
00073 int _total_priority;
00074 int _min_priority;
00075 int _max_priority;
00076 int _other_penalties;
00077
00078 bool _verifying;
00079 bool _establishing;
00080 bool _invalid;
00081 bool _askUser;
00082
00083 PoolItem_Ref _last_checked_item;
00084 ResStatus _last_checked_status;
00085
00086 PoolItemList _last_getMarked;
00087
00088 int _last_getMarked_which;
00089
00090 Arch _architecture;
00091
00092
00093 IgnoreMap _ignoreConflicts;
00094
00095 IgnoreMap _ignoreRequires;
00096
00097 IgnoreMap _ignoreObsoletes;
00098
00099 PoolItemList _ignoreInstalledItem;
00100
00101 PoolItemList _ignoreArchitectureItem;
00102
00103 PoolItemList _ignoreVendorItem;
00104
00105
00106
00107
00108 PoolItemList _userDeleteItems;
00109 PoolItemList _userInstallItems;
00110 PoolItemList _userLockUninstalledItems;
00111 PoolItemList _userKeepItems;
00112
00113 bool _forceResolve;
00114
00115
00116 bool _upgradeMode;
00117
00118 bool _preferHighestVersion;
00119
00120
00121
00122
00123
00124
00125
00126 bool _tryAllPossibilities;
00127 bool _skippedPossibilities;
00128
00129
00130 public:
00131 ResolverContext (const ResPool & pool, const Arch & arch, ResolverContext_Ptr parent = NULL);
00132 virtual ~ResolverContext();
00133
00134
00135
00136 friend std::ostream& operator<<(std::ostream&, const ResolverContext & context);
00137
00138
00139
00140 unsigned long long downloadSize(void) const { return _download_size; }
00141 unsigned long long installSize(void) const { return _install_size; }
00142 int totalPriority (void) const { return _total_priority; }
00143 int minPriority (void) const { return _min_priority; }
00144 int maxPriority (void) const { return _max_priority; }
00145 int otherPenalties (void) const { return _other_penalties; }
00146
00147 bool isValid (void) const { return !_invalid; }
00148 bool askUser (void) const { return _askUser; }
00149 bool isInvalid (void) const { return _invalid; }
00150
00151 bool verifying (void) const { return _verifying; }
00152 void setVerifying (bool verifying) { _verifying = verifying; }
00153
00154 bool tryAllPossibilities (void) const { return _tryAllPossibilities; }
00155 void setTryAllPossibilities (bool tryAllPossibilities) { _tryAllPossibilities = tryAllPossibilities; }
00156
00157 bool skippedPossibilities (void) const { return _skippedPossibilities; }
00158 void setSkippedPossibilities (bool skippedPossibilities) { _skippedPossibilities = skippedPossibilities; }
00159
00160 bool establishing (void) const { return _establishing; }
00161 void setEstablishing (bool establishing) { _establishing = establishing; }
00162
00163 inline ResPool pool() const { return _pool; }
00164
00165 inline Arch architecture() const { return _architecture; }
00166
00167
00168 void setIgnoreCababilities(const IgnoreMap ignoreConflicts,
00169 const IgnoreMap ignoreRequires,
00170 const IgnoreMap ignoreObsoletes,
00171 const PoolItemList ignoreInstalledItem,
00172 const PoolItemList ignoreArchitectureItem,
00173 const PoolItemList ignoreVendorItem)
00174 {_ignoreConflicts = ignoreConflicts;
00175 _ignoreRequires = ignoreRequires;
00176 _ignoreObsoletes = ignoreObsoletes;
00177 _ignoreInstalledItem = ignoreInstalledItem;
00178 _ignoreArchitectureItem = ignoreArchitectureItem;
00179 _ignoreVendorItem = ignoreVendorItem;
00180 }
00181
00182 const IgnoreMap getIgnoreConflicts() const { return _ignoreConflicts; }
00183 const IgnoreMap getIgnoreRequires() const { return _ignoreRequires; }
00184 const IgnoreMap getIgnoreObsoletes() const { return _ignoreObsoletes; }
00185 const PoolItemList getIgnoreInstalledItem() const { return _ignoreInstalledItem; }
00186 const PoolItemList getIgnoreArchitectureItem() const { return _ignoreArchitectureItem; }
00187 const PoolItemList getIgnoreVendorItem() const { return _ignoreVendorItem; }
00188
00189 void setForceResolve (const bool force) { _forceResolve = force; }
00190 const bool forceResolve() { return _forceResolve; }
00191
00192 void setEstablishContext (const ResolverContext_Ptr establish_context) { _establish_context = establish_context; }
00193
00194 void setPreferHighestVersion (const bool highestVersion) { _preferHighestVersion = highestVersion; }
00195 const bool preferHighestVersion() { return _preferHighestVersion; }
00196
00197 void setUpgradeMode (const bool upgrade) { _upgradeMode = upgrade; }
00198 const bool upgradeMode() { return _upgradeMode; }
00199
00200 void setUserDeleteItems ( const PoolItemList & deleteItems) { _userDeleteItems = deleteItems; }
00201 void setUserInstallItems ( const PoolItemList& installItems) { _userInstallItems = installItems; }
00202 void setUserLockUninstalledItems ( const PoolItemList& lockItems) { _userLockUninstalledItems = lockItems; }
00203 void setUserKeepItems ( const PoolItemList& keepItems) { _userKeepItems = keepItems; }
00204 PoolItemList userDeleteItems () { return _userDeleteItems; }
00205 PoolItemList userInstallItems () { return _userInstallItems; }
00206 PoolItemList userLockUninstalledItems () { return _userLockUninstalledItems; }
00207 PoolItemList userKeepItems () { return _userKeepItems; }
00208
00209
00210
00215 ResStatus getStatus (PoolItem_Ref item);
00216
00224 void setStatus (PoolItem_Ref item, const ResStatus & status);
00225
00228 bool install (PoolItem_Ref item, bool is_soft, int other_penalty);
00229
00232 bool satisfy (PoolItem_Ref item, int other_penalty);
00233
00236 bool unneeded (PoolItem_Ref item, int other_penalty);
00237
00240 bool incomplete (PoolItem_Ref item, int other_penalty);
00241
00245 bool upgrade (PoolItem_Ref to, PoolItem_Ref from, bool is_soft, int other_penalty);
00246
00249 bool uninstall (PoolItem_Ref item, bool part_of_upgrade, bool due_to_obsolete, bool due_to_unlink, bool explicitly_requested);
00250
00251
00252
00255 bool isPresent (PoolItem_Ref item, bool *unneeded = NULL,
00256 bool *installed = NULL);
00257
00260 bool isAbsent (PoolItem_Ref item);
00261
00262 bool requirementIsMet (const Capability & cap,
00263 const PoolItem_Ref who,
00264 const Dep & capKind,
00265 bool *unneeded = NULL,
00266 bool *installed = NULL,
00267 const bool installInfoFlag = false);
00274 bool requirementIsInstalledOrUnneeded (const Capability & capability,
00275 const PoolItem_Ref who,
00276 const Dep & capKind);
00277 bool requirementIsPossible (const Capability & cap);
00278
00279 bool itemIsPossible( const PoolItem_Ref item, Capability & failed );
00280 bool isParallelInstall (const PoolItem_Ref item) const;
00281 PoolItem_Ref getParallelInstall (const PoolItem_Ref item) const;
00282
00285 void foreachMarked (MarkedPoolItemFn fn, void *data) const;
00286 PoolItemList getMarked (int which);
00287
00288 int foreachInstall (MarkedPoolItemFn fn, void *data) const;
00289 PoolItemList getInstalls (void) const;
00290 int installCount (void) const;
00291
00292 int foreachUninstall (MarkedPoolItemFn fn, void *data);
00293 PoolItemList getUninstalls (void);
00294 int uninstallCount (void);
00295
00296 int foreachUpgrade (MarkedPoolItemPairFn fn, void *data);
00297 PoolItemList getUpgrades (void);
00298 int upgradeCount (void);
00299
00300 int foreachSatisfy (MarkedPoolItemFn fn, void *data) const;
00301 PoolItemList getSatisfies (void) const;
00302 int satisfyCount (void) const;
00303
00304 int foreachIncomplete (MarkedPoolItemFn fn, void *data) const;
00305 PoolItemList getIncompletes (void) const;
00306 int incompleteCount (void) const;
00307
00308 int foreachImpossible (MarkedPoolItemFn fn, void *data);
00309
00310
00311
00312
00313 void addInfo (ResolverInfo_Ptr info, bool askUser = false);
00314 void addError (ResolverInfo_Ptr info, bool askUser = false);
00315
00316
00317 void foreachInfo (PoolItem_Ref item, int priority, ResolverInfoFn fn, void *data, const bool merge=true, const bool findImportant = true) const;
00318 ResolverInfoList getInfo (void) const;
00319
00320
00321 void collectCompareInfo (int & cmpVersion,
00322 int & cmpSource,
00323 ResolverContext_Ptr compareContext);
00324
00325 int partialCompare (ResolverContext_Ptr context);
00326 int compare (ResolverContext_Ptr context);
00327
00328
00329 void spew (void);
00330 void spewInfo (void) const;
00331
00332 int getRepoPriority (Repository source) const;
00333 };
00334
00336 };
00339 };
00342 };
00344 #endif // ZYPP_SOLVER_DETAIL_RESOLVERCONTEXT_H
00345