libzypp 17.37.10

DeltaCandidates.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
9 extern "C"
10{
11#include <solv/knownid.h>
12}
13
14#include <iostream>
15#include <utility>
16#include <zypp/base/Logger.h>
17#include <zypp/Repository.h>
18#include <zypp/repo/DeltaCandidates.h>
19#include <zypp/sat/Pool.h>
20
21
22 using std::endl;
23 using namespace zypp::packagedelta;
24
26 namespace zypp
27{
29 namespace repo
30 {
31
33 struct DeltaCandidates::Impl
34 {
35 public:
36 Impl()
37 {}
38
39 Impl( std::list<Repository> &&repos, std::string &&pkgname = "" )
40 : repos(std::move(repos)), pkgname(std::move(pkgname))
41 {}
42
43 std::list<Repository> repos;
44 std::string pkgname;
45
46 private:
47 friend Impl * rwcowClone<Impl>( const Impl * rhs );
49 Impl * clone() const
50 { return new Impl( *this ); }
51 };
52
53
55 inline std::ostream & operator<<( std::ostream & str, const DeltaCandidates::Impl & obj )
56 {
57 return str << "DeltaCandidates::Impl";
58 }
59
61 //
62 // class DeltaCandidates
63 //
65
66 DeltaCandidates::DeltaCandidates()
67 : _pimpl( new Impl )
68 {}
69
70
71 DeltaCandidates::DeltaCandidates(std::list<Repository> repos,
72 std::string pkgname)
73 : _pimpl( new Impl(std::move(repos), std::move(pkgname)) )
74 {}
75
76 DeltaCandidates::~DeltaCandidates()
77 {}
78
79 std::list<DeltaRpm> DeltaCandidates::deltaRpms(const Package::constPtr & package) const
80 {
81 std::list<DeltaRpm> candidates;
82
83 DBG << "package: " << package << endl;
84 for_( rit, _pimpl->repos.begin(), _pimpl->repos.end() )
85 {
86 sat::LookupRepoAttr q( sat::SolvAttr::repositoryDeltaInfo, *rit );
87 for_( it, q.begin(), q.end() )
88 {
89 if ( _pimpl->pkgname.empty()
90 || it.subFind( sat::SolvAttr(DELTA_PACKAGE_NAME) ).asString() == _pimpl->pkgname )
91 {
92 DeltaRpm delta( it );
93 //DBG << "checking delta: " << delta << endl;
94 if ( ! package
95 || ( package->name() == delta.name()
96 && package->edition() == delta.edition()
97 && package->arch() == delta.arch() ) )
98 {
99 DBG << "got delta candidate: " << delta << endl;
100 candidates.push_back( delta );
101 }
102 }
103 }
104 }
105 return candidates;
106 }
107
108 std::ostream & operator<<( std::ostream & str, const DeltaCandidates & obj )
109 {
110 return str << *obj._pimpl;
111 }
112
114 } // namespace repo
115
117} // namespace zypp
DeltaCandidates.h
Pool.h
Repository.h
zypp::Package::constPtr
TraitsType::constPtrType constPtr
Definition Package.h:39
zypp::packagedelta::DeltaRpm
Definition PackageDelta.h:36
zypp::packagedelta::DeltaRpm::edition
const Edition & edition() const
Definition PackageDelta.h:65
zypp::packagedelta::DeltaRpm::name
const std::string & name() const
Definition PackageDelta.h:64
zypp::packagedelta::DeltaRpm::arch
const Arch & arch() const
Definition PackageDelta.h:66
zypp::repo::DeltaCandidates::deltaRpms
std::list< packagedelta::DeltaRpm > deltaRpms(const Package::constPtr &package) const
Definition DeltaCandidates.cc:79
zypp::repo::DeltaCandidates::_pimpl
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
Definition DeltaCandidates.h:63
zypp::repo::DeltaCandidates::operator<<
friend std::ostream & operator<<(std::ostream &str, const DeltaCandidates &obj)
Definition DeltaCandidates.cc:108
zypp::repo::DeltaCandidates::~DeltaCandidates
~DeltaCandidates()
Dtor.
Definition DeltaCandidates.cc:76
zypp::repo::DeltaCandidates::DeltaCandidates
DeltaCandidates()
Definition DeltaCandidates.cc:66
zypp::sat::LookupAttr::end
iterator end() const
Iterator behind the end of query results.
Definition LookupAttr.cc:240
zypp::sat::LookupAttr::begin
iterator begin() const
Iterator to the begin of query results.
Definition LookupAttr.cc:237
zypp::sat::LookupRepoAttr
Lightweight repository attribute value lookup.
Definition LookupAttr.h:265
zypp::sat::SolvAttr
Solvable attribute keys.
Definition SolvAttr.h:41
zypp::sat::SolvAttr::repositoryDeltaInfo
static const SolvAttr repositoryDeltaInfo
Definition SolvAttr.h:181
std
Definition Arch.h:364
str
String related utilities and Regular expression matching.
zypp::packagedelta
Definition PackageDelta.cc:33
zypp::repo
Definition DeltaCandidates.cc:30
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
zypp::repo::DeltaCandidates::Impl
DeltaCandidates implementation.
Definition DeltaCandidates.cc:34
zypp::repo::DeltaCandidates::Impl::Impl
Impl(std::list< Repository > &&repos, std::string &&pkgname="")
Definition DeltaCandidates.cc:39
zypp::repo::DeltaCandidates::Impl::repos
std::list< Repository > repos
Definition DeltaCandidates.cc:43
zypp::repo::DeltaCandidates::Impl::pkgname
std::string pkgname
Definition DeltaCandidates.cc:44
zypp::repo::DeltaCandidates::Impl::rwcowClone
friend Impl * rwcowClone(const Impl *rhs)
zypp::repo::DeltaCandidates::Impl::clone
Impl * clone() const
clone for RWCOW_pointer
Definition DeltaCandidates.cc:49
zypp::repo::DeltaCandidates::Impl::Impl
Impl()
Definition DeltaCandidates.cc:36
zypp::repo::DeltaCandidates::Impl::operator<<
std::ostream & operator<<(std::ostream &str, const DeltaCandidates::Impl &obj)
Stream output.
Definition DeltaCandidates.cc:55
for_
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition Easy.h:27
DBG
#define DBG
Definition Logger.h:99
Logger.h