libzypp 17.37.10

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
18#include <zypp/base/Functional.h>
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
25 namespace zypp
26{
28 namespace filter
29 {
56
58 //
59 // CLASS NAME : ByLocaleSupport
60 //
63 class ByLocaleSupport
64 {
65 private:
66 using LS1 = bool (sat::Solvable::*)(const Locale &) const;
67 using LS2 = bool (sat::Solvable::*)(const LocaleSet &) const;
68
69 public:
71 ByLocaleSupport()
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:
109 ByKind()
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:
127 ResKind _kind;
128 };
129
131 template<class TRes>
132 inline ByKind byKind()
133 { return ByKind( ResTraits<TRes>::kind ); }
134
135
137 //
138 // CLASS NAME : ByStatus
139 //
142 class ByStatus
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:
163 Predicate _pred;
164 };
165
166
167
169 //
170 // CLASS NAME : SameItemAs
171 //
176 class SameItemAs
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:
205 sat::Solvable _item;
206 };
207
208
209
211 } // namespace filter
212
214} // namespace zypp
216
217#include <zypp/ResFilters.h>
218
219#endif // ZYPP_FILTER_H
Functional.h
PoolItem.h
Pool.h
ResFilters.h
bool
zypp::Locale
'Language[_Country]' codes.
Definition Locale.h:51
zypp::PoolItem
Combining sat::Solvable and ResStatus.
Definition PoolItem.h:51
zypp::PoolItem::status
ResStatus & status() const
Returns the current status.
Definition PoolItem.cc:212
zypp::ResKind
Resolvable kinds.
Definition ResKind.h:33
zypp::ResStatus
Status bitfield.
Definition ResStatus.h:55
zypp::filter::ByKind::operator()
bool operator()(const sat::Solvable &solv_r) const
Filter on Solvable.
Definition Filter.h:118
zypp::filter::ByKind::_kind
ResKind _kind
Definition Filter.h:127
zypp::filter::ByKind::operator()
bool operator()(const TSolv &solv_r) const
Filter fitting PoolItem/ResObject.
Definition Filter.h:123
zypp::filter::ByKind::byKind
ByKind byKind()
templated convenience ctor.
Definition Filter.h:132
zypp::filter::ByKind::ByKind
ByKind()
Definition Filter.h:109
zypp::filter::ByKind::ByKind
ByKind(ResKind kind_r)
Definition Filter.h:112
zypp::filter::ByLocaleSupport::ByLocaleSupport
ByLocaleSupport(const Locale &locale_r)
Solvables supporting locale_r.
Definition Filter.h:76
zypp::filter::ByLocaleSupport::ByLocaleSupport
ByLocaleSupport()
Solvables with locale support.
Definition Filter.h:71
zypp::filter::ByLocaleSupport::ByLocaleSupport
ByLocaleSupport(const LocaleSet &locales_r)
Solvables supporting at least one locale in locales_r.
Definition Filter.h:81
zypp::filter::ByLocaleSupport::operator()
bool operator()(const TSolv &solv_r) const
Filter fitting PoolItem/ResObject.
Definition Filter.h:92
zypp::filter::ByLocaleSupport::operator()
bool operator()(const sat::Solvable &solv_r) const
Filter on Solvable.
Definition Filter.h:87
zypp::filter::ByLocaleSupport::LS2
bool(sat::Solvable::*)(const LocaleSet &) const LS2
Definition Filter.h:67
zypp::filter::ByLocaleSupport::_sel
function< bool(const sat::Solvable &)> _sel
Definition Filter.h:96
zypp::filter::ByLocaleSupport::LS1
bool(sat::Solvable::*)(const Locale &) const LS1
Definition Filter.h:66
zypp::filter::ByStatus::operator()
bool operator()(const TSolv &solv_r) const
Filter fitting sat::Solvable/ResObject.
Definition Filter.h:159
zypp::filter::ByStatus::operator()
bool operator()(const PoolItem &pi_r) const
Filter on PoolItem.
Definition Filter.h:154
zypp::filter::ByStatus::ByStatus
ByStatus(Predicate pred_r=0)
Definition Filter.h:148
zypp::filter::ByStatus::Predicate
bool(ResStatus::*)() const Predicate
Definition Filter.h:145
zypp::filter::ByStatus::_pred
Predicate _pred
Definition Filter.h:163
zypp::filter::SameItemAs::_item
sat::Solvable _item
Definition Filter.h:205
zypp::filter::SameItemAs::operator()
bool operator()(const sat::Solvable &solv_r) const
Filter on Solvable.
Definition Filter.h:191
zypp::filter::SameItemAs::SameItemAs
SameItemAs(const sat::Solvable &solv_r)
Definition Filter.h:179
zypp::filter::SameItemAs::operator()
bool operator()(const TSolv &solv_r) const
Filter fitting PoolItem/ResObject.
Definition Filter.h:201
zypp::filter::SameItemAs::SameItemAs
SameItemAs(const TSolv &solv_r)
Fitting PoolItem/ResObject.
Definition Filter.h:185
zypp::sat::Solvable
A Solvable object within the sat Pool.
Definition Solvable.h:54
zypp::sat::Solvable::vendor
IdString vendor() const
The vendor.
Definition Solvable.cc:358
zypp::sat::Solvable::edition
Edition edition() const
The edition (version-release).
Definition Solvable.cc:338
zypp::sat::Solvable::arch
Arch arch() const
The architecture.
Definition Solvable.cc:344
zypp::sat::Solvable::name
std::string name() const
The name (without any ResKind prefix).
Definition Solvable.cc:330
zypp::sat::Solvable::isKind
bool isKind(const ResKind &kind_r) const
Test whether a Solvable is of a certain ResKind.
Definition Solvable.cc:303
std
Definition Arch.h:364
zypp::filter
Definition Filter.h:29
zypp::sat
Definition Resolver.h:28
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
zypp::LocaleSet
std::unordered_set< Locale > LocaleSet
Definition Locale.h:29
zypp::ResTraits
ResTraits.
Definition ResTraits.h:80
Function.h