libzypp 17.31.23
Filter.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#ifndef ZYPP_FILTER_H
13#define ZYPP_FILTER_H
14
15#include <iosfwd>
16
18#include <zypp/base/Function.h>
19// #include <zypp/ResFilters.h> included at the end!
20#include <zypp/sat/Pool.h>
21#include <zypp/PoolItem.h>
22
24namespace zypp
25{
27 namespace filter
28 {
55
57 //
58 // CLASS NAME : ByLocaleSupport
59 //
63 {
64 private:
65 typedef bool (sat::Solvable::*LS1) (const Locale &) const;
66 typedef bool (sat::Solvable::*LS2) (const LocaleSet &) const;
67
68 public:
71 : _sel( std::mem_fn(&sat::Solvable::supportsLocales) )
72 {}
73
75 explicit ByLocaleSupport( const Locale & locale_r )
76 : _sel( std::bind( std::mem_fn((LS1)&sat::Solvable::supportsLocale), _1, locale_r ) )
77 {}
78
80 explicit ByLocaleSupport( const LocaleSet & locales_r )
81 : _sel( std::bind( std::mem_fn((LS2)&sat::Solvable::supportsLocale), _1, locales_r ) )
82 {}
83
84 public:
86 bool operator()( const sat::Solvable & solv_r ) const
87 { return _sel && _sel( solv_r ); }
88
90 template<class TSolv>
91 bool operator()( const TSolv & solv_r ) const
92 { return operator()( solv_r.satSolvable() ); }
93
94 private:
95 function<bool(const sat::Solvable &)> _sel;
96 };
98
100 //
101 // CLASS NAME : ByKind
102 //
105 class ByKind
106 {
107 public:
109 {}
110
111 ByKind( const ResKind & kind_r )
112 : _kind( kind_r )
113 {}
114
115 public:
117 bool operator()( const sat::Solvable & solv_r ) const
118 { return solv_r.isKind( _kind ); }
119
121 template<class TSolv>
122 bool operator()( const TSolv & solv_r ) const
123 { return operator()( solv_r.satSolvable() ); }
124
125 private:
127 };
128
130 template<class TRes>
131 inline ByKind byKind()
132 { return ByKind( ResTraits<TRes>::kind ); }
134
136 //
137 // CLASS NAME : ByStatus
138 //
142 {
143 public:
144 typedef bool (ResStatus::*Predicate)() const;
145
146 public:
147 ByStatus( Predicate pred_r = 0 )
148 : _pred( pred_r )
149 {}
150
151 public:
153 bool operator()( const PoolItem & pi_r ) const
154 { return _pred && (pi_r.status().*_pred)(); }
155
157 template<class TSolv>
158 bool operator()( const TSolv & solv_r ) const
159 { return operator()( PoolItem(solv_r) ); }
160
161 private:
163 };
165
166
168 //
169 // CLASS NAME : SameItemAs
170 //
176 {
177 public:
178 SameItemAs( const sat::Solvable & solv_r )
179 : _item( solv_r )
180 {}
181
183 template<class TSolv>
184 SameItemAs( const TSolv & solv_r )
185 : _item( solv_r.satSolvable() )
186 {}
187
188 public:
190 bool operator()( const sat::Solvable & solv_r ) const
191 {
192 return solv_r.name() == _item.name()
193 && solv_r.edition() == _item.edition()
194 && solv_r.arch() == _item.arch()
195 && solv_r.vendor() == _item.vendor();
196 }
197
199 template<class TSolv>
200 bool operator()( const TSolv & solv_r ) const
201 { return operator()( solv_r.satSolvable() ); }
202
203 private:
205 };
207
208
210 } // namespace filter
213} // namespace zypp
215
216#include <zypp/ResFilters.h>
217
218#endif // ZYPP_FILTER_H
'Language[_Country]' codes.
Definition: Locale.h:50
Combining sat::Solvable and ResStatus.
Definition: PoolItem.h:51
ResStatus & status() const
Returns the current status.
Definition: PoolItem.cc:211
Resolvable kinds.
Definition: ResKind.h:33
Status bitfield.
Definition: ResStatus.h:54
Filter solvables according to their kind.
Definition: Filter.h:106
bool operator()(const sat::Solvable &solv_r) const
Filter on Solvable.
Definition: Filter.h:117
bool operator()(const TSolv &solv_r) const
Filter fitting PoolItem/ResObject.
Definition: Filter.h:122
ByKind(const ResKind &kind_r)
Definition: Filter.h:111
ByKind byKind()
templated convenience ctor.
Definition: Filter.h:131
Filter solvables according to their locale support.
Definition: Filter.h:63
ByLocaleSupport(const Locale &locale_r)
Solvables supporting locale_r.
Definition: Filter.h:75
ByLocaleSupport()
Solvables with locale support.
Definition: Filter.h:70
ByLocaleSupport(const LocaleSet &locales_r)
Solvables supporting at least one locale in locales_r.
Definition: Filter.h:80
bool operator()(const TSolv &solv_r) const
Filter fitting PoolItem/ResObject.
Definition: Filter.h:91
bool operator()(const sat::Solvable &solv_r) const
Filter on Solvable.
Definition: Filter.h:86
bool(sat::Solvable::* LS1)(const Locale &) const
Definition: Filter.h:65
function< bool(const sat::Solvable &)> _sel
Definition: Filter.h:95
bool(sat::Solvable::* LS2)(const LocaleSet &) const
Definition: Filter.h:66
Filter solvables according to their status.
Definition: Filter.h:142
bool operator()(const TSolv &solv_r) const
Filter fitting sat::Solvable/ResObject.
Definition: Filter.h:158
bool operator()(const PoolItem &pi_r) const
Filter on PoolItem.
Definition: Filter.h:153
bool(ResStatus::* Predicate)() const
Definition: Filter.h:144
ByStatus(Predicate pred_r=0)
Definition: Filter.h:147
Filter items with at least same NVRA, vendor.
Definition: Filter.h:176
sat::Solvable _item
Definition: Filter.h:204
bool operator()(const sat::Solvable &solv_r) const
Filter on Solvable.
Definition: Filter.h:190
SameItemAs(const sat::Solvable &solv_r)
Definition: Filter.h:178
bool operator()(const TSolv &solv_r) const
Filter fitting PoolItem/ResObject.
Definition: Filter.h:200
SameItemAs(const TSolv &solv_r)
Fitting PoolItem/ResObject.
Definition: Filter.h:184
A Solvable object within the sat Pool.
Definition: Solvable.h:54
IdString vendor() const
The vendor.
Definition: Solvable.cc:357
Edition edition() const
The edition (version-release).
Definition: Solvable.cc:337
Arch arch() const
The architecture.
Definition: Solvable.cc:343
std::string name() const
The name (without any ResKind prefix).
Definition: Solvable.cc:329
bool isKind(const ResKind &kind_r) const
Test whether a Solvable is of a certain ResKind.
Definition: Solvable.cc:302
Definition: Arch.h:361
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
std::unordered_set< Locale > LocaleSet
Definition: Locale.h:28
ResTraits.
Definition: ResTraits.h:80