Add Selectable::highestAvailableVersionObj. (bnc #557557)
authorMichael Andres <ma@suse.de>
Wed, 2 Dec 2009 12:14:10 +0000 (13:14 +0100)
committerMichael Andres <ma@suse.de>
Wed, 2 Dec 2009 12:21:39 +0000 (13:21 +0100)
zypp/ui/Selectable.cc
zypp/ui/Selectable.h
zypp/ui/SelectableImpl.h

index 04d0534..6283a17 100644 (file)
@@ -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 ); }
 
index 82f97dd..875e086 100644 (file)
@@ -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
index e5167a2..ef71ef7 100644 (file)
@@ -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
        */