1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
// Copyright Contributors to the DNF5 project.
// Copyright Contributors to the libdnf project.
// SPDX-License-Identifier: LGPL-2.1-or-later
//
// This file is part of libdnf: https://github.com/rpm-software-management/libdnf/
//
// Libdnf is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 2.1 of the License, or
// (at your option) any later version.
//
// Libdnf is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with libdnf. If not, see <https://www.gnu.org/licenses/>.
#include "libdnf5/advisory/advisory_set.hpp"
#include "advisory/advisory_package_private.hpp"
#include "advisory_set_impl.hpp"
#include "base/base_private.hpp"
#include "solv/solv_map.hpp"
#include "libdnf5/advisory/advisory_set_iterator.hpp"
#include "libdnf5/rpm/nevra.hpp"
namespace libdnf5::advisory {
AdvisorySet::AdvisorySet(const BaseWeakPtr & base) : p_impl(new Impl(base)) {}
AdvisorySet::AdvisorySet(libdnf5::Base & base) : AdvisorySet(base.get_weak_ptr()) {}
AdvisorySet::AdvisorySet(const AdvisorySet & other) : p_impl(new Impl(*other.p_impl)) {}
AdvisorySet::AdvisorySet(AdvisorySet && other) noexcept : p_impl(new Impl(std::move(*other.p_impl))) {}
AdvisorySet::AdvisorySet(const BaseWeakPtr & base, libdnf5::solv::SolvMap & solv_map)
: p_impl(new Impl(base, solv_map)) {}
AdvisorySet::~AdvisorySet() = default;
AdvisorySet & AdvisorySet::operator=(const AdvisorySet & other) {
*p_impl = *other.p_impl;
return *this;
}
AdvisorySet & AdvisorySet::operator=(AdvisorySet && other) {
*p_impl = std::move(*other.p_impl);
return *this;
}
AdvisorySet & AdvisorySet::operator|=(const AdvisorySet & other) {
libdnf_assert_same_base(p_impl->base, other.p_impl->base);
*p_impl |= *other.p_impl;
return *this;
}
AdvisorySet & AdvisorySet::operator-=(const AdvisorySet & other) {
libdnf_assert_same_base(p_impl->base, other.p_impl->base);
*p_impl -= *other.p_impl;
return *this;
}
AdvisorySet & AdvisorySet::operator&=(const AdvisorySet & other) {
libdnf_assert_same_base(p_impl->base, other.p_impl->base);
*p_impl &= *other.p_impl;
return *this;
}
void AdvisorySet::clear() noexcept {
p_impl->clear();
}
bool AdvisorySet::empty() const noexcept {
return p_impl->empty();
}
std::size_t AdvisorySet::size() const noexcept {
return p_impl->size();
}
void AdvisorySet::swap(AdvisorySet & other) noexcept {
p_impl.swap(other.p_impl);
}
void AdvisorySet::add(const Advisory & adv) {
p_impl->add(adv.get_id().id);
}
bool AdvisorySet::contains(const Advisory & adv) const noexcept {
return p_impl->contains(adv.get_id().id);
}
void AdvisorySet::remove(const Advisory & adv) {
p_impl->remove(adv.get_id().id);
}
BaseWeakPtr AdvisorySet::get_base() const {
return p_impl->base;
}
std::vector<AdvisoryPackage> AdvisorySet::get_advisory_packages_sorted_by_name_arch_evr(bool only_applicable) const {
std::vector<AdvisoryPackage> out;
for (Id candidate_id : *p_impl) {
Advisory advisory2 = Advisory(p_impl->base, AdvisoryId(candidate_id));
auto collections = advisory2.get_collections();
for (auto & collection : collections) {
if (only_applicable && !collection.is_applicable()) {
continue;
}
collection.get_packages(out);
}
}
std::sort(out.begin(), out.end(), AdvisoryPackage::Impl::nevra_compare_lower_id);
return out;
}
std::vector<AdvisoryPackage> AdvisorySet::get_advisory_packages_sorted_by_name_arch_evr_string(
bool only_applicable) const {
std::vector<AdvisoryPackage> out;
for (Id candidate_id : *p_impl) {
Advisory advisory2 = Advisory(p_impl->base, AdvisoryId(candidate_id));
auto collections = advisory2.get_collections();
for (auto & collection : collections) {
if (only_applicable && !collection.is_applicable()) {
continue;
}
collection.get_packages(out);
}
}
std::sort(out.begin(), out.end(), libdnf5::rpm::cmp_naevr<AdvisoryPackage>);
return out;
}
} // namespace libdnf5::advisory
|