Skip to content

Commit

Permalink
PackageQuery: New ctor based on the PackageSet instance
Browse files Browse the repository at this point in the history
It's a shortcut instead of creating an empty PackageQuery and then
updating it with the content of PackageSet.
  • Loading branch information
m-blaha authored and j-mracek committed Mar 21, 2023
1 parent 4fd17fc commit 5bc0353
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/libdnf/rpm/package_query.hpp
Expand Up @@ -58,6 +58,13 @@ class PackageQuery : public PackageSet {
explicit PackageQuery(
const libdnf::BaseWeakPtr & base, ExcludeFlags flags = ExcludeFlags::APPLY_EXCLUDES, bool empty = false);
explicit PackageQuery(libdnf::Base & base, ExcludeFlags flags = ExcludeFlags::APPLY_EXCLUDES, bool empty = false);

/// Construct a new PackageQuery based on given PackageSet. This is a shortcut to creating
/// an empty PackageQuery and then updating it with the content of pkgset.
/// @param pkgset A packageset that the new query will contain
/// @param flags Which excludes the query respects
explicit PackageQuery(const PackageSet & pkgset, ExcludeFlags flags = ExcludeFlags::APPLY_EXCLUDES);

PackageQuery(const PackageQuery & src);
PackageQuery(PackageQuery && src) noexcept;
~PackageQuery();
Expand Down
5 changes: 5 additions & 0 deletions libdnf/rpm/package_query.cpp
Expand Up @@ -267,6 +267,11 @@ PackageQuery::PackageQuery(const BaseWeakPtr & base, ExcludeFlags flags, bool em
PackageQuery::PackageQuery(libdnf::Base & base, ExcludeFlags flags, bool empty)
: PackageQuery(base.get_weak_ptr(), flags, empty) {}

PackageQuery::PackageQuery(const PackageSet & pkgset, ExcludeFlags flags)
: PackageQuery(pkgset.get_base(), flags, true) {
update(pkgset);
}

PackageQuery::PackageQuery(const PackageQuery & src) : PackageSet(src), p_pq_impl(new PQImpl(*src.p_pq_impl)) {}

PackageQuery::PackageQuery(PackageQuery && src) noexcept = default;
Expand Down

0 comments on commit 5bc0353

Please sign in to comment.