libzypp  15.28.6
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  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 TSolv>
91  bool operator()( const TSolv & 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:
109  {}
110 
111  ByKind( const ResKind & kind_r )
112  : _kind( kind_r )
113  {}
114 
115  public:
117  bool operator()( const sat::Solvable & solv_r ) const
118  { return solv_r.isKind( _kind ); }
119 
121  template<class TSolv>
122  bool operator()( const TSolv & solv_r ) const
123  { return operator()( solv_r.satSolvable() ); }
124 
125  private:
127  };
128 
130  template<class TRes>
131  inline ByKind byKind()
132  { return ByKind( ResTraits<TRes>::kind ); }
134 
136  //
137  // CLASS NAME : ByStatus
138  //
141  class ByStatus
142  {
143  public:
144  typedef bool (ResStatus::*Predicate)() const;
145 
146  public:
147  ByStatus( Predicate pred_r = 0 )
148  : _pred( pred_r )
149  {}
150 
151  public:
153  bool operator()( const PoolItem & pi_r ) const
154  { return _pred && (pi_r.status().*_pred)(); }
155 
157  template<class TSolv>
158  bool operator()( const TSolv & solv_r ) const
159  { return operator()( PoolItem(solv_r) ); }
160 
161  private:
163  };
165 
166 
168  //
169  // CLASS NAME : SameItemAs
170  //
176  {
177  public:
178  SameItemAs( const sat::Solvable & solv_r )
179  : _item( solv_r )
180  {}
181 
183  template<class TSolv>
184  SameItemAs( const TSolv & solv_r )
185  : _item( solv_r.satSolvable() )
186  {}
187 
188  public:
190  bool operator()( const sat::Solvable & solv_r ) const
191  {
192  return solv_r.name() == _item.name()
193  && solv_r.edition() == _item.edition()
194  && solv_r.arch() == _item.arch()
195  && solv_r.vendor() == _item.vendor();
196  }
197 
199  template<class TSolv>
200  bool operator()( const TSolv & solv_r ) const
201  { return operator()( solv_r.satSolvable() ); }
202 
203  private:
205  };
207 
208 
210  } // namespace filter
213 } // namespace zypp
215 
216 #include "zypp/ResFilters.h"
217 
218 #endif // ZYPP_FILTER_H
bool operator()(const TSolv &solv_r) const
Filter fitting PoolItem/ResObject.
Definition: Filter.h:91
ByLocaleSupport(const LocaleSet &locales_r)
Solvables supporting at least one locale in locales_r.
Definition: Filter.h:80
A Solvable object within the sat Pool.
Definition: Solvable.h:53
Arch arch() const
The architecture.
Definition: Solvable.cc:331
sat::Solvable _item
Definition: Filter.h:204
bool(ResStatus::* Predicate)() const
Definition: Filter.h:144
Filter solvables according to their status.
Definition: Filter.h:141
bool(sat::Solvable::* LS2)(const LocaleSet &) const
Definition: Filter.h:66
ResTraits.
Definition: ResTraits.h:79
ByStatus(Predicate pred_r=0)
Definition: Filter.h:147
bool operator()(const PoolItem &pi_r) const
Filter on PoolItem.
Definition: Filter.h:153
function< bool(const sat::Solvable &)> _sel
Definition: Filter.h:95
ByKind byKind()
Definition: Filter.h:131
bool operator()(const TSolv &solv_r) const
Filter fitting PoolItem/ResObject.
Definition: Filter.h:200
SameItemAs(const sat::Solvable &solv_r)
Definition: Filter.h:178
std::string name() const
The name (without any ResKind prefix).
Definition: Solvable.cc:317
Filter solvables according to their locale support.
Definition: Filter.h:62
ResStatus & status() const
Returns the current status.
Definition: PoolItem.cc:204
Filter items with at least same NVRA, vendor.
Definition: Filter.h:175
bool operator()(const sat::Solvable &solv_r) const
Filter on Solvable.
Definition: Filter.h:117
bool operator()(const TSolv &solv_r) const
Filter fitting sat::Solvable/ResObject.
Definition: Filter.h:158
'Language[_Country]' codes.
Definition: Locale.h:49
bool operator()(const TSolv &solv_r) const
Filter fitting PoolItem/ResObject.
Definition: Filter.h:122
IdString vendor() const
The vendor.
Definition: Solvable.cc:345
bool(sat::Solvable::* LS1)(const Locale &) const
Definition: Filter.h:65
Status bitfield.
Definition: ResStatus.h:53
Combining sat::Solvable and ResStatus.
Definition: PoolItem.h:50
ByLocaleSupport()
Solvables with locale support.
Definition: Filter.h:70
bool operator()(const sat::Solvable &solv_r) const
Filter on Solvable.
Definition: Filter.h:190
bool isKind(const ResKind &kind_r) const
Test whether a Solvable is of a certain ResKind.
Definition: Solvable.cc:290
SameItemAs(const TSolv &solv_r)
Fitting PoolItem/ResObject.
Definition: Filter.h:184
ByLocaleSupport(const Locale &locale_r)
Solvables supporting locale_r.
Definition: Filter.h:75
Resolvable kinds.
Definition: ResKind.h:32
std::unordered_set< Locale > LocaleSet
Definition: Locale.h:27
Edition edition() const
The edition (version-release).
Definition: Solvable.cc:325
bool operator()(const sat::Solvable &solv_r) const
Filter on Solvable.
Definition: Filter.h:86
ByKind(const ResKind &kind_r)
Definition: Filter.h:111
Filter solvables according to their kind.
Definition: Filter.h:105