- Create the cache directly from the schema (installed) file.
[platform/upstream/libzypp.git] / zypp / CapFilters.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/CapFilters.h
10  *
11 */
12 #ifndef ZYPP_CAPFILTERS_H
13 #define ZYPP_CAPFILTERS_H
14
15 #include "zypp/base/Functional.h"
16 #include "zypp/Capability.h"
17
18 ///////////////////////////////////////////////////////////////////
19 namespace zypp
20 { /////////////////////////////////////////////////////////////////
21   ///////////////////////////////////////////////////////////////////
22   namespace capfilter
23   { /////////////////////////////////////////////////////////////////
24
25     /** \defgroup CAPFILTERS Filter functors operating on Capability.
26      * \ingroup g_Functor
27     */
28     //@{
29
30     /** */
31     typedef std::unary_function<Capability, bool> CapabilityFilterFunctor;
32
33     /** */
34     struct ByRefers : public CapabilityFilterFunctor
35     {
36       bool operator()( const Capability & c ) const
37       {
38         return c.refers() == _refers;
39       }
40
41       ByRefers( Resolvable::Kind refers_r )
42       : _refers( refers_r )
43       {}
44       ByRefers( ResObject::constPtr p )
45       : _refers( p->kind() )
46       {}
47       ByRefers( const Capability & cap_r )
48       : _refers( cap_r.refers() )
49       {}
50       Resolvable::Kind _refers;
51     };
52
53     /** */
54     struct ByIndex : public CapabilityFilterFunctor
55     {
56       bool operator()( const Capability & c ) const
57       {
58         return c.index() == _index;
59       }
60
61       ByIndex( const std::string & index_r )
62       : _index( index_r )
63       {}
64       ByIndex( const Capability & cap_r )
65       : _index( cap_r.index() )
66       {}
67       std::string _index;
68     };
69
70     /** */
71     struct ByCapMatch : public CapabilityFilterFunctor
72     {
73       bool operator()( const Capability & c ) const
74       {
75         return _lhs.matches( c ) == _expect;
76       }
77
78       ByCapMatch( const Capability & cap_r, CapMatch expect_r = CapMatch::yes )
79       : _lhs( cap_r )
80       , _expect( expect_r )
81       {}
82       Capability _lhs;
83       CapMatch   _expect;
84     };
85
86     //@}
87     /////////////////////////////////////////////////////////////////
88   } // namespace capfilter
89   ///////////////////////////////////////////////////////////////////^
90   /////////////////////////////////////////////////////////////////
91 } // namespace zypp
92 ///////////////////////////////////////////////////////////////////
93 #endif // ZYPP_CAPFILTERS_H