Selectable: add candidateObjFrom: The best candidate provided by a specific Repository.
authorMichael Andres <ma@suse.de>
Thu, 22 Oct 2009 12:31:10 +0000 (14:31 +0200)
committerMichael Andres <ma@suse.de>
Thu, 22 Oct 2009 12:31:10 +0000 (14:31 +0200)
zypp/ui/Selectable.cc
zypp/ui/Selectable.h
zypp/ui/SelectableImpl.h

index 62bf2ea..2f2cba0 100644 (file)
@@ -73,6 +73,9 @@ namespace zypp
     PoolItem Selectable::candidateObj() const
     { return _pimpl->candidateObj(); }
 
+    PoolItem Selectable::candidateObjFrom( Repository repo_r ) const
+    { return _pimpl->candidateObjFrom( repo_r ); }
+
     PoolItem Selectable::updateCandidateObj() const
     { return _pimpl->updateCandidateObj(); }
 
index c5cd548..92b0bf5 100644 (file)
@@ -125,6 +125,13 @@ namespace zypp
        */
       PoolItem candidateObj() const;
 
+      /** The best candidate provided by a specific \ref Repository, if there is one.
+       * In contrary to \ref candidateObj, this may return no item even if
+       * there are available objects. This simply means the \ref Repository
+       * does not provide this object.
+       */
+      PoolItem candidateObjFrom( Repository repo_r ) const;
+
       /** The best candidate for update, if there is one.
        * In contrary to \ref candidateObj, this may return no item even if
        * there are available objects. This simply means the best object is
@@ -133,6 +140,7 @@ namespace zypp
        */
       PoolItem updateCandidateObj() const;
 
+
       /** Return the \ref installedObj resolvable casted to a specific kind.
        * \code
        *   Selectable mySelectable;
index 53f4db8..c74ed90 100644 (file)
@@ -117,6 +117,21 @@ namespace zypp
       */
       PoolItem setCandidate( const PoolItem & newCandidate_r, ResStatus::TransactByValue causer_r );
 
+      /** The best candidate provided by a specific \ref Repository, if there is one.
+       * In contrary to \ref candidateObj, this may return no item even if
+       * there are available objects. This simply means the \ref Repository
+       * does not provide this object.
+       */
+      PoolItem candidateObjFrom( Repository repo_r ) const
+      {
+        for_( it, availableBegin(), availableEnd() )
+        {
+          if ( (*it)->repository() == repo_r )
+            return *it;
+        }
+        return PoolItem();
+      }
+
       /** The best candidate for update, if there is one.
        * In contrary to \ref candidateObj, this may return no item even if
        * there are available objects. This simply means the best object is