libzypp: zypp/Filter.h Source File

libzypp 17.25.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
17 #include <zypp/base/Functional.h>
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
24 namespace zypp
25 {
27 namespace filter
28 {
55
57 //
58 // CLASS NAME : ByLocaleSupport
59 //
62 class ByLocaleSupport
63 {
64 private:
65 typedef bool (sat::Solvable::*LS1) (const Locale &) const;
66 typedef bool (sat::Solvable::*LS2) (const LocaleSet &) const;
67
68 public:
70 ByLocaleSupport()
71 : _sel( boost::mem_fun_ref( &sat::Solvable::supportsLocales ) )
72 {}
73
75 explicit ByLocaleSupport( const Locale & locale_r )
76 : _sel( boost::bind( boost::mem_fun_ref( (LS1)&sat::Solvable::supportsLocale ), _1, locale_r ) )
77 {}
78
80 explicit ByLocaleSupport( const LocaleSet & locales_r )
81 : _sel( boost::bind( boost::mem_fun_ref( (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:
108 ByKind()
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:
126 ResKind _kind;
127 };
128
130 template<class TRes>
131 inline ByKind byKind()
132 { return ByKind( ResTraits<TRes>::kind ); }
134
136 //
137 // CLASS NAME : ByStatus
138 //
141 class ByStatus
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:
162 Predicate _pred;
163 };
165
166
168 //
169 // CLASS NAME : SameItemAs
170 //
175 class SameItemAs
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:
204 sat::Solvable _item;
205 };
207
208
210 } // namespace filter
213 } // namespace zypp
215
216 #include <zypp/ResFilters.h>
217
218 #endif // ZYPP_FILTER_H
Function.h
Functional.h
PoolItem.h
Pool.h
ResFilters.h
zypp::Locale
'Language[_Country]' codes.
Definition: Locale.h:50
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::ResKind
Resolvable kinds.
Definition: ResKind.h:33
zypp::ResStatus
Status bitfield.
Definition: ResStatus.h:54
zypp::filter::ByKind
Filter solvables according to their kind.
Definition: Filter.h:106
zypp::filter::ByKind::operator()
bool operator()(const sat::Solvable &solv_r) const
Filter on Solvable.
Definition: Filter.h:117
zypp::filter::ByKind::_kind
ResKind _kind
Definition: Filter.h:126
zypp::filter::ByKind::operator()
bool operator()(const TSolv &solv_r) const
Filter fitting PoolItem/ResObject.
Definition: Filter.h:122
zypp::filter::ByKind::ByKind
ByKind(const ResKind &kind_r)
Definition: Filter.h:111
zypp::filter::ByKind::byKind
ByKind byKind()
templated convenience ctor.
Definition: Filter.h:131
zypp::filter::ByKind::ByKind
ByKind()
Definition: Filter.h:108
zypp::filter::ByLocaleSupport
Filter solvables according to their locale support.
Definition: Filter.h:63
zypp::filter::ByLocaleSupport::ByLocaleSupport
ByLocaleSupport(const Locale &locale_r)
Solvables supporting locale_r.
Definition: Filter.h:75
zypp::filter::ByLocaleSupport::ByLocaleSupport
ByLocaleSupport()
Solvables with locale support.
Definition: Filter.h:70
zypp::filter::ByLocaleSupport::ByLocaleSupport
ByLocaleSupport(const LocaleSet &locales_r)
Solvables supporting at least one locale in locales_r.
Definition: Filter.h:80
zypp::filter::ByLocaleSupport::operator()
bool operator()(const TSolv &solv_r) const
Filter fitting PoolItem/ResObject.
Definition: Filter.h:91
zypp::filter::ByLocaleSupport::operator()
bool operator()(const sat::Solvable &solv_r) const
Filter on Solvable.
Definition: Filter.h:86
zypp::filter::ByLocaleSupport::LS1
bool(sat::Solvable::* LS1)(const Locale &) const
Definition: Filter.h:65
zypp::filter::ByLocaleSupport::_sel
function< bool(const sat::Solvable &)> _sel
Definition: Filter.h:95
zypp::filter::ByLocaleSupport::LS2
bool(sat::Solvable::* LS2)(const LocaleSet &) const
Definition: Filter.h:66
zypp::filter::ByStatus
Filter solvables according to their status.
Definition: Filter.h:142
zypp::filter::ByStatus::operator()
bool operator()(const TSolv &solv_r) const
Filter fitting sat::Solvable/ResObject.
Definition: Filter.h:158
zypp::filter::ByStatus::operator()
bool operator()(const PoolItem &pi_r) const
Filter on PoolItem.
Definition: Filter.h:153
zypp::filter::ByStatus::Predicate
bool(ResStatus::* Predicate)() const
Definition: Filter.h:144
zypp::filter::ByStatus::ByStatus
ByStatus(Predicate pred_r=0)
Definition: Filter.h:147
zypp::filter::ByStatus::_pred
Predicate _pred
Definition: Filter.h:162
zypp::filter::SameItemAs
Filter items with at least same NVRA, vendor.
Definition: Filter.h:176
zypp::filter::SameItemAs::_item
sat::Solvable _item
Definition: Filter.h:204
zypp::filter::SameItemAs::operator()
bool operator()(const sat::Solvable &solv_r) const
Filter on Solvable.
Definition: Filter.h:190
zypp::filter::SameItemAs::SameItemAs
SameItemAs(const sat::Solvable &solv_r)
Definition: Filter.h:178
zypp::filter::SameItemAs::operator()
bool operator()(const TSolv &solv_r) const
Filter fitting PoolItem/ResObject.
Definition: Filter.h:200
zypp::filter::SameItemAs::SameItemAs
SameItemAs(const TSolv &solv_r)
Fitting PoolItem/ResObject.
Definition: Filter.h:184
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:356
zypp::sat::Solvable::edition
Edition edition() const
The edition (version-release).
Definition: Solvable.cc:336
zypp::sat::Solvable::arch
Arch arch() const
The architecture.
Definition: Solvable.cc:342
zypp::sat::Solvable::name
std::string name() const
The name (without any ResKind prefix).
Definition: Solvable.cc:328
zypp::sat::Solvable::isKind
bool isKind(const ResKind &kind_r) const
Test whether a Solvable is of a certain ResKind.
Definition: Solvable.cc:301
boost
Boost libraries.
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
zypp::LocaleSet
std::unordered_set< Locale > LocaleSet
Definition: Locale.h:27
zypp::ResTraits
ResTraits.
Definition: ResTraits.h:80