libzypp  11.13.5
ResFilters.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_RESFILTERS_H
13 #define ZYPP_RESFILTERS_H
14 
15 #include <boost/function.hpp>
16 
17 #include "zypp/base/Functional.h"
18 #include "zypp/Filter.h"
19 #include "zypp/Resolvable.h"
20 
21 #include "zypp/PoolItem.h"
22 #include "zypp/Repository.h"
23 
25 namespace zypp
26 {
27 
28  namespace resfilter
29  {
30 
144 
145  //
146  // Some ResObject attributes
147  //
149 
151  typedef std::unary_function<ResObject::constPtr, bool> ResObjectFilterFunctor;
152  typedef boost::function<bool ( ResObject::constPtr )> ResFilter;
153 
157  template<class _Res>
160 
163  {
164  ByName( const std::string & name_r )
165  : _name( name_r )
166  {}
167 
169  {
170  return p->name() == _name;
171  }
172 
173  std::string _name;
174  };
175 
178  {
179  ByRepository( Repository repository_r )
180  : _alias( repository_r.info().alias() )
181  {}
182 
183  ByRepository( const std::string & alias_r )
184  : _alias( alias_r )
185  {}
186 
188  {
189  return p->repoInfo().alias() == _alias;
190  }
191 
192  std::string _alias;
193  };
194 
207  template<class _Compare = CompareByEQ<Edition> >
209  {
210  ByEdition( const Edition & edition_r,
211  _Compare cmp_r )
212  : _edition( edition_r )
213  , _cmp( cmp_r )
214  {}
215 
217  {
218  return _cmp( p->edition(), _edition );
219  }
220 
222  _Compare _cmp;
223  };
224 
226  template<class _Compare>
227  ByEdition<_Compare> byEdition( const Edition & edition_r, _Compare cmp_r )
228  { return ByEdition<_Compare>( edition_r, cmp_r ); }
229 
231  template<class _Compare>
232  ByEdition<_Compare> byEdition( const Edition & edition_r )
233  { return byEdition( edition_r, _Compare() ); }
234 
235 
248  template<class _Compare = CompareByEQ<Arch> >
250  {
251  ByArch( const Arch & arch_r,
252  _Compare cmp_r )
253  : _arch( arch_r )
254  , _cmp( cmp_r )
255  {}
256 
258  {
259  return _cmp( p->arch(), _arch );
260  }
261 
263  _Compare _cmp;
264  };
265 
267  template<class _Compare>
268  ByArch<_Compare> byArch( const Arch & arch_r, _Compare cmp_r )
269  { return ByArch<_Compare>( arch_r, cmp_r ); }
270 
272  template<class _Compare>
273  ByArch<_Compare> byArch( const Arch & arch_r )
274  { return byArch( arch_r, _Compare() ); }
275 
276 
278 
280  //
281  // Some PoolItem attributes
282  //
284 
286  typedef std::unary_function<PoolItem, bool> PoolItemFilterFunctor;
287 
290  {
291  bool operator()( const PoolItem & p ) const
292  {
293  return p.status().isInstalled();
294  }
295 
296  };
297 
300  {
301  bool operator()( const PoolItem & p ) const
302  {
303  return p.status().isUninstalled();
304  }
305  };
306 
309  {
310  bool operator()( const PoolItem & p ) const
311  {
312  return p.status().transacts();
313  }
314  };
315 
318  {
319  bool operator()( const PoolItem & p ) const
320  {
321  return p.status().isLocked();
322  }
323  };
324 
327  {
328  bool operator()( const PoolItem & p ) const
329  {
330  return p.status().isKept();
331  }
332  };
333 
336  {
337  bool operator()( const PoolItem & p ) const
338  {
339  return p.status().isRecommended();
340  }
341  };
342 
345  {
346  bool operator()( const PoolItem & p ) const
347  {
348  return p.status().isSuggested();
349  }
350  };
351 
353 
354  } // namespace resfilter
357 } // namespace zypp
359 #endif // ZYPP_RESFILTERS_H