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