diff options
author | David Kalnischkies <david@kalnischkies.de> | 2014-09-03 11:11:10 +0200 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2014-09-27 00:10:27 +0200 |
commit | 840ca9714364d5ef5aa8eee0c9b045277b6ab945 (patch) | |
tree | 071912697fed653b7840474436e8114eacad429f /apt-pkg/cacheset.h | |
parent | 5c8c7321559d9136ba90d0ec647ef0234e8d6c23 (diff) |
add APT::PackageUniverse as a pkgCache wrapper
Git-Dch: Ignore
Diffstat (limited to 'apt-pkg/cacheset.h')
-rw-r--r-- | apt-pkg/cacheset.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/apt-pkg/cacheset.h b/apt-pkg/cacheset.h index 736dda3cf..2656727d4 100644 --- a/apt-pkg/cacheset.h +++ b/apt-pkg/cacheset.h @@ -428,6 +428,44 @@ template<> template<class Compare> inline bool PackageContainer<std::vector<pkgC return true; } +// class PackageUniverse - pkgCache as PackageContainerInterface /*{{{*/ +/** \class PackageUniverse + + Wraps around our usual pkgCache, so that it can be stuffed into methods + expecting a PackageContainer. + + The wrapping is read-only in practice modeled by making erase and co + private methods. */ +class PackageUniverse : public PackageContainerInterface { + pkgCache * const _cont; +public: + typedef pkgCache::PkgIterator iterator; + typedef pkgCache::PkgIterator const_iterator; + + bool empty() const { return false; } + size_t size() const { return _cont->Head().PackageCount; } + + const_iterator begin() const { return _cont->PkgBegin(); } + const_iterator end() const { return _cont->PkgEnd(); } + iterator begin() { return _cont->PkgBegin(); } + iterator end() { return _cont->PkgEnd(); } + + PackageUniverse(pkgCache * const Owner) : _cont(Owner) { } + +private: + bool insert(pkgCache::PkgIterator const &) { return true; } + template<class Cont> void insert(PackageContainer<Cont> const &) { } + void insert(const_iterator, const_iterator) { } + + void clear() { } + iterator& erase(iterator &iter) { return iter; } + size_t erase(const pkgCache::PkgIterator) { return 0; } + void erase(iterator, iterator) { } + + void setConstructor(Constructor const &) { } + Constructor getConstructor() const { return UNKNOWN; } +}; + /*}}}*/ typedef PackageContainer<std::set<pkgCache::PkgIterator> > PackageSet; typedef PackageContainer<std::list<pkgCache::PkgIterator> > PackageList; typedef PackageContainer<std::vector<pkgCache::PkgIterator> > PackageVector; |