1 #ifndef APT_PRIVATE_CACHESET_H
2 #define APT_PRIVATE_CACHESET_H
4 #include <apt-pkg/cacheset.h>
5 #include <apt-pkg/macros.h>
7 #include <apt-private/private-output.h>
18 class VerIteratorWithCaching
20 const pkgCache::VerIterator iter
;
21 const pkgCache::DescFile
* descFile
;
23 VerIteratorWithCaching(const pkgCache::VerIterator
& iter
) :
25 descFile(iter
->DescriptionList
!= 0
26 ? (const pkgCache::DescFile
*) iter
.TranslatedDescription().FileList()
29 const pkgCache::DescFile
* CachedDescFile() const { return descFile
; }
30 operator pkgCache::VerIterator() const { return iter
; }
33 struct VersionSortDescriptionLocality
/*{{{*/
35 bool operator () (const VerIteratorWithCaching
&v_lhs
,
36 const VerIteratorWithCaching
&v_rhs
)
38 pkgCache::DescFile
const *A
= v_lhs
.CachedDescFile();
39 pkgCache::DescFile
const *B
= v_rhs
.CachedDescFile();
41 if (A
== nullptr && B
== nullptr)
50 if (A
->File
== B
->File
)
51 return A
->Offset
< B
->Offset
;
53 return A
->File
< B
->File
;
57 // sorted by locality which makes iterating much faster
58 typedef APT::VersionContainer
<
59 std::set
<VerIteratorWithCaching
,
60 VersionSortDescriptionLocality
> > LocalitySortedVersionSet
;
64 virtual bool operator () (const pkgCache::PkgIterator
&/*P*/) {
68 // FIXME: add default argument for OpProgress (or overloaded function)
69 bool GetLocalitySortedVersionSet(pkgCacheFile
&CacheFile
,
70 APT::VersionContainerInterface
* const vci
,
72 OpProgress
* const progress
);
73 bool GetLocalitySortedVersionSet(pkgCacheFile
&CacheFile
,
74 APT::VersionContainerInterface
* const vci
,
75 OpProgress
* const progress
);
78 // CacheSetHelper saving virtual packages /*{{{*/
79 class CacheSetHelperVirtuals
: public APT::CacheSetHelper
{
81 APT::PackageSet virtualPkgs
;
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
;
85 virtual pkgCache::PkgIterator
canNotFindPkgName(pkgCacheFile
&Cache
, std::string
const &str
) APT_OVERRIDE
;
87 CacheSetHelperVirtuals(bool const ShowErrors
= true, GlobalError::MsgType
const &ErrorType
= GlobalError::NOTICE
);
91 // CacheSetHelperAPTGet - responsible for message telling from the CacheSets/*{{{*/
92 class CacheSetHelperAPTGet
: public APT::CacheSetHelper
{
93 /** \brief stream message should be printed to */
95 /** \brief were things like Task or RegEx used to select packages? */
98 APT::PackageSet virtualPkgs
;
101 std::list
<std::pair
<pkgCache::VerIterator
, std::string
> > selectedByRelease
;
103 explicit CacheSetHelperAPTGet(std::ostream
&out
);
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
;
108 virtual void showSelectedVersion(pkgCache::PkgIterator
const &/*Pkg*/, pkgCache::VerIterator
const Ver
,
109 std::string
const &ver
, bool const /*verIsRel*/) APT_OVERRIDE
;
110 bool showVirtualPackageErrors(pkgCacheFile
&Cache
);
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
;
114 virtual pkgCache::PkgIterator
canNotFindPkgName(pkgCacheFile
&Cache
, std::string
const &str
) APT_OVERRIDE
;
116 APT::VersionSet
tryVirtualPackage(pkgCacheFile
&Cache
, pkgCache::PkgIterator
const &Pkg
,
117 CacheSetHelper::VerSelector
const select
);
119 inline bool allPkgNamedExplicitly() const { return explicitlyNamed
; }