From d5d6ed86a3307879e4923b9250f25515e2e81cfc Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Wed, 2 Dec 2009 13:14:10 +0100 Subject: [PATCH] Add Selectable::highestAvailableVersionObj. (bnc #557557) --- zypp/ui/Selectable.cc | 3 +++ zypp/ui/Selectable.h | 7 +++++++ zypp/ui/SelectableImpl.h | 12 ++++++++++++ 3 files changed, 22 insertions(+) diff --git a/zypp/ui/Selectable.cc b/zypp/ui/Selectable.cc index 04d0534..6283a17 100644 --- a/zypp/ui/Selectable.cc +++ b/zypp/ui/Selectable.cc @@ -79,6 +79,9 @@ namespace zypp PoolItem Selectable::updateCandidateObj() const { return _pimpl->updateCandidateObj(); } + PoolItem Selectable::highestAvailableVersionObj() const + { return _pimpl->highestAvailableVersionObj(); } + bool Selectable::identicalInstalled( const PoolItem & rhs ) const { return _pimpl->identicalInstalled( rhs ); } diff --git a/zypp/ui/Selectable.h b/zypp/ui/Selectable.h index 82f97dd..875e086 100644 --- a/zypp/ui/Selectable.h +++ b/zypp/ui/Selectable.h @@ -140,6 +140,13 @@ namespace zypp */ PoolItem updateCandidateObj() const; + /** Simply the highest available version, ignoring priorities and policies. + * It's doubtful whether solely looking at the version makes a good + * candidate, but apps ask for it. Beware that different vendors may + * use different (uncomparable) version schemata. + */ + PoolItem highestAvailableVersionObj() const; + /** \c True if \a rhs has the same content as an installed one. * Basically the same name, edition, arch, vendor and buildtime. * \see \ref sat::Solvable::identical diff --git a/zypp/ui/SelectableImpl.h b/zypp/ui/SelectableImpl.h index e5167a2..ef71ef7 100644 --- a/zypp/ui/SelectableImpl.h +++ b/zypp/ui/SelectableImpl.h @@ -168,6 +168,18 @@ namespace zypp return _defaultCandidate; } + /** \copydoc Selectable::highestAvailableVersionObj() */ + PoolItem highestAvailableVersionObj() const + { + PoolItem ret; + for_( it, availableBegin(), availableEnd() ) + { + if ( !ret || (*it).satSolvable().edition() > ret.satSolvable().edition() ) + ret = *it; + } + return ret; + } + /** \c True if \a rhs has the same content as an installed one. * \see \ref sat::Solvable::identical */ -- 2.7.4