summaryrefslogtreecommitdiff
path: root/apt-pkg/solver3.h
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2025-02-03 16:56:08 +0100
committerJulian Andres Klode <julian.klode@canonical.com>2025-02-07 20:59:43 +0100
commit466ff3cf0afc5c034ec77868781d8e19e274e7ff (patch)
treeb133e8ec5a47979703adbf8e543445198361c240 /apt-pkg/solver3.h
parent3c4551bbdae483d37b985b2c690d77372fb50e89 (diff)
solver3: Partially generalize work items from Version to Var
Store all possible solutions and choices as Var. Currently any Var in here must be a Version because CompareProviders3 cannot compare versions against packages yet, but in the future (TM), this will allow storing packages directly in clauses, which allows defering version selection to a later point.
Diffstat (limited to 'apt-pkg/solver3.h')
-rw-r--r--apt-pkg/solver3.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/apt-pkg/solver3.h b/apt-pkg/solver3.h
index 282e8865b..4561ffa73 100644
--- a/apt-pkg/solver3.h
+++ b/apt-pkg/solver3.h
@@ -7,6 +7,7 @@
* SPDX-License-Identifier: GPL-2.0+
*/
+#include <cassert>
#include <optional>
#include <queue>
#include <vector>
@@ -242,11 +243,21 @@ struct APT::Solver::Var
{
return IsVersion ? pkgCache::VerIterator(cache, cache.VerP + Ver()) : pkgCache::VerIterator();
}
+ // \brief Return a package, cast from version if needed
+ pkgCache::PkgIterator CastPkg(pkgCache &cache) const
+ {
+ assert(MapPtr != 0);
+ return IsVersion ? Ver(cache).ParentPkg() : Pkg(cache);
+ }
// \brief Check if there is no reason.
bool empty() const
{
return IsVersion == 0 && MapPtr == 0;
}
+ bool operator==(Var const other)
+ {
+ return IsVersion == other.IsVersion && MapPtr == other.MapPtr;
+ }
std::string toString(pkgCache &cache) const
{
@@ -277,14 +288,14 @@ struct APT::Solver::Work
// \brief The group we are in
Group group;
// \brief Possible solutions to this task, ordered in order of preference.
- std::vector<pkgCache::Version *> solutions{};
+ std::vector<Var> solutions{};
// This is a union because we only need to store the choice we made when adding
// to the choice vector, and we don't need the size of valid choices in there.
union
{
// The choice we took
- pkgCache::Version *choice;
+ Var choice;
// Number of valid choices
size_t size;
};