add lookForReinstall
authorKlaus Kaempf <kkaempf@suse.de>
Thu, 2 Feb 2006 13:52:58 +0000 (13:52 +0000)
committerKlaus Kaempf <kkaempf@suse.de>
Thu, 2 Feb 2006 13:52:58 +0000 (13:52 +0000)
zypp/solver/detail/Helper.cc
zypp/solver/detail/Helper.h

index a7ebf85..3017ef6 100644 (file)
@@ -129,6 +129,37 @@ MIL << "Helper::findUpdateItem(" << item << ") => " << info.uninstalled << endl;
     return info.uninstalled;
 }
 
+
+//----------------------------------------------------------------------------
+
+class LookForReinstall : public resfilter::OnCapMatchCallbackFunctor, public resfilter::PoolItemFilterFunctor
+{
+  public:
+    PoolItem_Ref uninstalled;
+
+    bool operator()( PoolItem_Ref provider )
+    {
+       uninstalled = provider;
+       return false;                           // stop here, we found it
+    }
+};
+
+
+PoolItem_Ref
+Helper::findReinstallItem (const ResPool & pool, PoolItem_Ref item)
+{
+    LookForReinstall info;
+#warning FIXME, should not report locked update candidates.
+    invokeOnEach( pool.byNameBegin( item->name() ),
+                 pool.byNameEnd( item->name() ),
+                 functor::chain (functor::chain (resfilter::ByUninstalled (),                  // ByUninstalled
+                                                 resfilter::ByKind( item->kind() ) ),          // equal kind
+                                 resfilter::byEdition<CompareByEQ<Edition> >( item->edition() )),
+                 functor::functorRef<bool,PoolItem> (info) );
+MIL << "Helper::findReinstallItem(" << item << ") => " << info.uninstalled << endl;
+    return info.uninstalled;
+}
+
 ///////////////////////////////////////////////////////////////////
     };// namespace detail
     /////////////////////////////////////////////////////////////////////
index 490608e..508b95f 100644 (file)
@@ -61,6 +61,9 @@ class Helper {
     // for item, find uninstalled item which has same name and higher edition
     static PoolItem_Ref findUninstalledItem (const ResPool & pool, PoolItem_Ref item);
 
+    // for item, find uninstalled item which has same name and equal edition
+    static PoolItem_Ref findReinstallItem (const ResPool & pool, PoolItem_Ref item);
+
     static PoolItem_Ref findUpdateItem (const ResPool & pool, PoolItem_Ref item);
 
     friend std::ostream& operator<<(std::ostream&, const PoolItemList & itemlist);