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 #include "zypp/ResObject.h"
00018 
00020 namespace zypp
00021 { 
00022 
00023   namespace capfilter
00024   { 
00025 
00030 
00032     typedef std::unary_function<Capability, bool> CapabilityFilterFunctor;
00033 
00035     struct ByRefers : public CapabilityFilterFunctor
00036     {
00037       bool operator()( const Capability & c ) const
00038       {
00039         return c.refers() == _refers;
00040       }
00041 
00042       ByRefers( Resolvable::Kind refers_r )
00043       : _refers( refers_r )
00044       {}
00045       ByRefers( ResObject::constPtr p )
00046       : _refers( p->kind() )
00047       {}
00048       ByRefers( const Capability & cap_r )
00049       : _refers( cap_r.refers() )
00050       {}
00051       Resolvable::Kind _refers;
00052     };
00053 
00055     struct ByIndex : public CapabilityFilterFunctor
00056     {
00057       bool operator()( const Capability & c ) const
00058       {
00059         return c.index() == _index;
00060       }
00061 
00062       ByIndex( const std::string & index_r )
00063       : _index( index_r )
00064       {}
00065       ByIndex( const Capability & cap_r )
00066       : _index( cap_r.index() )
00067       {}
00068       std::string _index;
00069     };
00070 
00072     struct ByCapMatch : public CapabilityFilterFunctor
00073     {
00074       bool operator()( const Capability & c ) const
00075       {
00076         return _lhs.matches( c ) == _expect;
00077       }
00078 
00079       ByCapMatch( const Capability & cap_r, CapMatch expect_r = CapMatch::yes )
00080       : _lhs( cap_r )
00081       , _expect( expect_r )
00082       {}
00083       Capability _lhs;
00084       CapMatch   _expect;
00085     };
00086 
00088 
00089   } // namespace capfilter
00092 } // namespace zypp
00094 #endif // ZYPP_CAPFILTERS_H

Generated on Tue Sep 25 19:23:00 2007 for libzypp by  doxygen 1.5.3