added ResPool::find( const sat::Solvable & )
authorMichael Andres <ma@suse.de>
Tue, 27 Nov 2007 10:50:59 +0000 (10:50 +0000)
committerMichael Andres <ma@suse.de>
Tue, 27 Nov 2007 10:50:59 +0000 (10:50 +0000)
zypp/ResPool.cc
zypp/ResPool.h
zypp/pool/PoolImpl.cc
zypp/pool/PoolImpl.h

index b0c75ac..aab4fca 100644 (file)
@@ -73,6 +73,9 @@ namespace zypp
   bool ResPool::empty() const
   { return _pimpl->empty(); }
 
+  PoolItem ResPool::find( const sat::Solvable & slv_r ) const
+  { return _pimpl->find( slv_r ); }
+
   ResPool::size_type ResPool::size() const
   { return _pimpl->size(); }
 
index 04cc6f7..aebe052 100644 (file)
 ///////////////////////////////////////////////////////////////////
 namespace zypp
 { /////////////////////////////////////////////////////////////////
+  ///////////////////////////////////////////////////////////////////
+  namespace sat
+  { /////////////////////////////////////////////////////////////////
+    class Solvable;
+    /////////////////////////////////////////////////////////////////
+  } // namespace sat
+  ///////////////////////////////////////////////////////////////////
 
   class SerialNumber;
 
@@ -65,9 +72,17 @@ namespace zypp
 
     /** Wheter in sync with sat-pool. */
     bool satSynced() const;
+
     /** Sync with sat-pool. */
     void satSync() const;
 
+    /** Return the corresponding \ref PoolItem.
+     * Pool and sat pool should be in sync. Returns an empty
+     * \ref PoolItem if there is no corresponding \ref PoolItem.
+     * \see \ref PoolItem::satSolvable.
+    */
+    PoolItem find( const sat::Solvable & slv_r ) const;
+
   public:
     /**  */
     bool empty() const;
index 2dc6a23..87cae3b 100644 (file)
@@ -266,6 +266,24 @@ namespace zypp
       //MIL << "Pool: " << _serial << ": In sync with sat-pool " << _satSyncRequired << endl;
     }
 
+    ///////////////////////////////////////////////////////////////////
+    //
+    // METHOD NAME : PoolImpl::satSync
+    // METHOD TYPE : void
+    //
+    PoolItem PoolImpl::find( const sat::Solvable & slv_r ) const
+    {
+      if ( slv_r )
+      {
+        for_( it, begin(), end() )
+        {
+          if ( (*it).satSolvable() == slv_r )
+            return *it;
+        }
+      }
+      return PoolItem();
+    }
+
     /******************************************************************
     **
     ** FUNCTION NAME : operator<<
index fbabc91..d9d347f 100644 (file)
@@ -334,6 +334,13 @@ namespace zypp
       /** Sync with sat-pool. */
       void satSync() const;
 
+      /** Return the corresponding \ref PoolItem.
+       * Pool and sat pool should be in sync. Returns an empty
+       * \ref PoolItem if there is no corresponding \ref PoolItem.
+       * \see \ref PoolItem::satSolvable.
+       */
+      PoolItem find( const sat::Solvable & slv_r ) const;
+
     private:
       /** Serial number. */
       SerialNumber        _serial;