1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
11 #include <satsolver/knownid.h>
15 #include "zypp/base/Logger.h"
16 #include "zypp/Repository.h"
17 #include "zypp/repo/DeltaCandidates.h"
18 #include "zypp/sat/Pool.h"
22 using namespace zypp::packagedelta;
24 ///////////////////////////////////////////////////////////////////
26 { /////////////////////////////////////////////////////////////////
27 ///////////////////////////////////////////////////////////////////
29 { /////////////////////////////////////////////////////////////////
31 /** DeltaCandidates implementation. */
32 struct DeltaCandidates::Impl
38 Impl( const std::list<Repository> & repos, const std::string & pkgname = "" )
39 : repos(repos), pkgname(pkgname)
42 std::list<Repository> repos;
46 friend Impl * rwcowClone<Impl>( const Impl * rhs );
47 /** clone for RWCOW_pointer */
49 { return new Impl( *this ); }
51 ///////////////////////////////////////////////////////////////////
53 /** \relates DeltaCandidates::Impl Stream output */
54 inline std::ostream & operator<<( std::ostream & str, const DeltaCandidates::Impl & obj )
56 return str << "DeltaCandidates::Impl";
59 ///////////////////////////////////////////////////////////////////
61 // class DeltaCandidates
63 ///////////////////////////////////////////////////////////////////
65 DeltaCandidates::DeltaCandidates()
70 DeltaCandidates::DeltaCandidates(const std::list<Repository> & repos,
71 const std::string & pkgname)
72 : _pimpl( new Impl(repos, pkgname) )
75 DeltaCandidates::~DeltaCandidates()
78 std::list<DeltaRpm> DeltaCandidates::deltaRpms(const Package::constPtr & package) const
80 std::list<DeltaRpm> candidates;
82 DBG << "package: " << package << endl;
83 for_( rit, _pimpl->repos.begin(), _pimpl->repos.end() )
85 sat::LookupRepoAttr q( sat::SolvAttr::repositoryDeltaInfo, *rit );
86 for_( it, q.begin(), q.end() )
88 if ( _pimpl->pkgname.empty()
89 || it.subFind( sat::SolvAttr(DELTA_PACKAGE_NAME) ).asString() == _pimpl->pkgname )
92 //DBG << "checking delta: " << delta << endl;
94 || ( package->name() == delta.name()
95 && package->edition() == delta.edition()
96 && package->arch() == delta.arch() ) )
98 DBG << "got delta candidate: " << delta << endl;
99 candidates.push_back( delta );
107 std::ostream & operator<<( std::ostream & str, const DeltaCandidates & obj )
109 return str << *obj._pimpl;
112 /////////////////////////////////////////////////////////////////
114 ///////////////////////////////////////////////////////////////////
115 /////////////////////////////////////////////////////////////////
117 ///////////////////////////////////////////////////////////////////