paludis Version 3.0.2
The one true package mangler
generator.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 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_GENERATOR_HH
21#define PALUDIS_GUARD_PALUDIS_GENERATOR_HH 1
22
24#include <paludis/generator_handler-fwd.hh>
25#include <paludis/util/pimp.hh>
28#include <paludis/name-fwd.hh>
32#include <paludis/match_package-fwd.hh>
34#include <memory>
35
36/** \file
37 * Declarations for the Generator class.
38 *
39 * \ingroup g_selections
40 *
41 * \section Examples
42 *
43 * - \ref example_selection.cc "example_selection.cc"
44 */
45
46namespace paludis
47{
48 /**
49 * A Generator specifies general properties desired from the PackageID
50 * instances to be returned by Environment::operator[].
51 *
52 * A Generator can be converted implicitly to a FilteredGenerator, either
53 * for being passed directly to a Selection subclass or for combining with
54 * one or more Filter subclasses.
55 *
56 * \ingroup g_selections
57 */
58 class PALUDIS_VISIBLE Generator
59 {
60 private:
61 Pimp<Generator> _imp;
62
63 protected:
64 Generator(const std::shared_ptr<const GeneratorHandler> &);
65
66 public:
67 ///\name Basic operations
68 ///\{
69
70 /**
71 * Generator subclasses can be copied without losing information.
72 */
73 Generator(const Generator &);
74 Generator & operator= (const Generator &);
75 ~Generator();
76
77 ///\}
78
79 /**
80 * We can implicitly convert to a FilteredGenerator, for being
81 * passed to a Selection subclass or combined with one or more
82 * Filter subclasses.
83 */
84 operator FilteredGenerator () const PALUDIS_ATTRIBUTE((warn_unused_result));
85
86 /**
87 * We are representable as a string, for use when stringifying.
88 */
89 std::string as_string() const PALUDIS_ATTRIBUTE((warn_unused_result));
90
91 ///\name For use by Selection
92 ///\{
93
94 /**
95 * Used by Selection subclasses to get a candidate set of
96 * repositories for consideration.
97 */
98 std::shared_ptr<const RepositoryNameSet> repositories(
99 const Environment * const,
100 const RepositoryContentMayExcludes &) const
101 PALUDIS_ATTRIBUTE((warn_unused_result));
102
103 /**
104 * Used by Selection subclasses to get a candidate set of categories
105 * for consideration.
106 */
107 std::shared_ptr<const CategoryNamePartSet> categories(
108 const Environment * const,
109 const std::shared_ptr<const RepositoryNameSet> &,
110 const RepositoryContentMayExcludes &) const
111 PALUDIS_ATTRIBUTE((warn_unused_result));
112
113 /**
114 * Used by Selection subclasses to get a candidate set of package
115 * names for consideration.
116 */
117 std::shared_ptr<const QualifiedPackageNameSet> packages(
118 const Environment * const,
119 const std::shared_ptr<const RepositoryNameSet> &,
120 const std::shared_ptr<const CategoryNamePartSet> &,
121 const RepositoryContentMayExcludes &) const
122 PALUDIS_ATTRIBUTE((warn_unused_result));
123
124 /**
125 * Used by Selection subclasses to get a candidate set of PackageID
126 * instances for consideration.
127 */
128 std::shared_ptr<const PackageIDSet> ids(
129 const Environment * const,
130 const std::shared_ptr<const RepositoryNameSet> &,
131 const std::shared_ptr<const QualifiedPackageNameSet> &,
132 const RepositoryContentMayExcludes &) const
133 PALUDIS_ATTRIBUTE((warn_unused_result));
134
135 ///\}
136 };
137
138 namespace generator
139 {
140 /**
141 * A Generator which returns all PackageIDs.
142 *
143 * \ingroup g_selections
144 */
145 class PALUDIS_VISIBLE All :
146 public Generator
147 {
148 public:
149 All();
150 };
151
152 /**
153 * A Generator which returns only those PackageIDs which match a
154 * particular PackageDepSpec.
155 *
156 * \ingroup g_selections
157 */
159 public Generator
160 {
161 public:
162 /**
163 * \param spec_id The PackageID the spec comes from. May be null. Used for
164 * [use=] style dependencies.
165 *
166 * \since 0.58 takes spec_id
167 */
168 Matches(const PackageDepSpec &, const std::shared_ptr<const PackageID> & from_id, const MatchPackageOptions &);
169 };
170
171 /**
172 * A Generator which returns only those PackageIDs which have a
173 * particular package name.
174 *
175 * \ingroup g_selections
176 */
177 class PALUDIS_VISIBLE Package :
178 public Generator
179 {
180 public:
181 Package(const QualifiedPackageName &);
182 };
183
184 /**
185 * A Generator which returns only those PackageIDs which are from a
186 * particular repository.
187 *
188 * \ingroup g_selections
189 */
190 class PALUDIS_VISIBLE FromRepository :
191 public Generator
192 {
193 public:
194 FromRepository(const RepositoryName &);
195 };
196
197 /**
198 * A Generator which returns only those PackageIDs which are in a
199 * particular repository.
200 *
201 * \ingroup g_selections
202 */
203 class PALUDIS_VISIBLE InRepository :
204 public Generator
205 {
206 public:
207 InRepository(const RepositoryName &);
208 };
209
210 /**
211 * A Generator which returns only those PackageIDs which are in a
212 * particular category.
213 *
214 * \ingroup g_selections
215 */
216 class PALUDIS_VISIBLE Category :
217 public Generator
218 {
219 public:
220 Category(const CategoryNamePart &);
221 };
222
223 /**
224 * A Generator which returns the intersection of two other Generator
225 * instances.
226 *
227 * Usually constructed by using operator + on two Generators.
228 *
229 * \ingroup g_selections
230 */
231 class PALUDIS_VISIBLE Intersection :
232 public Generator
233 {
234 public:
235 Intersection(const Generator &, const Generator &);
236 };
237
238 /**
239 * A Generator which returns the union of two other Generator
240 * instances.
241 *
242 * Usually constructed by using operator & on two Generators.
243 *
244 * \ingroup g_selections
245 */
246 class PALUDIS_VISIBLE Union :
247 public Generator
248 {
249 public:
250 Union(const Generator &, const Generator &);
251 };
252
253 /**
254 * A Generator which returns PackageID instances which might support a
255 * particular Action.
256 *
257 * There is no guarantee that returned PackageID instances will actually
258 * support the Action subclass in question. However, explicitly checking
259 * whether a PackageID really does support an Action is sometimes more
260 * work than is necessary at the query stage.
261 *
262 * \ingroup g_selections
263 */
264 template <typename>
265 class PALUDIS_VISIBLE SomeIDsMightSupportAction :
266 public Generator
267 {
268 public:
269 SomeIDsMightSupportAction();
270 };
271
272 /**
273 * A Generator which returns no PackageIDs.
274 *
275 * \ingroup g_selections
276 */
277 class PALUDIS_VISIBLE Nothing :
278 public Generator
279 {
280 public:
281 Nothing();
282 };
283 }
284
285 extern template class Pimp<Generator>;
286
287}
288
289#endif
Definition environment.hh:203
Definition filtered_generator.hh:49
Generator(const Generator &)
std::shared_ptr< const QualifiedPackageNameSet > packages(const Environment *const, const std::shared_ptr< const RepositoryNameSet > &, const std::shared_ptr< const CategoryNamePartSet > &, const RepositoryContentMayExcludes &) const PALUDIS_ATTRIBUTE((warn_unused_result))
std::shared_ptr< const RepositoryNameSet > repositories(const Environment *const, const RepositoryContentMayExcludes &) const PALUDIS_ATTRIBUTE((warn_unused_result))
std::shared_ptr< const CategoryNamePartSet > categories(const Environment *const, const std::shared_ptr< const RepositoryNameSet > &, const RepositoryContentMayExcludes &) const PALUDIS_ATTRIBUTE((warn_unused_result))
std::shared_ptr< const PackageIDSet > ids(const Environment *const, const std::shared_ptr< const RepositoryNameSet > &, const std::shared_ptr< const QualifiedPackageNameSet > &, const RepositoryContentMayExcludes &) const PALUDIS_ATTRIBUTE((warn_unused_result))
std::string as_string() const PALUDIS_ATTRIBUTE((warn_unused_result))
Definition dep_spec.hh:348
Definition pimp.hh:52
Definition name.hh:112
Matches(const PackageDepSpec &, const std::shared_ptr< const PackageID > &from_id, const MatchPackageOptions &)
WrappedValue< CategoryNamePartTag > CategoryNamePart
Definition name-fwd.hh:61
WrappedValue< RepositoryNameTag > RepositoryName
Definition name-fwd.hh:105
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