From: Michael Andres Date: Wed, 2 Dec 2009 12:14:10 +0000 (+0100) Subject: Add Selectable::highestAvailableVersionObj. (bnc #557557) X-Git-Tag: 6.25.0~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d5d6ed86a3307879e4923b9250f25515e2e81cfc;p=platform%2Fupstream%2Flibzypp.git Add Selectable::highestAvailableVersionObj. (bnc #557557) --- 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 */