libzypp  17.16.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  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 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  } // namespace resfilter
355 } // namespace zypp
357 #endif // ZYPP_RESFILTERS_H
Select PoolItem by lock.
Definition: ResFilters.h:315
ByRepository(const std::string &alias_r)
Definition: ResFilters.h:184
bool operator()(const PoolItem &p) const
Definition: ResFilters.h:317
bool transacts() const
Definition: ResStatus.h:267
bool operator()(ResObject::constPtr p) const
Definition: ResFilters.h:169
PoolItem which is suggested.
Definition: ResFilters.h:342
Architecture.
Definition: Arch.h:36
bool operator()(const PoolItem &p) const
Definition: ResFilters.h:299
Select ResObject by Edition using TCompare functor.
Definition: ResFilters.h:209
bool isInstalled() const
Definition: ResStatus.h:231
ResStatus & status() const
Returns the current status.
Definition: PoolItem.cc:204
bool operator()(const PoolItem &p) const
Definition: ResFilters.h:335
ByArch(const Arch &arch_r, TCompare cmp_r)
Definition: ResFilters.h:251
Edition represents [epoch:]version[-release]
Definition: Edition.h:60
bool isRecommended() const
Definition: ResStatus.h:182
ResTraits.
Definition: ResTraits.h:79
TraitsType::constPtrType constPtr
Definition: ResObject.h:43
Select ResObject by name.
Definition: ResFilters.h:160
ByEdition(const Edition &edition_r, TCompare cmp_r)
Definition: ResFilters.h:211
ByRepository(Repository repository_r)
Definition: ResFilters.h:180
filter::ByKind byKind()
Definition: ResFilters.h:156
Select PoolItem by installed.
Definition: ResFilters.h:288
std::unary_function< ResObject::constPtr, bool > ResObjectFilterFunctor
Definition: ResFilters.h:151
boost::function< bool(ResObject::constPtr)> ResFilter
Definition: ResFilters.h:152
bool operator()(ResObject::constPtr p) const
Definition: ResFilters.h:188
ByEdition< TCompare > byEdition(const Edition &edition_r, TCompare cmp_r)
Definition: ResFilters.h:227
PoolItem which is recommended.
Definition: ResFilters.h:333
Select PoolItem by keep.
Definition: ResFilters.h:324
ByArch< TCompare > byArch(const Arch &arch_r, TCompare cmp_r)
Definition: ResFilters.h:267
std::unary_function< PoolItem, bool > PoolItemFilterFunctor
Definition: ResFilters.h:285
Select ResObject by repository or repository alias.
Definition: ResFilters.h:178
bool operator()(ResObject::constPtr p) const
Definition: ResFilters.h:256
bool operator()(const PoolItem &p) const
Definition: ResFilters.h:290
Select PoolItem by transact.
Definition: ResFilters.h:306
bool operator()(const PoolItem &p) const
Definition: ResFilters.h:326
Select PoolItem by uninstalled.
Definition: ResFilters.h:297
ByName(const std::string &name_r)
Definition: ResFilters.h:165
Select ResObject by Arch using TCompare functor.
Definition: ResFilters.h:249
bool operator()(ResObject::constPtr p) const
Definition: ResFilters.h:216
bool isSuggested() const
Definition: ResStatus.h:185
bool isLocked() const
Definition: ResStatus.h:255
bool isKept() const
Definition: ResStatus.h:264
bool isUninstalled() const
Definition: ResStatus.h:234
Combining sat::Solvable and ResStatus.
Definition: PoolItem.h:50
bool operator()(const PoolItem &p) const
Definition: ResFilters.h:344
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
Filter solvables according to their kind.
Definition: Filter.h:105
bool operator()(const PoolItem &p) const
Definition: ResFilters.h:308