libzypp 17.37.17
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#include <utility>
17
19#include <zypp/base/Function.h>
20// #include <zypp/ResFilters.h> included at the end!
21#include <zypp/sat/Pool.h>
22#include <zypp/PoolItem.h>
23
25namespace zypp
26{
28 namespace filter
29 {
56
58 //
59 // CLASS NAME : ByLocaleSupport
60 //
64 {
65 private:
66 using LS1 = bool (sat::Solvable::*)(const Locale &) const;
67 using LS2 = bool (sat::Solvable::*)(const LocaleSet &) const;
68
69 public:
72 : _sel( std::mem_fn(&sat::Solvable::supportsLocales) )
73 {}
74
76 explicit ByLocaleSupport( const Locale & locale_r )
77 : _sel( std::bind( std::mem_fn((LS1)&sat::Solvable::supportsLocale), _1, locale_r ) )
78 {}
79
81 explicit ByLocaleSupport( const LocaleSet & locales_r )
82 : _sel( std::bind( std::mem_fn((LS2)&sat::Solvable::supportsLocale), _1, locales_r ) )
83 {}
84
85 public:
87 bool operator()( const sat::Solvable & solv_r ) const
88 { return _sel && _sel( solv_r ); }
89
91 template<class TSolv>
92 bool operator()( const TSolv & solv_r ) const
93 { return operator()( solv_r.satSolvable() ); }
94
95 private:
96 function<bool(const sat::Solvable &)> _sel;
97 };
98
99
101 //
102 // CLASS NAME : ByKind
103 //
106 class ByKind
107 {
108 public:
110 {}
111
112 ByKind( ResKind kind_r )
113 : _kind(std::move( kind_r ))
114 {}
115
116 public:
118 bool operator()( const sat::Solvable & solv_r ) const
119 { return solv_r.isKind( _kind ); }
120
122 template<class TSolv>
123 bool operator()( const TSolv & solv_r ) const
124 { return operator()( solv_r.satSolvable() ); }
125
126 private:
128 };
129
131 template<class TRes>
132 inline ByKind byKind()
133 { return ByKind( ResTraits<TRes>::kind ); }
134
135
137 //
138 // CLASS NAME : ByStatus
139 //
143 {
144 public:
145 using Predicate = bool (ResStatus::*)() const;
146
147 public:
148 ByStatus( Predicate pred_r = 0 )
149 : _pred( pred_r )
150 {}
151
152 public:
154 bool operator()( const PoolItem & pi_r ) const
155 { return _pred && (pi_r.status().*_pred)(); }
156
158 template<class TSolv>
159 bool operator()( const TSolv & solv_r ) const
160 { return operator()( PoolItem(solv_r) ); }
161
162 private:
164 };
165
166
167
169 //
170 // CLASS NAME : SameItemAs
171 //
177 {
178 public:
179 SameItemAs( const sat::Solvable & solv_r )
180 : _item( solv_r )
181 {}
182
184 template<class TSolv>
185 SameItemAs( const TSolv & solv_r )
186 : _item( solv_r.satSolvable() )
187 {}
188
189 public:
191 bool operator()( const sat::Solvable & solv_r ) const
192 {
193 return solv_r.name() == _item.name()
194 && solv_r.edition() == _item.edition()
195 && solv_r.arch() == _item.arch()
196 && solv_r.vendor() == _item.vendor();
197 }
198
200 template<class TSolv>
201 bool operator()( const TSolv & solv_r ) const
202 { return operator()( solv_r.satSolvable() ); }
203
204 private:
206 };
207
208
209
211 } // namespace filter
212
214} // namespace zypp
216
217#include <zypp/ResFilters.h>
218
219#endif // ZYPP_FILTER_H
'Language[_Country]' codes.
Definition Locale.h:51
Combining sat::Solvable and ResStatus.
Definition PoolItem.h:51
ResStatus & status() const
Returns the current status.
Definition PoolItem.cc:212
Resolvable kinds.
Definition ResKind.h:33
Status bitfield.
Definition ResStatus.h:55
bool operator()(const sat::Solvable &solv_r) const
Filter on Solvable.
Definition Filter.h:118
bool operator()(const TSolv &solv_r) const
Filter fitting PoolItem/ResObject.
Definition Filter.h:123
ByKind byKind()
templated convenience ctor.
Definition Filter.h:132
ByKind(ResKind kind_r)
Definition Filter.h:112
ByLocaleSupport(const Locale &locale_r)
Solvables supporting locale_r.
Definition Filter.h:76
ByLocaleSupport()
Solvables with locale support.
Definition Filter.h:71
ByLocaleSupport(const LocaleSet &locales_r)
Solvables supporting at least one locale in locales_r.
Definition Filter.h:81
bool operator()(const TSolv &solv_r) const
Filter fitting PoolItem/ResObject.
Definition Filter.h:92
bool operator()(const sat::Solvable &solv_r) const
Filter on Solvable.
Definition Filter.h:87
bool(sat::Solvable::*)(const LocaleSet &) const LS2
Definition Filter.h:67
function< bool(const sat::Solvable &)> _sel
Definition Filter.h:96
bool(sat::Solvable::*)(const Locale &) const LS1
Definition Filter.h:66
bool operator()(const TSolv &solv_r) const
Filter fitting sat::Solvable/ResObject.
Definition Filter.h:159
bool operator()(const PoolItem &pi_r) const
Filter on PoolItem.
Definition Filter.h:154
ByStatus(Predicate pred_r=0)
Definition Filter.h:148
bool(ResStatus::*)() const Predicate
Definition Filter.h:145
sat::Solvable _item
Definition Filter.h:205
bool operator()(const sat::Solvable &solv_r) const
Filter on Solvable.
Definition Filter.h:191
SameItemAs(const sat::Solvable &solv_r)
Definition Filter.h:179
bool operator()(const TSolv &solv_r) const
Filter fitting PoolItem/ResObject.
Definition Filter.h:201
SameItemAs(const TSolv &solv_r)
Fitting PoolItem/ResObject.
Definition Filter.h:185
A Solvable object within the sat Pool.
Definition Solvable.h:54
IdString vendor() const
The vendor.
Definition Solvable.cc:358
Edition edition() const
The edition (version-release).
Definition Solvable.cc:338
Arch arch() const
The architecture.
Definition Solvable.cc:344
std::string name() const
The name (without any ResKind prefix).
Definition Solvable.cc:330
bool isKind(const ResKind &kind_r) const
Test whether a Solvable is of a certain ResKind.
Definition Solvable.cc:303
Definition Arch.h:364
Libsolv interface
Easy-to use interface to the ZYPP dependency resolver.
std::unordered_set< Locale > LocaleSet
Definition Locale.h:29
ResTraits.
Definition ResTraits.h:80