libzypp  13.10.6
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"
18 #include "zypp/sat/Pool.h"
19 
20 
21 using std::endl;
22 using namespace zypp::packagedelta;
23 
25 namespace zypp
26 {
27  namespace repo
29  {
30 
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 
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  {
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
Candidate delta and patches for a package.
std::list< packagedelta::DeltaRpm > deltaRpms(const Package::constPtr &package) const
friend std::ostream & operator<<(std::ostream &str, const DeltaCandidates &obj)
static const SolvAttr repositoryDeltaInfo
Definition: SolvAttr.h:168
Impl * clone() const
clone for RWCOW_pointer
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition: Easy.h:27
const Arch & arch() const
Definition: PackageDelta.h:66
Impl(const std::list< Repository > &repos, const std::string &pkgname="")
std::ostream & operator<<(std::ostream &str, const DeltaCandidates::Impl &obj)
Solvable attribute keys.
Definition: SolvAttr.h:40
iterator end() const
Iterator behind the end of query results.
Definition: LookupAttr.cc:239
const Edition & edition() const
Definition: PackageDelta.h:65
Lightweight repository attribute value lookup.
Definition: LookupAttr.h:260
RepoInfoList repos
Definition: RepoManager.cc:192
DeltaCandidates implementation.
std::list< Repository > repos
const std::string & name() const
Definition: PackageDelta.h:64
TraitsType::constPtrType constPtr
Definition: Package.h:38
#define DBG
Definition: Logger.h:46
iterator begin() const
Iterator to the begin of query results.
Definition: LookupAttr.cc:236