libzypp  11.13.5
Filter.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_FILTER_H
13 #define ZYPP_FILTER_H
14 
15 #include <iosfwd>
16 
17 #include "zypp/base/Functional.h"
18 #include "zypp/base/Function.h"
19 // #include "zypp/ResFilters.h" included at the end!
20 #include "zypp/sat/Pool.h"
21 #include "zypp/PoolItem.h"
22 
24 namespace zypp
25 {
26 
27  namespace filter
28  {
29 
55 
57  //
58  // CLASS NAME : ByLocaleSupport
59  //
63  {
64  private:
65  typedef bool (sat::Solvable::*LS1) (const Locale &) const;
66  typedef bool (sat::Solvable::*LS2) (const LocaleSet &) const;
67 
68  public:
71  : _sel( boost::mem_fun_ref( &sat::Solvable::supportsLocales ) )
72  {}
73 
75  explicit ByLocaleSupport( const Locale & locale_r )
76  : _sel( boost::bind( boost::mem_fun_ref( (LS1)&sat::Solvable::supportsLocale ), _1, locale_r ) )
77  {}
78 
80  explicit ByLocaleSupport( const LocaleSet & locales_r )
81  : _sel( boost::bind( boost::mem_fun_ref( (LS2)&sat::Solvable::supportsLocale ), _1, locales_r ) )
82  {}
83 
84  public:
86  bool operator()( const sat::Solvable & solv_r ) const
87  { return _sel && _sel( solv_r ); }
88 
90  template<class _Solv>
91  bool operator()( const _Solv & solv_r ) const
92  { return operator()( solv_r.satSolvable() ); }
93 
94  private:
95  function<bool(const sat::Solvable &)> _sel;
96  };
98 
100  //
101  // CLASS NAME : ByKind
102  //
105  class ByKind
106  {
107  public:
108  ByKind( const ResKind & kind_r )
109  : _kind( kind_r )
110  {}
111 
112  public:
114  bool operator()( const sat::Solvable & solv_r ) const
115  { return solv_r.isKind( _kind ); }
116 
118  template<class _Solv>
119  bool operator()( const _Solv & solv_r ) const
120  { return operator()( solv_r.satSolvable() ); }
121 
122  private:
124  };
125 
127  template<class _Res>
128  inline ByKind byKind()
129  { return ByKind( ResTraits<_Res>::kind ); }
131 
133  //
134  // CLASS NAME : ByStatus
135  //
138  class ByStatus
139  {
140  public:
141  typedef bool (ResStatus::*Predicate)() const;
142 
143  public:
144  ByStatus( Predicate pred_r = 0 )
145  : _pred( pred_r )
146  {}
147 
148  public:
150  bool operator()( const PoolItem & pi_r ) const
151  { return _pred && (pi_r.status().*_pred)(); }
152 
154  template<class _Solv>
155  bool operator()( const _Solv & solv_r ) const
156  { return operator()( PoolItem(solv_r) ); }
157 
158  private:
160  };
162 
163 
165  //
166  // CLASS NAME : SameItemAs
167  //
173  {
174  public:
175  SameItemAs( const sat::Solvable & solv_r )
176  : _item( solv_r )
177  {}
178 
180  template<class _Solv>
181  SameItemAs( const _Solv & solv_r )
182  : _item( solv_r.satSolvable() )
183  {}
184 
185  public:
187  bool operator()( const sat::Solvable & solv_r ) const
188  {
189  return solv_r.name() == _item.name()
190  && solv_r.edition() == _item.edition()
191  && solv_r.arch() == _item.arch()
192  && solv_r.vendor() == _item.vendor();
193  }
194 
196  template<class _Solv>
197  bool operator()( const _Solv & solv_r ) const
198  { return operator()( solv_r.satSolvable() ); }
199 
200  private:
202  };
204 
205 
207  } // namespace filter
210 } // namespace zypp
212 
213 #include "zypp/ResFilters.h"
214 
215 #endif // ZYPP_FILTER_H