libzypp  13.10.6
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  namespace resfilter
29  {
30 
144  //
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 _Res>
158 
161  {
162  ByName( const std::string & name_r )
163  : _name( name_r )
164  {}
165 
167  {
168  return p->name() == _name;
169  }
170 
171  std::string _name;
172  };
173 
176  {
177  ByRepository( Repository repository_r )
178  : _alias( repository_r.info().alias() )
179  {}
180 
181  ByRepository( const std::string & alias_r )
182  : _alias( alias_r )
183  {}
184 
186  {
187  return p->repoInfo().alias() == _alias;
188  }
189 
190  std::string _alias;
191  };
192 
205  template<class _Compare = CompareByEQ<Edition> >
207  {
208  ByEdition( const Edition & edition_r,
209  _Compare cmp_r )
210  : _edition( edition_r )
211  , _cmp( cmp_r )
212  {}
213 
215  {
216  return _cmp( p->edition(), _edition );
217  }
218 
220  _Compare _cmp;
221  };
222 
224  template<class _Compare>
225  ByEdition<_Compare> byEdition( const Edition & edition_r, _Compare cmp_r )
226  { return ByEdition<_Compare>( edition_r, cmp_r ); }
227 
229  template<class _Compare>
230  ByEdition<_Compare> byEdition( const Edition & edition_r )
231  { return byEdition( edition_r, _Compare() ); }
232 
233 
246  template<class _Compare = CompareByEQ<Arch> >
248  {
249  ByArch( const Arch & arch_r,
250  _Compare cmp_r )
251  : _arch( arch_r )
252  , _cmp( cmp_r )
253  {}
254 
256  {
257  return _cmp( p->arch(), _arch );
258  }
259 
261  _Compare _cmp;
262  };
263 
265  template<class _Compare>
266  ByArch<_Compare> byArch( const Arch & arch_r, _Compare cmp_r )
267  { return ByArch<_Compare>( arch_r, cmp_r ); }
268 
270  template<class _Compare>
271  ByArch<_Compare> byArch( const Arch & arch_r )
272  { return byArch( arch_r, _Compare() ); }
273 
274 
276 
278  //
279  // Some PoolItem attributes
280  //
282 
284  typedef std::unary_function<PoolItem, bool> PoolItemFilterFunctor;
285 
288  {
289  bool operator()( const PoolItem & p ) const
290  {
291  return p.status().isInstalled();
292  }
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  } // namespace resfilter
355 } // namespace zypp
357 #endif // ZYPP_RESFILTERS_H
bool operator()(ResObject::constPtr p) const
Definition: ResFilters.h:185
Select PoolItem by lock.
Definition: ResFilters.h:315
ByRepository(const std::string &alias_r)
Definition: ResFilters.h:181
bool isSuggested() const
Definition: ResStatus.h:185
bool transacts() const
Definition: ResStatus.h:264
PoolItem which is suggested.
Definition: ResFilters.h:342
Architecture.
Definition: Arch.h:36
ByEdition(const Edition &edition_r, _Compare cmp_r)
Definition: ResFilters.h:208
bool operator()(ResObject::constPtr p) const
Definition: ResFilters.h:166
Select ResObject by Edition using _Compare functor.
Definition: ResFilters.h:206
bool operator()(const PoolItem &p) const
Definition: ResFilters.h:326
bool isUninstalled() const
Definition: ResStatus.h:231
bool operator()(const PoolItem &p) const
Definition: ResFilters.h:308
bool isLocked() const
Definition: ResStatus.h:252
bool isKept() const
Definition: ResStatus.h:261
bool operator()(const PoolItem &p) const
Definition: ResFilters.h:344
Edition represents [epoch:]version[-release]
Definition: Edition.h:60
ResTraits.
Definition: ResTraits.h:77
TraitsType::constPtrType constPtr
Definition: ResObject.h:50
Select ResObject by name.
Definition: ResFilters.h:160
ByRepository(Repository repository_r)
Definition: ResFilters.h:177
filter::ByKind byKind()
Definition: ResFilters.h:156
Select PoolItem by installed.
Definition: ResFilters.h:287
bool isInstalled() const
Definition: ResStatus.h:228
std::unary_function< ResObject::constPtr, bool > ResObjectFilterFunctor
Definition: ResFilters.h:151
boost::function< bool(ResObject::constPtr)> ResFilter
Definition: ResFilters.h:152
PoolItem which is recommended.
Definition: ResFilters.h:333
Select PoolItem by keep.
Definition: ResFilters.h:324
bool operator()(ResObject::constPtr p) const
Definition: ResFilters.h:255
std::unary_function< PoolItem, bool > PoolItemFilterFunctor
Definition: ResFilters.h:284
Select ResObject by repository or repository alias.
Definition: ResFilters.h:175
ResStatus & status() const
Returns the current status.
Definition: PoolItem.cc:241
ByEdition< _Compare > byEdition(const Edition &edition_r, _Compare cmp_r)
Definition: ResFilters.h:225
Select PoolItem by transact.
Definition: ResFilters.h:306
bool operator()(ResObject::constPtr p) const
Definition: ResFilters.h:214
Select PoolItem by uninstalled.
Definition: ResFilters.h:297
ByArch< _Compare > byArch(const Arch &arch_r, _Compare cmp_r)
Definition: ResFilters.h:266
bool operator()(const PoolItem &p) const
Definition: ResFilters.h:335
ByName(const std::string &name_r)
Definition: ResFilters.h:162
Select ResObject by Arch using _Compare functor.
Definition: ResFilters.h:247
bool operator()(const PoolItem &p) const
Definition: ResFilters.h:289
Reference to a PoolItem connecting ResObject and ResStatus.
Definition: PoolItem.h:50
bool operator()(const PoolItem &p) const
Definition: ResFilters.h:317
bool operator()(const PoolItem &p) const
Definition: ResFilters.h:299
ByArch(const Arch &arch_r, _Compare cmp_r)
Definition: ResFilters.h:249
bool isRecommended() const
Definition: ResStatus.h:182
Filter solvables according to their kind.
Definition: Filter.h:105