libzypp  17.32.4
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>
19 #include <zypp/sat/Pool.h>
20 
21 
22 using std::endl;
23 using namespace zypp::packagedelta;
24 
26 namespace zypp
27 {
28  namespace repo
30  {
31 
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  };
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 
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  {
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
117 } // namespace zypp
Candidate delta and patches for a package.
const Edition & edition() const
Definition: PackageDelta.h:65
TraitsType::constPtrType constPtr
Definition: Package.h:38
Impl * clone() const
clone for RWCOW_pointer
friend std::ostream & operator<<(std::ostream &str, const DeltaCandidates &obj)
static const SolvAttr repositoryDeltaInfo
Definition: SolvAttr.h:169
RWCOW_pointer< Impl > _pimpl
Pointer to implementation.
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
Definition: Easy.h:28
String related utilities and Regular expression matching.
Definition: Arch.h:363
Impl(std::list< Repository > &&repos, std::string &&pkgname="")
std::list< packagedelta::DeltaRpm > deltaRpms(const Package::constPtr &package) const
std::ostream & operator<<(std::ostream &str, const DeltaCandidates::Impl &obj)
iterator end() const
Iterator behind the end of query results.
Definition: LookupAttr.cc:240
Solvable attribute keys.
Definition: SolvAttr.h:40
Lightweight repository attribute value lookup.
Definition: LookupAttr.h:263
DeltaCandidates implementation.
std::list< Repository > repos
const Arch & arch() const
Definition: PackageDelta.h:66
const std::string & name() const
Definition: PackageDelta.h:64
Easy-to use interface to the ZYPP dependency resolver.
Definition: Application.cc:19
iterator begin() const
Iterator to the begin of query results.
Definition: LookupAttr.cc:237
#define DBG
Definition: Logger.h:95