00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include <iostream>
00011 #include "zypp/base/Logger.h"
00012
00013 #include "zypp/repo/DeltaCandidates.h"
00014
00015 using std::endl;
00016 using namespace zypp::packagedelta;
00017
00019 namespace zypp
00020 {
00021
00022 namespace repo
00023 {
00024
00026 struct DeltaCandidates::Impl
00027 {
00028
00029 public:
00030
00031 Impl( const std::list<Repository> & repos )
00032 : repos(repos)
00033 {
00034
00035 }
00036
00037 friend Impl * rwcowClone<Impl>( const Impl * rhs );
00039 Impl * clone() const
00040 { return new Impl( *this ); }
00041
00042 std::list<Repository> repos;
00043 };
00045
00047 inline std::ostream & operator<<( std::ostream & str, const DeltaCandidates::Impl & obj )
00048 {
00049 return str << "DeltaCandidates::Impl";
00050 }
00051
00052 DeltaCandidates::DeltaCandidates(const std::list<Repository> & repos)
00053 : _pimpl( new Impl(repos) )
00054 {}
00055
00056 DeltaCandidates::~DeltaCandidates()
00057 {}
00058
00059 std::list<PatchRpm> DeltaCandidates::patchRpms(const Package::constPtr & package ) const
00060 {
00061 std::list<PatchRpm> candidates;
00062
00063
00064 for ( std::list<Repository>::const_iterator it = _pimpl->repos.begin();
00065 it != _pimpl->repos.end();
00066 ++it )
00067 {
00068
00069 std::list<PatchRpm> candidates_in_repo = (*it).patchRpms();
00070 for ( std::list<PatchRpm>::const_iterator dit = candidates_in_repo.begin();
00071 dit != candidates_in_repo.end();
00072 ++dit )
00073 {
00074 if ( ! package
00075 || ( package->name() == dit->name()
00076 && package->edition() == dit->edition()
00077 && package->arch() == dit->arch() ) )
00078 {
00079 candidates.push_back( *dit );
00080 }
00081 }
00082 }
00083 return candidates;
00084 }
00085
00086 std::list<DeltaRpm> DeltaCandidates::deltaRpms(const Package::constPtr & package) const
00087 {
00088 std::list<DeltaRpm> candidates;
00089
00090
00091 for ( std::list<Repository>::const_iterator it = _pimpl->repos.begin();
00092 it != _pimpl->repos.end();
00093 ++it )
00094 {
00095
00096 std::list<DeltaRpm> candidates_in_repo = (*it).deltaRpms();
00097 for ( std::list<DeltaRpm>::const_iterator dit = candidates_in_repo.begin();
00098 dit != candidates_in_repo.end();
00099 ++dit )
00100 {
00101 if ( ! package
00102 || ( package->name() == dit->name()
00103 && package->edition() == dit->edition()
00104 && package->arch() == dit->arch() ) )
00105 {
00106 candidates.push_back( *dit );
00107 }
00108 }
00109 }
00110 return candidates;
00111 }
00112
00113 std::ostream & operator<<( std::ostream & str, const DeltaCandidates & obj )
00114 {
00115 return str << *obj._pimpl;
00116 }
00117
00119 }
00122 }