paludis Version 3.0.2
The one true package mangler
fake_package_id.hh
1/* vim: set sw=4 sts=4 et foldmethod=syntax : */
2
3/*
4 * Copyright (c) 2007, 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_REPOSITORIES_FAKE_FAKE_PACKAGE_ID_HH
21#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_FAKE_FAKE_PACKAGE_ID_HH 1
22
23#include <paludis/package_id.hh>
25#include <paludis/mask.hh>
26#include <paludis/util/set.hh>
27#include <functional>
28
29namespace paludis
30{
32
33 template <typename C_>
34 class PALUDIS_VISIBLE FakeMetadataCollectionKey :
35 public MetadataCollectionKey<C_>
36 {
37 protected:
39
40 FakeMetadataCollectionKey(const std::string &, const std::string &, const MetadataKeyType,
41 const std::shared_ptr<const PackageID> &, const Environment * const);
42
43 public:
44 ~FakeMetadataCollectionKey() override;
45
46 const std::shared_ptr<const C_> parse_value() const override PALUDIS_ATTRIBUTE((warn_unused_result));
47
48 const std::string raw_name() const override PALUDIS_ATTRIBUTE((warn_unused_result));
49 const std::string human_name() const override PALUDIS_ATTRIBUTE((warn_unused_result));
50 MetadataKeyType type() const override PALUDIS_ATTRIBUTE((warn_unused_result));
51
52 const std::string pretty_print_value(
53 const PrettyPrinter &,
54 const PrettyPrintOptions &) const override PALUDIS_ATTRIBUTE((warn_unused_result));
55 };
56
57 class PALUDIS_VISIBLE FakeMetadataKeywordSetKey :
58 public FakeMetadataCollectionKey<KeywordNameSet>
59 {
60 public:
61 FakeMetadataKeywordSetKey(const std::string &, const std::string &, const std::string &, const MetadataKeyType,
62 const std::shared_ptr<const PackageID> &, const Environment * const);
63
64 void set_from_string(const std::string &);
65
66 const std::string pretty_print_value(
67 const PrettyPrinter &,
68 const PrettyPrintOptions &) const override PALUDIS_ATTRIBUTE((warn_unused_result));
69 };
70
71 template <typename C_>
72 class PALUDIS_VISIBLE FakeMetadataSpecTreeKey :
73 public MetadataSpecTreeKey<C_>
74 {
75 private:
77
78 public:
79 FakeMetadataSpecTreeKey(const std::string &, const std::string &, const std::string &,
80 const std::function<const std::shared_ptr<const C_> (const std::string &)> &, const MetadataKeyType);
81 ~FakeMetadataSpecTreeKey() override;
82
83 const std::shared_ptr<const C_> parse_value() const
84 override PALUDIS_ATTRIBUTE((warn_unused_result));
85
86 void set_from_string(const std::string &);
87
88 const std::string raw_name() const override PALUDIS_ATTRIBUTE((warn_unused_result));
89 const std::string human_name() const override PALUDIS_ATTRIBUTE((warn_unused_result));
90 MetadataKeyType type() const override PALUDIS_ATTRIBUTE((warn_unused_result));
91
92 const std::string pretty_print_value(
93 const PrettyPrinter &,
94 const PrettyPrintOptions &) const override PALUDIS_ATTRIBUTE((warn_unused_result));
95 };
96
97 template <>
98 class PALUDIS_VISIBLE FakeMetadataSpecTreeKey<FetchableURISpecTree> :
99 public MetadataSpecTreeKey<FetchableURISpecTree>
100 {
101 private:
103
104 public:
105 FakeMetadataSpecTreeKey(const std::string &, const std::string &, const std::string &,
106 const std::function<const std::shared_ptr<const FetchableURISpecTree> (const std::string &)> &,
107 const MetadataKeyType);
108 ~FakeMetadataSpecTreeKey() override;
109
110 const std::shared_ptr<const FetchableURISpecTree> parse_value() const
111 override PALUDIS_ATTRIBUTE((warn_unused_result));
112
113 void set_from_string(const std::string &);
114
115 const std::shared_ptr<const URILabel> initial_label() const
116 override PALUDIS_ATTRIBUTE((warn_unused_result));
117
118 const std::string raw_name() const override PALUDIS_ATTRIBUTE((warn_unused_result));
119 const std::string human_name() const override PALUDIS_ATTRIBUTE((warn_unused_result));
120 MetadataKeyType type() const override PALUDIS_ATTRIBUTE((warn_unused_result));
121
122 const std::string pretty_print_value(
123 const PrettyPrinter &,
124 const PrettyPrintOptions &) const override PALUDIS_ATTRIBUTE((warn_unused_result));
125 };
126
127 template <>
128 class PALUDIS_VISIBLE FakeMetadataSpecTreeKey<DependencySpecTree> :
129 public MetadataSpecTreeKey<DependencySpecTree>
130 {
131 private:
133
134 public:
135 FakeMetadataSpecTreeKey(const std::string &, const std::string &, const std::string &,
136 const std::function<const std::shared_ptr<const DependencySpecTree> (const std::string &)> &,
137 const std::shared_ptr<const DependenciesLabelSequence> &,
138 const MetadataKeyType);
139 ~FakeMetadataSpecTreeKey() override;
140
141 const std::shared_ptr<const DependencySpecTree> parse_value() const
142 override PALUDIS_ATTRIBUTE((warn_unused_result));
143
144 void set_from_string(const std::string &);
145
146 const std::shared_ptr<const DependenciesLabelSequence> initial_labels() const
147 override PALUDIS_ATTRIBUTE((warn_unused_result));
148
149 const std::string raw_name() const override PALUDIS_ATTRIBUTE((warn_unused_result));
150 const std::string human_name() const override PALUDIS_ATTRIBUTE((warn_unused_result));
151 MetadataKeyType type() const override PALUDIS_ATTRIBUTE((warn_unused_result));
152
153 const std::string pretty_print_value(
154 const PrettyPrinter &,
155 const PrettyPrintOptions &) const override PALUDIS_ATTRIBUTE((warn_unused_result));
156 };
157
158 class PALUDIS_VISIBLE FakeMetadataChoicesKey :
159 public MetadataValueKey<std::shared_ptr<const Choices> >
160 {
161 private:
163
164 public:
165 FakeMetadataChoicesKey(
166 const Environment * const,
167 const std::shared_ptr<const PackageID> &);
168 ~FakeMetadataChoicesKey() override;
169
170 void add(const std::string &, const std::string &);
171 const std::shared_ptr<const Choices> parse_value() const override PALUDIS_ATTRIBUTE((warn_unused_result));
172
173 const std::string raw_name() const override PALUDIS_ATTRIBUTE((warn_unused_result));
174 const std::string human_name() const override PALUDIS_ATTRIBUTE((warn_unused_result));
175 MetadataKeyType type() const override PALUDIS_ATTRIBUTE((warn_unused_result));
176 };
177
178 class PALUDIS_VISIBLE FakeUnacceptedMask :
179 public UnacceptedMask
180 {
181 private:
183
184 public:
185 FakeUnacceptedMask(const char, const std::string &, const std::string &);
186 ~FakeUnacceptedMask() override;
187
188 char key() const override;
189 const std::string description() const override;
190 const std::string unaccepted_key_name() const override;
191 };
192
193 class PALUDIS_VISIBLE FakeUnsupportedMask :
194 public UnsupportedMask
195 {
196 public:
197 FakeUnsupportedMask();
198 ~FakeUnsupportedMask() override;
199
200 char key() const override;
201 const std::string description() const override;
202 const std::string explanation() const override;
203 };
204
205 /**
206 * A PackageID in a FakeRepository or a FakeInstalledRepository.
207 *
208 * Various keys can be modified.
209 *
210 * \ingroup g_fake_repository
211 * \since 0.26
212 */
213 class PALUDIS_VISIBLE FakePackageID :
214 public PackageID,
215 public std::enable_shared_from_this<FakePackageID>
216 {
217 private:
219
220 protected:
221 void need_keys_added() const override;
222 void need_masks_added() const override;
223
224 public:
225 ///\name Basic operations
226 ///\{
227
228 FakePackageID(const Environment * const e,
229 const RepositoryName &,
230 const QualifiedPackageName &, const VersionSpec &);
231 ~FakePackageID() override;
232
233 ///\}
234
235 const std::string canonical_form(const PackageIDCanonicalForm) const override;
236
237 const QualifiedPackageName name() const override;
238 const VersionSpec version() const override;
239 const RepositoryName repository_name() const override;
241
242 const std::shared_ptr<const MetadataValueKey<Slot> > slot_key() const override;
243 const std::shared_ptr<const MetadataCollectionKey<KeywordNameSet> > keywords_key() const override;
244 const std::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > dependencies_key() const override;
245 const std::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > build_dependencies_key() const override;
246 const std::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > run_dependencies_key() const override;
247 const std::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > post_dependencies_key() const override;
248 const std::shared_ptr<const MetadataSpecTreeKey<FetchableURISpecTree> > fetches_key() const override;
249 const std::shared_ptr<const MetadataSpecTreeKey<SimpleURISpecTree> > homepage_key() const override;
250 const std::shared_ptr<const MetadataValueKey<std::string> > short_description_key() const override;
251 const std::shared_ptr<const MetadataValueKey<std::string> > long_description_key() const override;
252 const std::shared_ptr<const MetadataTimeKey> installed_time_key() const override;
253 const std::shared_ptr<const MetadataValueKey<FSPath> > fs_location_key() const override;
254 virtual const std::shared_ptr<const MetadataValueKey<long> > size_of_download_required_key() const;
255 virtual const std::shared_ptr<const MetadataValueKey<long> > size_of_all_distfiles_key() const;
256 const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > behaviours_key() const override;
257 const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > from_repositories_key() const override;
258 const std::shared_ptr<const MetadataValueKey<std::shared_ptr<const Choices> > > choices_key() const override;
259
260 const std::shared_ptr<const MetadataSpecTreeKey<LicenseSpecTree> > license_key() const;
261
262 ///\name Modifiable keys
263 ///\{
264
265 const std::shared_ptr<FakeMetadataKeywordSetKey> keywords_key();
266 const std::shared_ptr<FakeMetadataSpecTreeKey<DependencySpecTree> > build_dependencies_key();
267 const std::shared_ptr<FakeMetadataSpecTreeKey<DependencySpecTree> > run_dependencies_key();
268 const std::shared_ptr<FakeMetadataSpecTreeKey<DependencySpecTree> > post_dependencies_key();
269 const std::shared_ptr<FakeMetadataSpecTreeKey<FetchableURISpecTree> > fetches_key();
270 const std::shared_ptr<FakeMetadataSpecTreeKey<SimpleURISpecTree> > homepage_key();
271 const std::shared_ptr<FakeMetadataChoicesKey> choices_key();
272
273 const std::shared_ptr<Set<std::string> > behaviours_set();
274
275 void set_slot(const SlotName &);
276 void set_slot(const SlotName &, const SlotName &);
277
278 ///\}
279
280 char use_expand_separator() const;
281
282 bool arbitrary_less_than_comparison(const PackageID &) const override;
283 std::size_t extra_hash_value() const override;
284
285 bool supports_action(const SupportsActionTestBase &) const override PALUDIS_ATTRIBUTE((warn_unused_result));
286 void perform_action(Action &) const override;
287
288 const std::shared_ptr<const Contents> contents() const override;
289
290 };
291}
292
293#endif
Definition action.hh:278
Definition choice.hh:152
Definition environment.hh:203
const std::shared_ptr< const Choices > parse_value() const override PALUDIS_ATTRIBUTE((warn_unused_result))
const std::shared_ptr< const C_ > parse_value() const override PALUDIS_ATTRIBUTE((warn_unused_result))
const std::string human_name() const override PALUDIS_ATTRIBUTE((warn_unused_result))
const std::string pretty_print_value(const PrettyPrinter &, const PrettyPrintOptions &) const override PALUDIS_ATTRIBUTE((warn_unused_result))
const std::string raw_name() const override PALUDIS_ATTRIBUTE((warn_unused_result))
MetadataKeyType type() const override PALUDIS_ATTRIBUTE((warn_unused_result))
const std::string pretty_print_value(const PrettyPrinter &, const PrettyPrintOptions &) const override PALUDIS_ATTRIBUTE((warn_unused_result))
const std::shared_ptr< const DependencySpecTree > parse_value() const override PALUDIS_ATTRIBUTE((warn_unused_result))
const std::string pretty_print_value(const PrettyPrinter &, const PrettyPrintOptions &) const override PALUDIS_ATTRIBUTE((warn_unused_result))
const std::string human_name() const override PALUDIS_ATTRIBUTE((warn_unused_result))
const std::shared_ptr< const DependenciesLabelSequence > initial_labels() const override PALUDIS_ATTRIBUTE((warn_unused_result))
MetadataKeyType type() const override PALUDIS_ATTRIBUTE((warn_unused_result))
const std::string raw_name() const override PALUDIS_ATTRIBUTE((warn_unused_result))
const std::string pretty_print_value(const PrettyPrinter &, const PrettyPrintOptions &) const override PALUDIS_ATTRIBUTE((warn_unused_result))
const std::string raw_name() const override PALUDIS_ATTRIBUTE((warn_unused_result))
MetadataKeyType type() const override PALUDIS_ATTRIBUTE((warn_unused_result))
const std::shared_ptr< const FetchableURISpecTree > parse_value() const override PALUDIS_ATTRIBUTE((warn_unused_result))
const std::shared_ptr< const URILabel > initial_label() const override PALUDIS_ATTRIBUTE((warn_unused_result))
const std::string human_name() const override PALUDIS_ATTRIBUTE((warn_unused_result))
MetadataKeyType type() const override PALUDIS_ATTRIBUTE((warn_unused_result))
const std::shared_ptr< const C_ > parse_value() const override PALUDIS_ATTRIBUTE((warn_unused_result))
const std::string pretty_print_value(const PrettyPrinter &, const PrettyPrintOptions &) const override PALUDIS_ATTRIBUTE((warn_unused_result))
const std::string human_name() const override PALUDIS_ATTRIBUTE((warn_unused_result))
const std::string raw_name() const override PALUDIS_ATTRIBUTE((warn_unused_result))
const RepositoryName repository_name() const override
const std::shared_ptr< const MetadataSpecTreeKey< FetchableURISpecTree > > fetches_key() const override
const std::shared_ptr< const MetadataValueKey< FSPath > > fs_location_key() const override
void need_keys_added() const override
const std::shared_ptr< const MetadataValueKey< Slot > > slot_key() const override
const std::shared_ptr< const MetadataValueKey< std::string > > long_description_key() const override
PackageDepSpec uniquely_identifying_spec() const override
void need_masks_added() const override
const std::shared_ptr< const MetadataValueKey< std::shared_ptr< const Choices > > > choices_key() const override
const std::shared_ptr< const MetadataSpecTreeKey< DependencySpecTree > > build_dependencies_key() const override
void perform_action(Action &) const override
const std::shared_ptr< const MetadataSpecTreeKey< SimpleURISpecTree > > homepage_key() const override
std::size_t extra_hash_value() const override
bool supports_action(const SupportsActionTestBase &) const override PALUDIS_ATTRIBUTE((warn_unused_result))
const std::shared_ptr< const MetadataCollectionKey< Set< std::string > > > from_repositories_key() const override
const std::shared_ptr< const MetadataTimeKey > installed_time_key() const override
const std::shared_ptr< const MetadataValueKey< std::string > > short_description_key() const override
bool arbitrary_less_than_comparison(const PackageID &) const override
const VersionSpec version() const override
const std::shared_ptr< const MetadataCollectionKey< KeywordNameSet > > keywords_key() const override
const std::string canonical_form(const PackageIDCanonicalForm) const override
const QualifiedPackageName name() const override
const std::shared_ptr< const MetadataSpecTreeKey< DependencySpecTree > > run_dependencies_key() const override
const std::shared_ptr< const MetadataCollectionKey< Set< std::string > > > behaviours_key() const override
const std::shared_ptr< const Contents > contents() const override
const std::shared_ptr< const MetadataSpecTreeKey< DependencySpecTree > > post_dependencies_key() const override
const std::shared_ptr< const MetadataSpecTreeKey< DependencySpecTree > > dependencies_key() const override
Definition fake_repository_base.hh:48
char key() const override
const std::string description() const override
const std::string unaccepted_key_name() const override
const std::string description() const override
char key() const override
const std::string explanation() const override
Definition metadata_key.hh:279
Definition metadata_key.hh:305
Definition metadata_key.hh:229
Definition dep_spec.hh:348
Definition pimp.hh:52
Definition pretty_printer.hh:36
Definition name.hh:112
Definition action.hh:633
Definition dep_label.hh:59
Definition mask.hh:129
Definition mask.hh:187
Definition version_spec.hh:109
Sequence< std::shared_ptr< const DependenciesLabel > > DependenciesLabelSequence
Definition dep_label-fwd.hh:221
WrappedValue< SlotNameTag > SlotName
Definition name-fwd.hh:93
WrappedValue< RepositoryNameTag > RepositoryName
Definition name-fwd.hh:105
#define PALUDIS_ATTRIBUTE(x)
Definition attributes.hh:53
#define PALUDIS_VISIBLE
Definition attributes.hh:59
Definition about_metadata-fwd.hh:24