// -*- 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
##################################################################### */
/*}}}*/
-// 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 <pkglib/pkgcache.h>
+#include <apt-pkg/pkgcache.h>
+#include <apt-pkg/progress.h>
-class pkgDepCache : public pkgCache
+class pkgDepCache : protected pkgCache::Namespace
{
public:
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};
// 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);
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;};
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);
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();
};