libzypp: zypp/ResFilters.h Source File

libzypp 17.25.10

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 {
28 namespace resfilter
29 {
30
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>
156 inline filter::ByKind byKind()
157 { return filter::ByKind( ResTraits<TRes>::kind ); }
158
160 struct ByName : public ResObjectFilterFunctor
161 {
162 ByName()
163 {}
164
165 ByName( const std::string & name_r )
166 : _name( name_r )
167 {}
168
169 bool operator()( ResObject::constPtr p ) const
170 {
171 return p->name() == _name;
172 }
173
174 std::string _name;
175 };
176
178 struct ByRepository : public ResObjectFilterFunctor
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
188 bool operator()( ResObject::constPtr p ) const
189 {
190 return p->repoInfo().alias() == _alias;
191 }
192
193 std::string _alias;
194 };
195
208 template<class TCompare = CompareByEQ<Edition> >
209 struct ByEdition : public ResObjectFilterFunctor
210 {
211 ByEdition( const Edition & edition_r, TCompare cmp_r )
212 : _edition( edition_r )
213 , _cmp( cmp_r )
214 {}
215
216 bool operator()( ResObject::constPtr p ) const
217 {
218 return _cmp( p->edition(), _edition );
219 }
220
221 Edition _edition;
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> >
249 struct ByArch : public ResObjectFilterFunctor
250 {
251 ByArch( const Arch & arch_r, TCompare cmp_r )
252 : _arch( arch_r )
253 , _cmp( cmp_r )
254 {}
255
256 bool operator()( ResObject::constPtr p ) const
257 {
258 return _cmp( p->arch(), _arch );
259 }
260
261 Arch _arch;
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
288 struct ByInstalled : public PoolItemFilterFunctor
289 {
290 bool operator()( const PoolItem & p ) const
291 {
292 return p.status().isInstalled();
293 }
294 };
295
297 struct ByUninstalled : public PoolItemFilterFunctor
298 {
299 bool operator()( const PoolItem & p ) const
300 {
301 return p.status().isUninstalled();
302 }
303 };
304
306 struct ByTransact : public PoolItemFilterFunctor
307 {
308 bool operator()( const PoolItem & p ) const
309 {
310 return p.status().transacts();
311 }
312 };
313
315 struct ByLock : public PoolItemFilterFunctor
316 {
317 bool operator()( const PoolItem & p ) const
318 {
319 return p.status().isLocked();
320 }
321 };
322
324 struct ByKeep : public PoolItemFilterFunctor
325 {
326 bool operator()( const PoolItem & p ) const
327 {
328 return p.status().isKept();
329 }
330 };
331
333 struct ByRecommended : public PoolItemFilterFunctor
334 {
335 bool operator()( const PoolItem & p ) const
336 {
337 return p.status().isRecommended();
338 }
339 };
340
342 struct BySuggested : public PoolItemFilterFunctor
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
Filter.h
Functional.h
PoolItem.h
Repository.h
Resolvable.h
PoolItemFilterFunctor
ResObjectFilterFunctor
zypp::Arch
Architecture.
Definition: Arch.h:37
zypp::Edition
Edition represents [epoch:]version[-release]
Definition: Edition.h:61
zypp::PoolItem
Combining sat::Solvable and ResStatus.
Definition: PoolItem.h:51
zypp::PoolItem::status
ResStatus & status() const
Returns the current status.
Definition: PoolItem.cc:204
zypp::Repository
Definition: Repository.h:40
zypp::ResObject::constPtr
TraitsType::constPtrType constPtr
Definition: ResObject.h:43
zypp::ResStatus::isSuggested
bool isSuggested() const
Definition: ResStatus.h:185
zypp::ResStatus::isLocked
bool isLocked() const
Definition: ResStatus.h:264
zypp::ResStatus::isKept
bool isKept() const
Definition: ResStatus.h:273
zypp::ResStatus::transacts
bool transacts() const
Definition: ResStatus.h:276
zypp::ResStatus::isRecommended
bool isRecommended() const
Definition: ResStatus.h:182
zypp::ResStatus::isInstalled
bool isInstalled() const
Definition: ResStatus.h:240
zypp::ResStatus::isUninstalled
bool isUninstalled() const
Definition: ResStatus.h:243
zypp::filter::ByKind
Filter solvables according to their kind.
Definition: Filter.h:106
zypp::resfilter::ResFilter
boost::function< bool(ResObject::constPtr)> ResFilter
Definition: ResFilters.h:152
zypp::resfilter::byKind
filter::ByKind byKind()
Definition: ResFilters.h:156
zypp::resfilter::byEdition
ByEdition< TCompare > byEdition(const Edition &edition_r, TCompare cmp_r)
Definition: ResFilters.h:227
zypp::resfilter::byArch
ByArch< TCompare > byArch(const Arch &arch_r, TCompare cmp_r)
Definition: ResFilters.h:267
zypp::resfilter::PoolItemFilterFunctor
std::unary_function< PoolItem, bool > PoolItemFilterFunctor
Definition: ResFilters.h:285
zypp::resfilter::ResObjectFilterFunctor
std::unary_function< ResObject::constPtr, bool > ResObjectFilterFunctor
Definition: ResFilters.h:151
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
zypp::ResTraits
ResTraits.
Definition: ResTraits.h:80
zypp::resfilter::ByArch
Select ResObject by Arch using TCompare functor.
Definition: ResFilters.h:250
zypp::resfilter::ByArch::_arch
Arch _arch
Definition: ResFilters.h:261
zypp::resfilter::ByArch::ByArch
ByArch(const Arch &arch_r, TCompare cmp_r)
Definition: ResFilters.h:251
zypp::resfilter::ByArch::_cmp
TCompare _cmp
Definition: ResFilters.h:262
zypp::resfilter::ByArch::operator()
bool operator()(ResObject::constPtr p) const
Definition: ResFilters.h:256
zypp::resfilter::ByEdition
Select ResObject by Edition using TCompare functor.
Definition: ResFilters.h:210
zypp::resfilter::ByEdition::ByEdition
ByEdition(const Edition &edition_r, TCompare cmp_r)
Definition: ResFilters.h:211
zypp::resfilter::ByEdition::_edition
Edition _edition
Definition: ResFilters.h:221
zypp::resfilter::ByEdition::operator()
bool operator()(ResObject::constPtr p) const
Definition: ResFilters.h:216
zypp::resfilter::ByEdition::_cmp
TCompare _cmp
Definition: ResFilters.h:222
zypp::resfilter::ByInstalled
Select PoolItem by installed.
Definition: ResFilters.h:289
zypp::resfilter::ByInstalled::operator()
bool operator()(const PoolItem &p) const
Definition: ResFilters.h:290
zypp::resfilter::ByKeep
Select PoolItem by keep.
Definition: ResFilters.h:325
zypp::resfilter::ByKeep::operator()
bool operator()(const PoolItem &p) const
Definition: ResFilters.h:326
zypp::resfilter::ByLock
Select PoolItem by lock.
Definition: ResFilters.h:316
zypp::resfilter::ByLock::operator()
bool operator()(const PoolItem &p) const
Definition: ResFilters.h:317
zypp::resfilter::ByName
Select ResObject by name.
Definition: ResFilters.h:161
zypp::resfilter::ByName::ByName
ByName(const std::string &name_r)
Definition: ResFilters.h:165
zypp::resfilter::ByName::ByName
ByName()
Definition: ResFilters.h:162
zypp::resfilter::ByName::_name
std::string _name
Definition: ResFilters.h:174
zypp::resfilter::ByName::operator()
bool operator()(ResObject::constPtr p) const
Definition: ResFilters.h:169
zypp::resfilter::ByRecommended
PoolItem which is recommended.
Definition: ResFilters.h:334
zypp::resfilter::ByRecommended::operator()
bool operator()(const PoolItem &p) const
Definition: ResFilters.h:335
zypp::resfilter::ByRepository
Select ResObject by repository or repository alias.
Definition: ResFilters.h:179
zypp::resfilter::ByRepository::ByRepository
ByRepository(const std::string &alias_r)
Definition: ResFilters.h:184
zypp::resfilter::ByRepository::ByRepository
ByRepository(Repository repository_r)
Definition: ResFilters.h:180
zypp::resfilter::ByRepository::_alias
std::string _alias
Definition: ResFilters.h:193
zypp::resfilter::ByRepository::operator()
bool operator()(ResObject::constPtr p) const
Definition: ResFilters.h:188
zypp::resfilter::BySuggested
PoolItem which is suggested.
Definition: ResFilters.h:343
zypp::resfilter::BySuggested::operator()
bool operator()(const PoolItem &p) const
Definition: ResFilters.h:344
zypp::resfilter::ByTransact
Select PoolItem by transact.
Definition: ResFilters.h:307
zypp::resfilter::ByTransact::operator()
bool operator()(const PoolItem &p) const
Definition: ResFilters.h:308
zypp::resfilter::ByUninstalled
Select PoolItem by uninstalled.
Definition: ResFilters.h:298
zypp::resfilter::ByUninstalled::operator()
bool operator()(const PoolItem &p) const
Definition: ResFilters.h:299