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>
16 class VerIteratorWithCaching
18 const pkgCache::VerIterator iter
;
19 const pkgCache::DescFile
* descFile
;
21 VerIteratorWithCaching(const pkgCache::VerIterator
& iter
) :
23 descFile(iter
->DescriptionList
!= 0
24 ? (const pkgCache::DescFile
*) iter
.TranslatedDescription().FileList()
27 const pkgCache::DescFile
* CachedDescFile() const { return descFile
; }
28 operator pkgCache::VerIterator() const { return iter
; }
31 struct VersionSortDescriptionLocality
/*{{{*/
33 bool operator () (const VerIteratorWithCaching
&v_lhs
,
34 const VerIteratorWithCaching
&v_rhs
)
36 pkgCache::DescFile
const *A
= v_lhs
.CachedDescFile();
37 pkgCache::DescFile
const *B
= v_rhs
.CachedDescFile();
39 if (A
== nullptr && B
== nullptr)
48 if (A
->File
== B
->File
)
49 return A
->Offset
< B
->Offset
;
51 return A
->File
< B
->File
;
55 // sorted by locality which makes iterating much faster
56 typedef APT::VersionContainer
<
57 std::set
<VerIteratorWithCaching
,
58 VersionSortDescriptionLocality
> > LocalitySortedVersionSet
;
62 virtual bool operator () (const pkgCache::PkgIterator
&/*P*/) {
66 // FIXME: add default argument for OpProgress (or overloaded function)
67 bool GetLocalitySortedVersionSet(pkgCacheFile
&CacheFile
,
68 APT::VersionContainerInterface
* const vci
,
70 OpProgress
* const progress
);
71 bool GetLocalitySortedVersionSet(pkgCacheFile
&CacheFile
,
72 APT::VersionContainerInterface
* const vci
,
73 OpProgress
* const progress
);
76 // CacheSetHelper saving virtual packages /*{{{*/
77 class CacheSetHelperVirtuals
: public APT::CacheSetHelper
{
79 APT::PackageSet virtualPkgs
;
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
;
83 virtual pkgCache::PkgIterator
canNotFindPkgName(pkgCacheFile
&Cache
, std::string
const &str
) APT_OVERRIDE
;
85 CacheSetHelperVirtuals(bool const ShowErrors
= true, GlobalError::MsgType
const &ErrorType
= GlobalError::NOTICE
);
89 // CacheSetHelperAPTGet - responsible for message telling from the CacheSets/*{{{*/
90 class CacheSetHelperAPTGet
: public APT::CacheSetHelper
{
91 /** \brief stream message should be printed to */
93 /** \brief were things like Task or RegEx used to select packages? */
96 APT::PackageSet virtualPkgs
;
99 std::list
<std::pair
<pkgCache::VerIterator
, std::string
> > selectedByRelease
;
101 explicit CacheSetHelperAPTGet(std::ostream
&out
);
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
;
106 virtual void showSelectedVersion(pkgCache::PkgIterator
const &/*Pkg*/, pkgCache::VerIterator
const Ver
,
107 std::string
const &ver
, bool const /*verIsRel*/) APT_OVERRIDE
;
108 bool showVirtualPackageErrors(pkgCacheFile
&Cache
);
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
;
112 virtual pkgCache::PkgIterator
canNotFindPkgName(pkgCacheFile
&Cache
, std::string
const &str
) APT_OVERRIDE
;
114 APT::VersionSet
tryVirtualPackage(pkgCacheFile
&Cache
, pkgCache::PkgIterator
const &Pkg
,
115 CacheSetHelper::VerSelector
const select
);
117 inline bool allPkgNamedExplicitly() const { return explicitlyNamed
; }