diff options
author | David Kalnischkies <kalnischkies@gmail.com> | 2009-12-19 16:25:56 +0100 |
---|---|---|
committer | David Kalnischkies <kalnischkies@gmail.com> | 2009-12-19 16:25:56 +0100 |
commit | 5bf15716398fdb767ca6249a0155219b88d7ae60 (patch) | |
tree | 35a5f1db804539d0fb2d3260d5557a4edde73838 /apt-pkg/cacheiterators.h | |
parent | 201d1fa0d25deeda77c2570ee5342eaf18499699 (diff) |
Implement the first step toward Multi-Arch by setting up a Group
infrastructor for packages.
APT is now aware of the fact that a package A in architecture X can't
satisfy a dependency on package A in architecture Y - to handle these
packages are now identified by name and architecture, so different
architectures of the same package are handled internally as completly
different packages. This is great for pinning, dependency checking and
in many other situations, but sometimes we need to know which archs are
available for a given package: Here Groups come to our rescue!
Diffstat (limited to 'apt-pkg/cacheiterators.h')
-rw-r--r-- | apt-pkg/cacheiterators.h | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h index 1da5c6f02..35d3aa228 100644 --- a/apt-pkg/cacheiterators.h +++ b/apt-pkg/cacheiterators.h @@ -31,10 +31,8 @@ #define PKGLIB_CACHEITERATORS_H // abstract Iterator template /*{{{*/ /* This template provides the very basic iterator methods we - need to have for doing some walk-over-the-cache magic, */ + need to have for doing some walk-over-the-cache magic */ template<typename Str, typename Itr> class pkgCache::Iterator { - __attribute__ ((deprecated)) void _dummy(); // FIXME: Who on earth uses this method ??? - protected: Str *S; pkgCache *Owner; @@ -77,6 +75,35 @@ template<typename Str, typename Itr> class pkgCache::Iterator { inline Iterator(pkgCache &Owner,Str *T = 0) : S(T), Owner(&Owner) {}; }; /*}}}*/ +// Group Iterator /*{{{*/ +/* Packages with the same name are collected in a Group so someone only + interest in package names can iterate easily over the names, so the + different architectures can be treated as of the "same" package + (apt internally treat them as totally different packages) */ +class pkgCache::GrpIterator: public Iterator<Group, GrpIterator> { + protected: + inline Group* OwnerPointer() const { + return Owner->GrpP; + }; + + public: + void operator ++(int) {if (S != Owner->GrpP) S = Owner->GrpP + S->Next;}; + virtual void operator ++() {operator ++(0);}; + + inline const char *Name() const {return S->Name == 0?0:Owner->StrP + S->Name;}; + inline PkgIterator PackageList() const; + PkgIterator FindPkg(string Arch = "any"); + PkgIterator NextPkg(PkgIterator const &Pkg); + + // Constructors + inline GrpIterator(pkgCache &Owner, Group *Trg) : Iterator<Group, GrpIterator>(Owner, Trg) { + if (S == 0) + S = OwnerPointer(); + }; + inline GrpIterator() : Iterator<Group, GrpIterator>() {}; + +}; + /*}}}*/ // Package Iterator /*{{{*/ class pkgCache::PkgIterator: public Iterator<Package, PkgIterator> { long HashIndex; @@ -103,6 +130,8 @@ class pkgCache::PkgIterator: public Iterator<Package, PkgIterator> { inline const char *Section() const {return S->Section == 0?0:Owner->StrP + S->Section;}; inline bool Purge() const {return S->CurrentState == pkgCache::State::Purge || (S->CurrentVer == 0 && S->CurrentState == pkgCache::State::NotInstalled);}; + inline const char *Arch() const {return S->Arch == 0?0:Owner->StrP + S->Arch;}; + inline GrpIterator Group() const { return GrpIterator(*Owner, Owner->GrpP + S->Group);}; inline VerIterator VersionList() const; inline VerIterator CurrentVer() const; @@ -339,6 +368,8 @@ class pkgCache::DescFileIterator : public Iterator<DescFile, DescFileIterator> { }; /*}}}*/ // Inlined Begin functions cant be in the class because of order problems /*{{{*/ +inline pkgCache::PkgIterator pkgCache::GrpIterator::PackageList() const + {return PkgIterator(*Owner,Owner->PkgP + S->FirstPackage);}; inline pkgCache::VerIterator pkgCache::PkgIterator::VersionList() const {return VerIterator(*Owner,Owner->VerP + S->VersionList);}; inline pkgCache::VerIterator pkgCache::PkgIterator::CurrentVer() const |