X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/6c139d6e362f04a1582e8a8f511f8aeab031fecf..cec6091772ae3463cb04c417e3f598f9b6814516:/apt-pkg/depcache.h diff --git a/apt-pkg/depcache.h b/apt-pkg/depcache.h index 222e34425..6d51920e9 100644 --- a/apt-pkg/depcache.h +++ b/apt-pkg/depcache.h @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: depcache.h,v 1.1 1998/07/07 04:17:01 jgg Exp $ +// $Id: depcache.h,v 1.14 2001/02/20 07:03:17 jgg Exp $ /* ###################################################################### DepCache - Dependency Extension data for the cache @@ -35,17 +35,17 @@ ##################################################################### */ /*}}}*/ -// Header section: pkglib #ifndef PKGLIB_DEPCACHE_H #define PKGLIB_DEPCACHE_H #ifdef __GNUG__ -#pragma interface "pkglib/depcache.h" +#pragma interface "apt-pkg/depcache.h" #endif -#include +#include +#include -class pkgDepCache : public pkgCache +class pkgDepCache : protected pkgCache::Namespace { public: @@ -59,7 +59,7 @@ class pkgDepCache : public pkgCache DepCandPolicy = (1 << 4), DepCandMin = (1 << 5)}; // These flags are used in StateCache::iFlags - enum InternalFlags {AutoKept = (1 << 0)}; + enum InternalFlags {AutoKept = (1 << 0), Purge = (1 << 1), ReInstall = (1 << 2)}; enum VersionTypes {NowVersion, InstallVersion, CandidateVersion}; enum ModeList {ModeDelete = 0, ModeKeep = 1, ModeInstall = 2}; @@ -74,16 +74,16 @@ class pkgDepCache : public pkgCache // Pointer to the install version. Version *InstallVer; + + // Copy of Package::Flags + unsigned short Flags; + unsigned short iFlags; // Internal flags // Various tree indicators signed char Status; // -1,0,1,2 unsigned char Mode; // ModeList unsigned char DepState; // DepState Flags - // Copy of Package::Flags - unsigned short Flags; - unsigned short iFlags; // Internal flags - // Update of candidate version const char *StripEpoch(const char *Ver); void Update(PkgIterator Pkg,pkgCache &Cache); @@ -93,8 +93,8 @@ class pkgDepCache : public pkgCache inline bool Delete() const {return Mode == ModeDelete;}; inline bool Keep() const {return Mode == ModeKeep;}; inline bool Upgrade() const {return Status > 0 && Mode == ModeInstall;}; - inline bool Upgradable() const {return Status == 1;}; - inline bool Downgrade() const {return Status < 0;}; + inline bool Upgradable() const {return Status >= 1;}; + inline bool Downgrade() const {return Status < 0 && Mode == ModeInstall;}; inline bool Held() const {return Status != 0 && Keep();}; inline bool NowBroken() const {return (DepState & DepNowMin) != DepNowMin;}; inline bool InstBroken() const {return (DepState & DepInstMin) != DepInstMin;}; @@ -109,29 +109,42 @@ class pkgDepCache : public pkgCache void BuildGroupOrs(VerIterator const &V); void UpdateVerState(PkgIterator Pkg); - bool Init(); - + // User Policy control + class Policy + { + public: + + virtual VerIterator GetCandidateVer(PkgIterator Pkg); + virtual bool IsImportantDep(DepIterator Dep); + + virtual ~Policy() {}; + }; + protected: // State information + pkgCache *Cache; StateCache *PkgState; unsigned char *DepState; - long iUsrSize; - long iDownloadSize; - long iInstCount; - long iDelCount; - long iKeepCount; - long iBrokenCount; - long iBadCount; - + double iUsrSize; + double iDownloadSize; + unsigned long iInstCount; + unsigned long iDelCount; + unsigned long iKeepCount; + unsigned long iBrokenCount; + unsigned long iBadCount; + + Policy *delLocalPolicy; // For memory clean up.. + Policy *LocalPolicy; + // Check for a matching provides bool CheckDep(DepIterator Dep,int Type,PkgIterator &Res); inline bool CheckDep(DepIterator Dep,int Type) { - PkgIterator Res(*this); + PkgIterator Res(*this,0); return CheckDep(Dep,Type,Res); - } + } // Computes state information for deps and versions (w/o storing) unsigned char DependencyState(DepIterator &D); @@ -144,45 +157,54 @@ class pkgDepCache : public pkgCache void Update(PkgIterator const &P); // Count manipulators - void AddSizes(const PkgIterator &Pkg,long Mult = 1); + void AddSizes(const PkgIterator &Pkg,signed long Mult = 1); inline void RemoveSizes(const PkgIterator &Pkg) {AddSizes(Pkg,-1);}; void AddStates(const PkgIterator &Pkg,int Add = 1); inline void RemoveStates(const PkgIterator &Pkg) {AddStates(Pkg,-1);}; - + public: + // Legacy.. We look like a pkgCache + inline operator pkgCache &() {return *Cache;}; + inline Header &Head() {return *Cache->HeaderP;}; + inline PkgIterator PkgBegin() {return Cache->PkgBegin();}; + inline PkgIterator FindPkg(string const &Name) {return Cache->FindPkg(Name);}; + + inline pkgCache &GetCache() {return *Cache;}; + inline pkgVersioningSystem &VS() {return *Cache->VS;}; + // Policy implementation - virtual VerIterator GetCandidateVer(PkgIterator Pkg); - virtual bool IsImportantDep(DepIterator Dep); - + inline VerIterator GetCandidateVer(PkgIterator Pkg) {return LocalPolicy->GetCandidateVer(Pkg);}; + inline bool IsImportantDep(DepIterator Dep) {return LocalPolicy->IsImportantDep(Dep);}; + inline Policy &GetPolicy() {return *LocalPolicy;}; + // Accessors inline StateCache &operator [](PkgIterator const &I) {return PkgState[I->ID];}; inline unsigned char &operator [](DepIterator const &I) {return DepState[I->ID];}; // Manipulators void MarkKeep(PkgIterator const &Pkg,bool Soft = false); - void MarkDelete(PkgIterator const &Pkg); - void MarkInstall(PkgIterator const &Pkg,bool AutoInst = true); + void MarkDelete(PkgIterator const &Pkg,bool Purge = false); + void MarkInstall(PkgIterator const &Pkg,bool AutoInst = true, + unsigned long Depth = 0); + void SetReInstall(PkgIterator const &Pkg,bool To); + void SetCandidateVersion(VerIterator TargetVer); // This is for debuging - void Update(); - - // Dep Processing for AutoKeep - void ResolveConflicts(unsigned char *Touched); - - // Hook to keep the extra data in sync - virtual bool ReMap(); + void Update(OpProgress *Prog = 0); // Size queries - inline long UsrSize() {return iUsrSize;}; - inline long DebSize() {return iDownloadSize;}; - inline long DelCount() {return iDelCount;}; - inline long KeepCount() {return iKeepCount;}; - inline long InstCount() {return iInstCount;}; - inline long BrokenCount() {return iBrokenCount;}; - inline long BadCount() {return iBadCount;}; - - pkgDepCache(MMap &Map); + inline double UsrSize() {return iUsrSize;}; + inline double DebSize() {return iDownloadSize;}; + inline unsigned long DelCount() {return iDelCount;}; + inline unsigned long KeepCount() {return iKeepCount;}; + inline unsigned long InstCount() {return iInstCount;}; + inline unsigned long BrokenCount() {return iBrokenCount;}; + inline unsigned long BadCount() {return iBadCount;}; + + bool Init(OpProgress *Prog); + + pkgDepCache(pkgCache *Cache,Policy *Plcy = 0); virtual ~pkgDepCache(); };