libzypp  17.14.0
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 
155  template<class TRes>
158 
161  {
163  {}
164 
165  ByName( const std::string & name_r )
166  : _name( name_r )
167  {}
168 
170  {
171  return p->name() == _name;
172  }
173 
174  std::string _name;
175  };
176 
179  {
180  ByRepository( Repository repository_r )
181  : _alias( repository_r.info().alias() )
182  {}
183 
184  ByRepository( const std::string & alias_r )
185  : _alias( alias_r )
186  {}
187 
189  {
190  return p->repoInfo().alias() == _alias;
191  }
192 
193  std::string _alias;
194  };
195 
208  template<class TCompare = CompareByEQ<Edition> >
210  {
211  ByEdition( const Edition & edition_r, TCompare cmp_r )
212  : _edition( edition_r )
213  , _cmp( cmp_r )
214  {}
215 
217  {
218  return _cmp( p->edition(), _edition );
219  }
220 
222  TCompare _cmp;
223  };
224 
226  template<class TCompare>
227  ByEdition<TCompare> byEdition( const Edition & edition_r, TCompare cmp_r )
228  { return ByEdition<TCompare>( edition_r, cmp_r ); }
229 
231  template<class TCompare>
232  ByEdition<TCompare> byEdition( const Edition & edition_r )
233  { return byEdition( edition_r, TCompare() ); }
234 
235 
248  template<class TCompare = CompareByEQ<Arch> >
250  {
251  ByArch( const Arch & arch_r, TCompare cmp_r )
252  : _arch( arch_r )
253  , _cmp( cmp_r )
254  {}
255 
257  {
258  return _cmp( p->arch(), _arch );
259  }
260 
262  TCompare _cmp;
263  };
264 
266  template<class TCompare>
267  ByArch<TCompare> byArch( const Arch & arch_r, TCompare cmp_r )
268  { return ByArch<TCompare>( arch_r, cmp_r ); }
269 
271  template<class TCompare>
272  ByArch<TCompare> byArch( const Arch & arch_r )
273  { return byArch( arch_r, TCompare() ); }
274 
275 
277 
279  //
280  // Some PoolItem attributes
281  //
283 
285  typedef std::unary_function<PoolItem, bool> PoolItemFilterFunctor;
286 
289  {
290  bool operator()( const PoolItem & p ) const
291  {
292  return p.status().isInstalled();
293  }
294  };
295 
298  {
299  bool operator()( const PoolItem & p ) const
300  {
301  return p.status().isUninstalled();
302  }
303  };
304 
307  {
308  bool operator()( const PoolItem & p ) const
309  {
310  return p.status().transacts();
311  }
312  };
313 
316  {
317  bool operator()( const PoolItem & p ) const
318  {
319  return p.status().isLocked();
320  }
321  };
322 
325  {
326  bool operator()( const PoolItem & p ) const
327  {
328  return p.status().isKept();
329  }
330  };
331 
334  {
335  bool operator()( const PoolItem & p ) const
336  {
337  return p.status().isRecommended();
338  }
339  };
340 
343  {
344  bool operator()( const PoolItem & p ) const
345  {
346  return p.status().isSuggested();
347  }
348  };
349 
351 
352  } // namespace resfilter
355 } // namespace zypp
357 #endif // ZYPP_RESFILTERS_H