diff --git a/include/libdnf5/comps/environment/query.hpp b/include/libdnf5/comps/environment/query.hpp
index b7d239232..c64aedece 100644
--- a/include/libdnf5/comps/environment/query.hpp
+++ b/include/libdnf5/comps/environment/query.hpp
@@ -22,7 +22,6 @@ along with libdnf. If not, see .
#include "libdnf5/base/base_weak.hpp"
#include "libdnf5/common/sack/query.hpp"
-#include "libdnf5/common/weak_ptr.hpp"
#include "libdnf5/comps/environment/environment.hpp"
#include
@@ -32,42 +31,34 @@ along with libdnf. If not, see .
namespace libdnf5::comps {
-
class EnvironmentQuery : public libdnf5::sack::Query {
public:
// Create new query with newly composed environments (using only solvables from currently enabled repositories)
explicit EnvironmentQuery(const libdnf5::BaseWeakPtr & base, bool empty = false);
explicit EnvironmentQuery(libdnf5::Base & base, bool empty = false);
- void filter_environmentid(const std::string & pattern, sack::QueryCmp cmp = libdnf5::sack::QueryCmp::EQ) {
- filter(F::environmentid, pattern, cmp);
- }
+ ~EnvironmentQuery();
- void filter_environmentid(
- const std::vector & patterns, sack::QueryCmp cmp = libdnf5::sack::QueryCmp::EQ) {
- filter(F::environmentid, patterns, cmp);
- }
+ EnvironmentQuery(const EnvironmentQuery & src);
+ EnvironmentQuery & operator=(const EnvironmentQuery & src);
- void filter_name(const std::string & pattern, sack::QueryCmp cmp = libdnf5::sack::QueryCmp::EQ) {
- filter(F::name, pattern, cmp);
- }
+ EnvironmentQuery(EnvironmentQuery && src) noexcept;
+ EnvironmentQuery & operator=(EnvironmentQuery && src) noexcept;
- void filter_name(const std::vector & patterns, sack::QueryCmp cmp = libdnf5::sack::QueryCmp::EQ) {
- filter(F::name, patterns, cmp);
- }
+ void filter_environmentid(const std::string & pattern, sack::QueryCmp cmp = libdnf5::sack::QueryCmp::EQ);
+ void filter_environmentid(
+ const std::vector & patterns, sack::QueryCmp cmp = libdnf5::sack::QueryCmp::EQ);
- void filter_installed(bool value) { filter(F::is_installed, value, sack::QueryCmp::EQ); }
+ void filter_name(const std::string & pattern, sack::QueryCmp cmp = libdnf5::sack::QueryCmp::EQ);
-private:
- struct F {
- static std::string environmentid(const Environment & obj) { return obj.get_environmentid(); }
- static std::string name(const Environment & obj) { return obj.get_name(); }
- static bool is_installed(const Environment & obj) { return obj.get_installed(); }
- };
+ void filter_name(const std::vector & patterns, sack::QueryCmp cmp = libdnf5::sack::QueryCmp::EQ);
- libdnf5::BaseWeakPtr base;
+ void filter_installed(bool value);
+private:
friend Environment;
+ class Impl;
+ std::unique_ptr p_impl;
};
diff --git a/libdnf5/comps/environment/query.cpp b/libdnf5/comps/environment/query.cpp
index 6b70380e7..02285172a 100644
--- a/libdnf5/comps/environment/query.cpp
+++ b/libdnf5/comps/environment/query.cpp
@@ -37,8 +37,23 @@ extern "C" {
namespace libdnf5::comps {
+class EnvironmentQuery::Impl {
+public:
+ explicit Impl(const libdnf5::BaseWeakPtr & base) : base(base) {}
-EnvironmentQuery::EnvironmentQuery(const BaseWeakPtr & base, bool empty) : base(base) {
+private:
+ friend EnvironmentQuery;
+
+ struct F {
+ static std::string environmentid(const Environment & obj) { return obj.get_environmentid(); }
+ static std::string name(const Environment & obj) { return obj.get_name(); }
+ static bool is_installed(const Environment & obj) { return obj.get_installed(); }
+ };
+
+ libdnf5::BaseWeakPtr base;
+};
+
+EnvironmentQuery::EnvironmentQuery(const BaseWeakPtr & base, bool empty) : p_impl(std::make_unique(base)) {
if (empty) {
return;
}
@@ -101,5 +116,45 @@ EnvironmentQuery::EnvironmentQuery(const BaseWeakPtr & base, bool empty) : base(
EnvironmentQuery::EnvironmentQuery(Base & base, bool empty) : EnvironmentQuery(base.get_weak_ptr(), empty) {}
+EnvironmentQuery::~EnvironmentQuery() = default;
+
+EnvironmentQuery::EnvironmentQuery(const EnvironmentQuery & src)
+ : libdnf5::sack::Query(src),
+ p_impl(new Impl(*src.p_impl)) {}
+EnvironmentQuery::EnvironmentQuery(EnvironmentQuery && src) noexcept = default;
+
+EnvironmentQuery & EnvironmentQuery::operator=(const EnvironmentQuery & src) {
+ libdnf5::sack::Query::operator=(src);
+ if (this != &src) {
+ if (p_impl) {
+ *p_impl = *src.p_impl;
+ } else {
+ p_impl = std::make_unique(*src.p_impl);
+ }
+ }
+
+ return *this;
+}
+EnvironmentQuery & EnvironmentQuery::operator=(EnvironmentQuery && src) noexcept = default;
+
+void EnvironmentQuery::filter_environmentid(const std::string & pattern, sack::QueryCmp cmp) {
+ filter(Impl::F::environmentid, pattern, cmp);
+}
+
+void EnvironmentQuery::filter_environmentid(const std::vector & patterns, sack::QueryCmp cmp) {
+ filter(Impl::F::environmentid, patterns, cmp);
+}
+
+void EnvironmentQuery::filter_name(const std::string & pattern, sack::QueryCmp cmp) {
+ filter(Impl::F::name, pattern, cmp);
+}
+
+void EnvironmentQuery::filter_name(const std::vector & patterns, sack::QueryCmp cmp) {
+ filter(Impl::F::name, patterns, cmp);
+}
+
+void EnvironmentQuery::filter_installed(bool value) {
+ filter(Impl::F::is_installed, value, sack::QueryCmp::EQ);
+}
} // namespace libdnf5::comps