]>
Commit | Line | Data |
---|---|---|
b9179170 MV |
1 | #ifndef APT_PRIVATE_CACHESET_H |
2 | #define APT_PRIVATE_CACHESET_H | |
3 | ||
b9179170 | 4 | #include <apt-pkg/cacheset.h> |
453b82a3 | 5 | #include <apt-pkg/macros.h> |
b9179170 | 6 | |
a0c19a21 DK |
7 | #include <apt-private/private-output.h> |
8 | ||
b9179170 | 9 | #include <vector> |
453b82a3 | 10 | #include <list> |
453b82a3 DK |
11 | #include <set> |
12 | #include <string> | |
b9179170 | 13 | |
453b82a3 DK |
14 | class OpProgress; |
15 | ||
326a2ecf AW |
16 | class VerIteratorWithCaching |
17 | { | |
18 | const pkgCache::VerIterator iter; | |
19 | const pkgCache::DescFile * descFile; | |
20 | public: | |
21 | VerIteratorWithCaching(const pkgCache::VerIterator& iter) : | |
22 | iter(iter), | |
23 | descFile(iter->DescriptionList != 0 | |
24 | ? (const pkgCache::DescFile *) iter.TranslatedDescription().FileList() | |
25 | : nullptr) | |
26 | {} | |
27 | const pkgCache::DescFile * CachedDescFile() const { return descFile; } | |
28 | operator pkgCache::VerIterator() const { return iter; } | |
29 | }; | |
30 | ||
f6777222 | 31 | struct VersionSortDescriptionLocality /*{{{*/ |
b9179170 | 32 | { |
326a2ecf AW |
33 | bool operator () (const VerIteratorWithCaching &v_lhs, |
34 | const VerIteratorWithCaching &v_rhs) | |
6cfadda1 | 35 | { |
326a2ecf AW |
36 | pkgCache::DescFile const *A = v_lhs.CachedDescFile(); |
37 | pkgCache::DescFile const *B = v_rhs.CachedDescFile(); | |
3d8232bf | 38 | |
6cfadda1 DK |
39 | if (A == nullptr && B == nullptr) |
40 | return false; | |
b9179170 | 41 | |
6cfadda1 DK |
42 | if (A == nullptr) |
43 | return true; | |
b9179170 | 44 | |
6cfadda1 DK |
45 | if (B == nullptr) |
46 | return false; | |
b9179170 | 47 | |
6cfadda1 DK |
48 | if (A->File == B->File) |
49 | return A->Offset < B->Offset; | |
b9179170 | 50 | |
6cfadda1 DK |
51 | return A->File < B->File; |
52 | } | |
b9179170 | 53 | }; |
6cfadda1 | 54 | /*}}}*/ |
b9179170 MV |
55 | // sorted by locality which makes iterating much faster |
56 | typedef APT::VersionContainer< | |
326a2ecf | 57 | std::set<VerIteratorWithCaching, |
b9179170 MV |
58 | VersionSortDescriptionLocality> > LocalitySortedVersionSet; |
59 | ||
60 | class Matcher { | |
61 | public: | |
65512241 DK |
62 | virtual bool operator () (const pkgCache::PkgIterator &/*P*/) { |
63 | return true;} | |
b9179170 MV |
64 | }; |
65 | ||
66 | // FIXME: add default argument for OpProgress (or overloaded function) | |
25594bb5 DK |
67 | bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile, |
68 | APT::VersionContainerInterface * const vci, | |
b9179170 | 69 | Matcher &matcher, |
25594bb5 DK |
70 | OpProgress * const progress); |
71 | bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile, | |
72 | APT::VersionContainerInterface * const vci, | |
73 | OpProgress * const progress); | |
b9179170 MV |
74 | |
75 | ||
76 | // CacheSetHelper saving virtual packages /*{{{*/ | |
f6777222 | 77 | class CacheSetHelperVirtuals: public APT::CacheSetHelper { |
b9179170 MV |
78 | public: |
79 | APT::PackageSet virtualPkgs; | |
80 | ||
6cfadda1 DK |
81 | virtual pkgCache::VerIterator canNotGetVersion(enum CacheSetHelper::VerSelector const select, pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) APT_OVERRIDE; |
82 | virtual void canNotFindVersion(enum CacheSetHelper::VerSelector const select, APT::VersionContainerInterface * vci, pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) APT_OVERRIDE; | |
3addaba1 | 83 | virtual pkgCache::PkgIterator canNotFindPkgName(pkgCacheFile &Cache, std::string const &str) APT_OVERRIDE; |
b9179170 | 84 | |
6cfadda1 | 85 | CacheSetHelperVirtuals(bool const ShowErrors = true, GlobalError::MsgType const &ErrorType = GlobalError::NOTICE); |
b9179170 MV |
86 | }; |
87 | /*}}}*/ | |
88 | ||
89 | // CacheSetHelperAPTGet - responsible for message telling from the CacheSets/*{{{*/ | |
f6777222 | 90 | class CacheSetHelperAPTGet : public APT::CacheSetHelper { |
b9179170 MV |
91 | /** \brief stream message should be printed to */ |
92 | std::ostream &out; | |
93 | /** \brief were things like Task or RegEx used to select packages? */ | |
94 | bool explicitlyNamed; | |
95 | ||
96 | APT::PackageSet virtualPkgs; | |
97 | ||
98 | public: | |
99 | std::list<std::pair<pkgCache::VerIterator, std::string> > selectedByRelease; | |
100 | ||
258b9e51 | 101 | explicit CacheSetHelperAPTGet(std::ostream &out); |
b9179170 | 102 | |
6cfadda1 DK |
103 | virtual void showTaskSelection(pkgCache::PkgIterator const &Pkg, std::string const &pattern) APT_OVERRIDE; |
104 | virtual void showFnmatchSelection(pkgCache::PkgIterator const &Pkg, std::string const &pattern) APT_OVERRIDE; | |
105 | virtual void showRegExSelection(pkgCache::PkgIterator const &Pkg, std::string const &pattern) APT_OVERRIDE; | |
65512241 | 106 | virtual void showSelectedVersion(pkgCache::PkgIterator const &/*Pkg*/, pkgCache::VerIterator const Ver, |
6cfadda1 DK |
107 | std::string const &ver, bool const /*verIsRel*/) APT_OVERRIDE; |
108 | bool showVirtualPackageErrors(pkgCacheFile &Cache); | |
b9179170 | 109 | |
6cfadda1 DK |
110 | virtual pkgCache::VerIterator canNotFindCandidateVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) APT_OVERRIDE; |
111 | virtual pkgCache::VerIterator canNotFindNewestVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) APT_OVERRIDE; | |
3addaba1 | 112 | virtual pkgCache::PkgIterator canNotFindPkgName(pkgCacheFile &Cache, std::string const &str) APT_OVERRIDE; |
b9179170 MV |
113 | |
114 | APT::VersionSet tryVirtualPackage(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg, | |
6cfadda1 | 115 | CacheSetHelper::VerSelector const select); |
b9179170 MV |
116 | |
117 | inline bool allPkgNamedExplicitly() const { return explicitlyNamed; } | |
b9179170 MV |
118 | }; |
119 | /*}}}*/ | |
120 | ||
121 | #endif |