#include <boost/function.hpp>
#include "zypp/base/Functional.h"
+#include "zypp/Filter.h"
#include "zypp/Resolvable.h"
#include "zypp/PoolItem.h"
*
* // 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() );
* 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.
*/
//@{
///////////////////////////////////////////////////////////////////
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
{
return p.status().isSuggested();
}
- };
+ };
//@}
/////////////////////////////////////////////////////////////////