use ByInstalled
authorKlaus Kaempf <kkaempf@suse.de>
Thu, 26 Jan 2006 17:03:31 +0000 (17:03 +0000)
committerKlaus Kaempf <kkaempf@suse.de>
Thu, 26 Jan 2006 17:03:31 +0000 (17:03 +0000)
zypp/solver/detail/Helper.cc

index 8782691bef9aaa53774730f055fcc78c1d643745..53ab3b0e367df0bc681ba9d08d79b81e86d99694 100644 (file)
 
 #include "zypp/solver/detail/Helper.h"
 
+#include "zypp/CapSet.h"
+#include "zypp/base/Logger.h"
+#include "zypp/base/String.h"
+#include "zypp/base/Gettext.h"
+
+#include "zypp/base/Algorithm.h"
+#include "zypp/ResPool.h"
+#include "zypp/ResFilters.h"
+#include "zypp/CapFilters.h"
+
+using namespace std;
+
 /////////////////////////////////////////////////////////////////////////
 namespace zypp
 { ///////////////////////////////////////////////////////////////////////
@@ -33,30 +45,44 @@ namespace zypp
     namespace detail
     { ///////////////////////////////////////////////////////////////////
 
-PoolItem
-Helper::findInstalledItem (const ResPool *pool, PoolItem_Ref item)
+ostream &
+operator<< (ostream & os, const PoolItemList & itemlist)
 {
-    struct LookForUpgrades : public resfilter::OnCapMatchCallbackFunctor
-    {
-       PoolItem_Ref installed;
+    for (PoolItemList::const_iterator iter = itemlist.begin(); iter != itemlist.end(); ++iter) {
+       if (iter != itemlist.begin())
+           os << ", ";
+       os << *iter;
+    }
+    return os;
+}
 
-       LookForUpgrades ()
-       { }
 
-       bool operator()( PoolItem_Ref  & provider )
-       {
-           installed = provider;
-           return false;                               // stop here, we found it
-       }
-    };
+struct LookForUpgrades : public resfilter::OnCapMatchCallbackFunctor, public resfilter::PoolItemFilterFunctor
+{
+    PoolItem_Ref installed;
 
+    LookForUpgrades ()
+    { }
+
+    bool operator()( PoolItem_Ref provider )
+    {
+       installed = provider;
+       return false;                           // stop here, we found it
+    }
+};
+
+
+PoolItem
+Helper::findInstalledItem (const ResPool *pool, PoolItem_Ref item)
+{
     LookForUpgrades info;
 
-    invokeOnEach( pool->byNameBegin( item->name() ), pool->byNameEnd( item->name() ),
-                 functor::chain( resfilter::ByStatus ( ResStatus::INSTALLED ),
-                                 resfilter::ByKind( item->kind() ),
-                                 resfilter::ByEdition<CompareByLT<Edition> >( item->edition() ),
-                 info );
+    invokeOnEach( pool->byNameBegin( item->name() ),
+                 pool->byNameEnd( item->name() ),
+                 functor::chain( resfilter::ByInstalled (),
+                                 functor::chain (resfilter::ByKind( item->kind() ),
+                                          resfilter::byEdition<CompareByLT<Edition> >( item->edition() ) ) ),
+                 functor::functorRef<bool,PoolItem> (info) );
 
     return info.installed;
 }