paludis Version 3.0.2
The one true package mangler
filter.hh
Go to the documentation of this file.
1/* vim: set sw=4 sts=4 et foldmethod=syntax : */
2
3/*
4 * Copyright (c) 2008, 2009, 2010, 2011, 2014 Ciaran McCreesh
5 *
6 * This file is part of the Paludis package manager. Paludis is free software;
7 * you can redistribute it and/or modify it under the terms of the GNU General
8 * Public License version 2, as published by the Free Software Foundation.
9 *
10 * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
11 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
17 * Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#ifndef PALUDIS_GUARD_PALUDIS_FILTER_HH
21#define PALUDIS_GUARD_PALUDIS_FILTER_HH 1
22
23#include <paludis/filter-fwd.hh>
24#include <paludis/filter_handler-fwd.hh>
26#include <paludis/util/pimp.hh>
28#include <paludis/util/fs_path-fwd.hh>
29#include <paludis/name-fwd.hh>
32#include <paludis/action-fwd.hh>
34#include <paludis/match_package-fwd.hh>
36#include <functional>
37#include <memory>
38
39/** \file
40 * Declarations for the Filter class.
41 *
42 * \ingroup g_selections
43 *
44 * \section Examples
45 *
46 * - \ref example_selection.cc "example_selection.cc"
47 */
48
49namespace paludis
50{
51 /**
52 * A Filter subclass can be used to further restrict the values picked by a
53 * Generator, which when combined together produces a FilteredGenerator
54 * which can be passed to a Selection subclass.
55 *
56 * \ingroup g_selections
57 */
58 class PALUDIS_VISIBLE Filter
59 {
60 private:
61 Pimp<Filter> _imp;
62
63 protected:
64 Filter(const std::shared_ptr<const FilterHandler> &);
65
66 public:
67 ///\name Basic operations
68 ///\{
69
70 /**
71 * Filter subclasses can be copied without losing information.
72 */
73 Filter(const Filter &);
74 Filter & operator= (const Filter &);
75 ~Filter();
76
77 ///\}
78
79 /**
80 * A Filter can be represented as a string, for use by operator<<.
81 */
82 std::string as_string() const PALUDIS_ATTRIBUTE((warn_unused_result));
83
84 ///\name For use by Selection
85 ///\{
86
87 /**
88 * Return any RepositoryContentMayExcludes that are implied by this
89 * filter.
90 *
91 * \since 0.59
92 */
93 const RepositoryContentMayExcludes may_excludes() const PALUDIS_ATTRIBUTE((warn_unused_result));
94
95 /**
96 * Filter candidate repository names.
97 */
98 std::shared_ptr<const RepositoryNameSet> repositories(
99 const Environment * const,
100 const std::shared_ptr<const RepositoryNameSet> &) const
101 PALUDIS_ATTRIBUTE((warn_unused_result));
102
103 /**
104 * Filter candidate category names.
105 */
106 std::shared_ptr<const CategoryNamePartSet> categories(
107 const Environment * const,
108 const std::shared_ptr<const RepositoryNameSet> &,
109 const std::shared_ptr<const CategoryNamePartSet> &) const
110 PALUDIS_ATTRIBUTE((warn_unused_result));
111
112 /**
113 * Filter candidate package names.
114 */
115 std::shared_ptr<const QualifiedPackageNameSet> packages(
116 const Environment * const,
117 const std::shared_ptr<const RepositoryNameSet> &,
118 const std::shared_ptr<const QualifiedPackageNameSet> &) const
119 PALUDIS_ATTRIBUTE((warn_unused_result));
120
121 /**
122 * Filter candidate PackageID instances.
123 */
124 std::shared_ptr<const PackageIDSet> ids(
125 const Environment * const,
126 const std::shared_ptr<const PackageIDSet> &) const
127 PALUDIS_ATTRIBUTE((warn_unused_result));
128
129 ///\}
130 };
131
132 namespace filter
133 {
134 /**
135 * A Filter which accepts all PackageID instances.
136 *
137 * \ingroup g_selections
138 */
139 class PALUDIS_VISIBLE All :
140 public Filter
141 {
142 public:
143 All();
144 };
145
146 /**
147 * A Filter which accepts only PackageID instances which support a given
148 * Action subclass.
149 *
150 * \ingroup g_selections
151 */
152 template <typename>
153 class PALUDIS_VISIBLE SupportsAction :
154 public Filter
155 {
156 public:
157 SupportsAction();
158 };
159
160 /**
161 * A Filter which accepts only PackageID instances which are not masked.
162 *
163 * \ingroup g_selections
164 */
165 class PALUDIS_VISIBLE NotMasked :
166 public Filter
167 {
168 public:
169 NotMasked();
170 };
171
172 /**
173 * A Filter which accepts only PackageID instances that are installed to
174 * a particular root.
175 *
176 * \ingroup g_selections
177 */
178 class PALUDIS_VISIBLE InstalledAtRoot :
179 public Filter
180 {
181 public:
182 InstalledAtRoot(const FSPath &);
183 };
184
185 /**
186 * A Filter which accepts only PackageID instances that are installed but
187 * not in a particular root.
188 *
189 * \ingroup g_selections
190 */
191 class PALUDIS_VISIBLE InstalledNotAtRoot :
192 public Filter
193 {
194 public:
195 InstalledNotAtRoot(const FSPath &);
196 };
197
198 /**
199 * A Filter which accepts only PackageID instances that are installed to
200 * the / fs.
201 *
202 * \ingroup g_selections
203 * \since 0.51
204 */
205 class PALUDIS_VISIBLE InstalledAtSlash :
206 public Filter
207 {
208 public:
209 InstalledAtSlash();
210 };
211
212 /**
213 * A Filter which accepts only PackageID instances that are installed to
214 * an fs other than /.
215 *
216 * \ingroup g_selections
217 * \since 0.51
218 */
219 class PALUDIS_VISIBLE InstalledAtNotSlash :
220 public Filter
221 {
222 public:
223 InstalledAtNotSlash();
224 };
225
226 class PALUDIS_VISIBLE CrossCompileHost :
227 public Filter
228 {
229 public:
230 CrossCompileHost(const std::string & host);
231 };
232
233 /**
234 * A Filter which accepts only PackageID instances that are accepted by
235 * two different filters.
236 *
237 * Used internally by FilteredGenerator.
238 *
239 * \ingroup g_selections
240 */
241 class PALUDIS_VISIBLE And :
242 public Filter
243 {
244 public:
245 And(const Filter &, const Filter &);
246 };
247
248 /**
249 * A Filter which accepts only PackageID instances that have the same
250 * slot as the specified PackageID, or, if the specified PackageID has
251 * no slot, that have no slot.
252 *
253 * \ingroup g_selections
254 */
255 class PALUDIS_VISIBLE SameSlot :
256 public Filter
257 {
258 public:
259 SameSlot(const std::shared_ptr<const PackageID> &);
260 };
261
262 /**
263 * A Filter which accepts only PackageID instances that have a
264 * particular slot.
265 *
266 * \ingroup g_selections
267 */
268 class PALUDIS_VISIBLE Slot :
269 public Filter
270 {
271 public:
272 Slot(const SlotName &);
273 };
274
275 /**
276 * A Filter which accepts only PackageID instances that have no slot.
277 *
278 * \ingroup g_selections
279 */
280 class PALUDIS_VISIBLE NoSlot :
281 public Filter
282 {
283 public:
284 NoSlot();
285 };
286
287 /**
288 * A Filter which accepts only PackageID instances that match a
289 * particular PackageDepSpec.
290 *
291 * \ingroup g_selections
292 */
294 public Filter
295 {
296 public:
297 /**
298 * \param spec_id The PackageID the spec comes from. May be null. Used
299 * for [use=] style dependencies.
300 *
301 * \since 0.58 takes spec_id
302 */
304 const PackageDepSpec &,
305 const std::shared_ptr<const PackageID> & from_id,
306 const MatchPackageOptions &);
307 };
308
309 /**
310 * A Filter which rejects PackageIDs using a function.
311 *
312 * \ingroup g_selections
313 * \since 2.0
314 */
315 class PALUDIS_VISIBLE ByFunction :
316 public Filter
317 {
318 public:
319 ByFunction(
320 const std::function<bool (const std::shared_ptr<const PackageID> &)> &,
321 const std::string &);
322 };
323 }
324
325 extern template class Pimp<Filter>;
333}
334
335#endif
Definition environment.hh:203
Definition fs_path.hh:34
const RepositoryContentMayExcludes may_excludes() const PALUDIS_ATTRIBUTE((warn_unused_result))
std::shared_ptr< const QualifiedPackageNameSet > packages(const Environment *const, const std::shared_ptr< const RepositoryNameSet > &, const std::shared_ptr< const QualifiedPackageNameSet > &) const PALUDIS_ATTRIBUTE((warn_unused_result))
std::shared_ptr< const PackageIDSet > ids(const Environment *const, const std::shared_ptr< const PackageIDSet > &) const PALUDIS_ATTRIBUTE((warn_unused_result))
std::string as_string() const PALUDIS_ATTRIBUTE((warn_unused_result))
std::shared_ptr< const CategoryNamePartSet > categories(const Environment *const, const std::shared_ptr< const RepositoryNameSet > &, const std::shared_ptr< const CategoryNamePartSet > &) const PALUDIS_ATTRIBUTE((warn_unused_result))
Filter(const Filter &)
std::shared_ptr< const RepositoryNameSet > repositories(const Environment *const, const std::shared_ptr< const RepositoryNameSet > &) const PALUDIS_ATTRIBUTE((warn_unused_result))
Definition dep_spec.hh:348
Definition pimp.hh:52
Matches(const PackageDepSpec &, const std::shared_ptr< const PackageID > &from_id, const MatchPackageOptions &)
Definition filter.hh:155
WrappedValue< SlotNameTag > SlotName
Definition name-fwd.hh:93
Set< std::shared_ptr< const PackageID >, PackageIDSetComparator > PackageIDSet
Definition package_id-fwd.hh:57
#define PALUDIS_ATTRIBUTE(x)
Definition attributes.hh:53
#define PALUDIS_VISIBLE
Definition attributes.hh:59
Definition about_metadata-fwd.hh:24
Options< MatchPackageOption > MatchPackageOptions
Definition match_package-fwd.hh:38