libzypp: zypp/repo/DeltaCandidates.cc Source File

libzypp 17.25.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 <zypp/base/Logger.h>
16 #include <zypp/Repository.h>
17 #include <zypp/repo/DeltaCandidates.h>
18 #include <zypp/sat/Pool.h>
19
20
21 using std::endl;
22 using namespace zypp::packagedelta;
23
25 namespace zypp
26 {
28 namespace repo
29 {
30
32 struct DeltaCandidates::Impl
33 {
34 public:
35 Impl()
36 {}
37
38 Impl( const std::list<Repository> & repos, const std::string & pkgname = "" )
39 : repos(repos), pkgname(pkgname)
40 {}
41
42 std::list<Repository> repos;
43 std::string pkgname;
44
45 private:
46 friend Impl * rwcowClone<Impl>( const Impl * rhs );
48 Impl * clone() const
49 { return new Impl( *this ); }
50 };
52
54 inline std::ostream & operator<<( std::ostream & str, const DeltaCandidates::Impl & obj )
55 {
56 return str << "DeltaCandidates::Impl";
57 }
58
60 //
61 // class DeltaCandidates
62 //
64
65 DeltaCandidates::DeltaCandidates()
66 : _pimpl( new Impl )
67 {}
68
69
70 DeltaCandidates::DeltaCandidates(const std::list<Repository> & repos,
71 const std::string & pkgname)
72 : _pimpl( new Impl(repos, pkgname) )
73 {}
74
75 DeltaCandidates::~DeltaCandidates()
76 {}
77
78 std::list<DeltaRpm> DeltaCandidates::deltaRpms(const Package::constPtr & package) const
79 {
80 std::list<DeltaRpm> candidates;
81
82 DBG << "package: " << package << endl;
83 for_( rit, _pimpl->repos.begin(), _pimpl->repos.end() )
84 {
85 sat::LookupRepoAttr q( sat::SolvAttr::repositoryDeltaInfo, *rit );
86 for_( it, q.begin(), q.end() )
87 {
88 if ( _pimpl->pkgname.empty()
89 || it.subFind( sat::SolvAttr(DELTA_PACKAGE_NAME) ).asString() == _pimpl->pkgname )
90 {
91 DeltaRpm delta( it );
92 //DBG << "checking delta: " << delta << endl;
93 if ( ! package
94 || ( package->name() == delta.name()
95 && package->edition() == delta.edition()
96 && package->arch() == delta.arch() ) )
97 {
98 DBG << "got delta candidate: " << delta << endl;
99 candidates.push_back( delta );
100 }
101 }
102 }
103 }
104 return candidates;
105 }
106
107 std::ostream & operator<<( std::ostream & str, const DeltaCandidates & obj )
108 {
109 return str << *obj._pimpl;
110 }
111
113 } // namespace repo
116 } // namespace zypp
DeltaCandidates.h
for_
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition: Easy.h:28
Logger.h
DBG
#define DBG
Definition: Logger.h:90
Pool.h
repos
RepoInfoList repos
Definition: RepoManager.cc:277
Repository.h
zypp::Package::constPtr
TraitsType::constPtrType constPtr
Definition: Package.h:38
zypp::packagedelta::DeltaRpm
Definition: PackageDelta.h:36
zypp::packagedelta::DeltaRpm::arch
const Arch & arch() const
Definition: PackageDelta.h:66
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::repo::DeltaCandidates
Candidate delta and patches for a package.
Definition: DeltaCandidates.h:37
zypp::repo::DeltaCandidates::deltaRpms
std::list< packagedelta::DeltaRpm > deltaRpms(const Package::constPtr &package) const
Definition: DeltaCandidates.cc:78
zypp::repo::DeltaCandidates::_pimpl
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
Definition: DeltaCandidates.h:58
zypp::repo::DeltaCandidates::~DeltaCandidates
~DeltaCandidates()
Dtor.
Definition: DeltaCandidates.cc:75
zypp::repo::DeltaCandidates::DeltaCandidates
DeltaCandidates()
Definition: DeltaCandidates.cc:65
zypp::repo::DeltaCandidates::operator<<
friend std::ostream & operator<<(std::ostream &str, const DeltaCandidates &obj)
Definition: DeltaCandidates.cc:107
zypp::sat::LookupAttr::end
iterator end() const
Iterator behind the end of query results.
Definition: LookupAttr.cc:239
zypp::sat::LookupAttr::begin
iterator begin() const
Iterator to the begin of query results.
Definition: LookupAttr.cc:236
zypp::sat::LookupRepoAttr
Lightweight repository attribute value lookup.
Definition: LookupAttr.h:258
zypp::sat::SolvAttr
Solvable attribute keys.
Definition: SolvAttr.h:41
zypp::sat::SolvAttr::repositoryDeltaInfo
static const SolvAttr repositoryDeltaInfo
Definition: SolvAttr.h:162
str
String related utilities and Regular expression matching.
zypp::packagedelta
Definition: PackageDelta.cc:33
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
zypp::repo::DeltaCandidates::Impl
DeltaCandidates implementation.
Definition: DeltaCandidates.cc:33
zypp::repo::DeltaCandidates::Impl::Impl
Impl(const std::list< Repository > &repos, const std::string &pkgname="")
Definition: DeltaCandidates.cc:38
zypp::repo::DeltaCandidates::Impl::repos
std::list< Repository > repos
Definition: DeltaCandidates.cc:42
zypp::repo::DeltaCandidates::Impl::clone
Impl * clone() const
clone for RWCOW_pointer
Definition: DeltaCandidates.cc:48
zypp::repo::DeltaCandidates::Impl::pkgname
std::string pkgname
Definition: DeltaCandidates.cc:43
zypp::repo::DeltaCandidates::Impl::Impl
Impl()
Definition: DeltaCandidates.cc:35
zypp::repo::DeltaCandidates::Impl::operator<<
std::ostream & operator<<(std::ostream &str, const DeltaCandidates::Impl &obj)
Stream output.
Definition: DeltaCandidates.cc:54