libzypp  13.10.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 _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
bool operator()(const _Solv &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:55
Arch arch() const
Definition: Solvable.cc:378
sat::Solvable _item
Definition: Filter.h:201
bool(ResStatus::* Predicate)() const
Definition: Filter.h:141
Filter solvables according to their status.
Definition: Filter.h:138
bool(sat::Solvable::* LS2)(const LocaleSet &) const
Definition: Filter.h:66
bool operator()(const _Solv &solv_r) const
Filter fitting PoolItem/ResObject.
Definition: Filter.h:119
ResTraits.
Definition: ResTraits.h:77
ByStatus(Predicate pred_r=0)
Definition: Filter.h:144
bool operator()(const PoolItem &pi_r) const
Filter on PoolItem.
Definition: Filter.h:150
function< bool(const sat::Solvable &)> _sel
Definition: Filter.h:95
ByKind byKind()
Definition: Filter.h:128
SameItemAs(const sat::Solvable &solv_r)
Definition: Filter.h:175
std::string name() const
Definition: Solvable.cc:364
bool operator()(const _Solv &solv_r) const
Filter fitting sat::Solvable/ResObject.
Definition: Filter.h:155
Filter solvables according to their locale support.
Definition: Filter.h:62
ResStatus & status() const
Returns the current status.
Definition: PoolItem.cc:241
std::tr1::unordered_set< Locale > LocaleSet
Definition: Locale.h:28
Filter items with at least same NVRA, vendor.
Definition: Filter.h:172
bool operator()(const sat::Solvable &solv_r) const
Filter on Solvable.
Definition: Filter.h:114
IdString vendor() const
Definition: Solvable.cc:397
bool operator()(const _Solv &solv_r) const
Filter fitting PoolItem/ResObject.
Definition: Filter.h:197
bool(sat::Solvable::* LS1)(const Locale &) const
Definition: Filter.h:65
SameItemAs(const _Solv &solv_r)
Fitting PoolItem/ResObject.
Definition: Filter.h:181
Status bitfield.
Definition: ResStatus.h:53
Reference to a PoolItem connecting ResObject 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:187
bool isKind(const ResKind &kind_r) const
Test whether a Solvable is of a certain ResKind.
Definition: Solvable.cc:337
ByLocaleSupport(const Locale &locale_r)
Solvables supporting locale_r.
Definition: Filter.h:75
Resolvable kinds.
Definition: ResKind.h:35
Edition edition() const
Definition: Solvable.cc:372
bool operator()(const sat::Solvable &solv_r) const
Filter on Solvable.
Definition: Filter.h:86
ByKind(const ResKind &kind_r)
Definition: Filter.h:108
Filter solvables according to their kind.
Definition: Filter.h:105