CapFilters.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #ifndef ZYPP_CAPFILTERS_H
00013 #define ZYPP_CAPFILTERS_H
00014 
00015 #include "zypp/base/Functional.h"
00016 #include "zypp/Capability.h"
00017 
00019 namespace zypp
00020 { 
00021 
00022   namespace capfilter
00023   { 
00024 
00029 
00031     typedef std::unary_function<Capability, bool> CapabilityFilterFunctor;
00032 
00034     struct ByRefers : public CapabilityFilterFunctor
00035     {
00036       bool operator()( const Capability & c ) const
00037       {
00038         return c.refers() == _refers;
00039       }
00040 
00041       ByRefers( Resolvable::Kind refers_r )
00042       : _refers( refers_r )
00043       {}
00044       ByRefers( ResObject::constPtr p )
00045       : _refers( p->kind() )
00046       {}
00047       ByRefers( const Capability & cap_r )
00048       : _refers( cap_r.refers() )
00049       {}
00050       Resolvable::Kind _refers;
00051     };
00052 
00054     struct ByIndex : public CapabilityFilterFunctor
00055     {
00056       bool operator()( const Capability & c ) const
00057       {
00058         return c.index() == _index;
00059       }
00060 
00061       ByIndex( const std::string & index_r )
00062       : _index( index_r )
00063       {}
00064       ByIndex( const Capability & cap_r )
00065       : _index( cap_r.index() )
00066       {}
00067       std::string _index;
00068     };
00069 
00071     struct ByCapMatch : public CapabilityFilterFunctor
00072     {
00073       bool operator()( const Capability & c ) const
00074       {
00075         return _lhs.matches( c ) == _expect;
00076       }
00077 
00078       ByCapMatch( const Capability & cap_r, CapMatch expect_r = CapMatch::yes )
00079       : _lhs( cap_r )
00080       , _expect( expect_r )
00081       {}
00082       const Capability & _lhs;
00083       CapMatch           _expect;
00084     };
00085 
00087 
00088   } // namespace capfilter
00091 } // namespace zypp
00093 #endif // ZYPP_CAPFILTERS_H

Generated on Thu Jul 6 00:07:20 2006 for zypp by  doxygen 1.4.6