]>
Commit | Line | Data |
---|---|---|
b9179170 MV |
1 | #ifndef APT_PRIVATE_CACHEFILE_H |
2 | #define APT_PRIVATE_CACHEFILE_H | |
3 | ||
4 | #include <apt-pkg/cachefile.h> | |
5 | #include <apt-pkg/progress.h> | |
453b82a3 DK |
6 | #include <apt-pkg/configuration.h> |
7 | #include <apt-pkg/pkgcache.h> | |
63ff4208 | 8 | #include <apt-pkg/macros.h> |
aaf677da | 9 | #include <apt-pkg/sourcelist.h> |
a0c19a21 DK |
10 | #include <apt-pkg/cacheset.h> |
11 | ||
aaf677da | 12 | #include <apti18n.h> |
b9179170 | 13 | |
a0c19a21 | 14 | // FIXME: we need to find a way to export this |
aaf677da MV |
15 | class APT_PUBLIC SourceList : public pkgSourceList |
16 | { | |
aaf677da MV |
17 | public: |
18 | // Add custom metaIndex (e.g. local files) | |
19 | void AddMetaIndex(metaIndex *mi) { | |
20 | SrcList.push_back(mi); | |
21 | } | |
22 | ||
23 | }; | |
b9179170 MV |
24 | |
25 | // class CacheFile - Cover class for some dependency cache functions /*{{{*/ | |
63ff4208 | 26 | class APT_PUBLIC CacheFile : public pkgCacheFile |
b9179170 | 27 | { |
b9179170 | 28 | public: |
a0c19a21 DK |
29 | std::vector<map_pointer_t> UniverseList; |
30 | ||
b9179170 MV |
31 | bool CheckDeps(bool AllowBroken = false); |
32 | bool BuildCaches(bool WithLock = true) | |
33 | { | |
34 | OpTextProgress Prog(*_config); | |
35 | if (pkgCacheFile::BuildCaches(&Prog,WithLock) == false) | |
36 | return false; | |
37 | return true; | |
38 | } | |
aaf677da MV |
39 | // FIXME: this can go once the "libapt-pkg" pkgSourceList has a way |
40 | // to add custom metaIndexes (or custom local files or so) | |
41 | bool BuildSourceList(OpProgress */*Progress*/ = NULL) { | |
42 | if (SrcList != NULL) | |
43 | return true; | |
44 | SrcList = new SourceList(); | |
45 | if (SrcList->ReadMainList() == false) | |
46 | return _error->Error(_("The list of sources could not be read.")); | |
47 | return true; | |
48 | } | |
a0c19a21 | 49 | bool Open(bool WithLock = true) |
b9179170 MV |
50 | { |
51 | OpTextProgress Prog(*_config); | |
a0c19a21 | 52 | return pkgCacheFile::Open(&Prog,WithLock); |
b9179170 MV |
53 | }; |
54 | bool OpenForInstall() | |
55 | { | |
56 | if (_config->FindB("APT::Get::Print-URIs") == true) | |
57 | return Open(false); | |
58 | else | |
59 | return Open(true); | |
60 | } | |
b9179170 MV |
61 | }; |
62 | /*}}}*/ | |
63 | ||
a0c19a21 DK |
64 | class APT_PUBLIC SortedPackageUniverse : public APT::PackageUniverse |
65 | { | |
66 | std::vector<map_pointer_t> &List; | |
67 | void LazyInit() const; | |
68 | ||
69 | public: | |
70 | SortedPackageUniverse(CacheFile &Cache); | |
71 | ||
72 | class const_iterator : public APT::Container_iterator_base<APT::PackageContainerInterface, SortedPackageUniverse, SortedPackageUniverse::const_iterator, std::vector<map_pointer_t>::const_iterator, pkgCache::PkgIterator> | |
73 | { | |
74 | pkgCache * const Cache; | |
75 | protected: | |
76 | inline virtual pkgCache::PkgIterator getType(void) const APT_OVERRIDE | |
77 | { | |
78 | if (*_iter == 0) return pkgCache::PkgIterator(*Cache); | |
79 | return pkgCache::PkgIterator(*Cache, Cache->PkgP + *_iter); | |
80 | } | |
81 | public: | |
82 | explicit const_iterator(pkgCache * const Owner, std::vector<map_pointer_t>::const_iterator i): | |
83 | Container_iterator_base<APT::PackageContainerInterface, SortedPackageUniverse, SortedPackageUniverse::const_iterator, std::vector<map_pointer_t>::const_iterator, pkgCache::PkgIterator>(i), Cache(Owner) {} | |
84 | ||
85 | }; | |
86 | typedef const_iterator iterator; | |
87 | ||
88 | APT_PUBLIC const_iterator begin() const { LazyInit(); return const_iterator(data(), List.begin()); } | |
89 | APT_PUBLIC const_iterator end() const { LazyInit(); return const_iterator(data(), List.end()); } | |
90 | APT_PUBLIC const_iterator cbegin() const { LazyInit(); return const_iterator(data(), List.begin()); } | |
91 | APT_PUBLIC const_iterator cend() const { LazyInit(); return const_iterator(data(), List.end()); } | |
92 | APT_PUBLIC iterator begin() { LazyInit(); return iterator(data(), List.begin()); } | |
93 | APT_PUBLIC iterator end() { LazyInit(); return iterator(data(), List.end()); } | |
94 | }; | |
95 | ||
b9179170 | 96 | #endif |