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