Imported Upstream version 14.45.0
[platform/upstream/libzypp.git] / zypp / ResFilters.h
index 212825c..c7a6db2 100644 (file)
@@ -15,6 +15,7 @@
 #include <boost/function.hpp>
 
 #include "zypp/base/Functional.h"
+#include "zypp/Filter.h"
 #include "zypp/Resolvable.h"
 
 #include "zypp/PoolItem.h"
@@ -74,19 +75,19 @@ namespace zypp
      *
      * // print and count all Packages named "kernel"
      * counter = 0;
-     * store.forEach( chain( ByKind(ResTraits<Package>::kind),
+     * store.forEach( chain( ByKind(ResKind::package),
      *                       ByName("kernel") ),
      *                PrintAndCount(counter) );
      *
      * // print and count all Packages not named "kernel"
      * counter = 0;
-     * store.forEach( chain( ByKind(ResTraits<Package>::kind),
+     * store.forEach( chain( ByKind(ResKind::package),
      *                       not_c(ByName("kernel")) ),
      *                PrintAndCount(counter) );
      *
      * // same as above ;)
      * counter = 0;
-     * store.forEach( chain( ByKind(ResTraits<Package>::kind),
+     * store.forEach( chain( ByKind(ResKind::package),
      *                       chain( not_c(ByName("kernel")),
      *                              PrintAndCount(counter) ) ),
      *                true_c() );
@@ -136,6 +137,8 @@ namespace zypp
      * If you look at a functor, you'll see that it contains both, the function
      * to call (it's <tt>operator()</tt> ) and the data you'd otherwise pass as
      * <tt>void * data</tt>. That's nice and safe.
+     *
+     * \todo migrate to namespace filter and enhance to support Solvables as well.
     */
     //@{
     ///////////////////////////////////////////////////////////////////
@@ -148,25 +151,10 @@ namespace zypp
     typedef std::unary_function<ResObject::constPtr, bool> ResObjectFilterFunctor;
     typedef boost::function<bool ( ResObject::constPtr )> ResFilter;
 
-    /** Select ResObject by kind. */
-    struct ByKind : public ResObjectFilterFunctor
-    {
-      ByKind( const ResObject::Kind & kind_r )
-      : _kind( kind_r )
-      {}
-
-      bool operator()( ResObject::constPtr p ) const
-      {
-        return p->kind() == _kind;
-      }
-
-      ResObject::Kind _kind;
-    };
-
     /** */
     template<class _Res>
-      inline ByKind byKind()
-      { return ByKind( ResTraits<_Res>::kind ); }
+      inline filter::ByKind byKind()
+      { return filter::ByKind( ResTraits<_Res>::kind ); }
 
     /** Select ResObject by name. */
     struct ByName : public ResObjectFilterFunctor
@@ -357,7 +345,7 @@ namespace zypp
       {
        return p.status().isSuggested();
       }
-    };      
+    };
 
     //@}
     /////////////////////////////////////////////////////////////////