paludis  Version 2.6.0
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>
24 #include <paludis/metadata_key.hh>
25 #include <paludis/mask.hh>
26 #include <paludis/util/set.hh>
27 #include <functional>
28 
29 namespace paludis
30 {
31  class FakeRepositoryBase;
32 
33  template <typename C_>
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:
45 
46  virtual const std::shared_ptr<const C_> parse_value() const PALUDIS_ATTRIBUTE((warn_unused_result));
47 
48  virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
49  virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
50  virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result));
51 
52  virtual const std::string pretty_print_value(
53  const PrettyPrinter &,
54  const PrettyPrintOptions &) const PALUDIS_ATTRIBUTE((warn_unused_result));
55  };
56 
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  virtual const std::string pretty_print_value(
67  const PrettyPrinter &,
68  const PrettyPrintOptions &) const PALUDIS_ATTRIBUTE((warn_unused_result));
69  };
70 
71  template <typename C_>
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);
82 
83  virtual const std::shared_ptr<const C_> parse_value() const
84  PALUDIS_ATTRIBUTE((warn_unused_result));
85 
86  void set_from_string(const std::string &);
87 
88  virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
89  virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
90  virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result));
91 
92  virtual const std::string pretty_print_value(
93  const PrettyPrinter &,
94  const PrettyPrintOptions &) const PALUDIS_ATTRIBUTE((warn_unused_result));
95  };
96 
97  template <>
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);
109 
110  virtual const std::shared_ptr<const FetchableURISpecTree> parse_value() const
111  PALUDIS_ATTRIBUTE((warn_unused_result));
112 
113  void set_from_string(const std::string &);
114 
115  virtual const std::shared_ptr<const URILabel> initial_label() const
116  PALUDIS_ATTRIBUTE((warn_unused_result));
117 
118  virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
119  virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
120  virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result));
121 
122  virtual const std::string pretty_print_value(
123  const PrettyPrinter &,
124  const PrettyPrintOptions &) const PALUDIS_ATTRIBUTE((warn_unused_result));
125  };
126 
127  template <>
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);
140 
141  virtual const std::shared_ptr<const DependencySpecTree> parse_value() const
142  PALUDIS_ATTRIBUTE((warn_unused_result));
143 
144  void set_from_string(const std::string &);
145 
146  virtual const std::shared_ptr<const DependenciesLabelSequence> initial_labels() const
147  PALUDIS_ATTRIBUTE((warn_unused_result));
148 
149  virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
150  virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
151  virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result));
152 
153  virtual const std::string pretty_print_value(
154  const PrettyPrinter &,
155  const PrettyPrintOptions &) const PALUDIS_ATTRIBUTE((warn_unused_result));
156  };
157 
159  public MetadataValueKey<std::shared_ptr<const Choices> >
160  {
161  private:
163 
164  public:
166  const Environment * const,
167  const std::shared_ptr<const PackageID> &);
169 
170  void add(const std::string &, const std::string &);
171  const std::shared_ptr<const Choices> parse_value() const PALUDIS_ATTRIBUTE((warn_unused_result));
172 
173  virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
174  virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result));
175  virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result));
176  };
177 
179  public UnacceptedMask
180  {
181  private:
183 
184  public:
185  FakeUnacceptedMask(const char, const std::string &, const std::string &);
187 
188  char key() const;
189  const std::string description() const;
190  const std::string unaccepted_key_name() const;
191  };
192 
194  public UnsupportedMask
195  {
196  public:
199 
200  char key() const;
201  const std::string description() const;
202  const std::string explanation() const;
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  */
214  public PackageID,
215  public std::enable_shared_from_this<FakePackageID>
216  {
217  private:
218  Pimp<FakePackageID> _imp;
219 
220  protected:
221  virtual void need_keys_added() const;
222  virtual void need_masks_added() const;
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();
232 
233  ///\}
234 
235  virtual const std::string canonical_form(const PackageIDCanonicalForm) const;
236 
237  virtual const QualifiedPackageName name() const;
238  virtual const VersionSpec version() const;
239  virtual const RepositoryName repository_name() const;
240  virtual PackageDepSpec uniquely_identifying_spec() const;
241 
242  virtual const std::shared_ptr<const MetadataValueKey<Slot> > slot_key() const;
243  virtual const std::shared_ptr<const MetadataCollectionKey<KeywordNameSet> > keywords_key() const;
244  virtual const std::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > dependencies_key() const;
245  virtual const std::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > build_dependencies_key() const;
246  virtual const std::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > run_dependencies_key() const;
247  virtual const std::shared_ptr<const MetadataSpecTreeKey<DependencySpecTree> > post_dependencies_key() const;
248  virtual const std::shared_ptr<const MetadataSpecTreeKey<FetchableURISpecTree> > fetches_key() const;
249  virtual const std::shared_ptr<const MetadataSpecTreeKey<SimpleURISpecTree> > homepage_key() const;
250  virtual const std::shared_ptr<const MetadataValueKey<std::string> > short_description_key() const;
251  virtual const std::shared_ptr<const MetadataValueKey<std::string> > long_description_key() const;
252  virtual const std::shared_ptr<const MetadataTimeKey> installed_time_key() const;
253  virtual const std::shared_ptr<const MetadataValueKey<FSPath> > fs_location_key() const;
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  virtual const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > behaviours_key() const;
257  virtual const std::shared_ptr<const MetadataCollectionKey<Set<std::string> > > from_repositories_key() const;
258  virtual const std::shared_ptr<const MetadataValueKey<std::shared_ptr<const Choices> > > choices_key() const;
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  virtual bool arbitrary_less_than_comparison(const PackageID &) const;
283  virtual std::size_t extra_hash_value() const;
284 
285  virtual bool supports_action(const SupportsActionTestBase &) const PALUDIS_ATTRIBUTE((warn_unused_result));
286  virtual void perform_action(Action &) const;
287 
288  virtual const std::shared_ptr<const Contents> contents() const;
289 
290  };
291 }
292 
293 #endif
Definition: fake_package_id.hh:57
Definition: spec_tree-fwd.hh:71
Definition: pimp.hh:51
Definition: about_metadata-fwd.hh:23
Definition: fake_package_id.hh:213
Definition: mask.hh:184
Definition: name.hh:110
Definition: fake_package_id.hh:72
Definition: mask.hh:126
MetadataKeyType
Definition: metadata_key-fwd.hh:16
Definition: fake_package_id.hh:158
PackageIDCanonicalForm
Definition: package_id-fwd.hh:17
Definition: version_spec.hh:107
Definition: pretty_printer.hh:35
Definition: metadata_key-fwd.hh:41
Definition: package_id.hh:95
Definition: fake_package_id.hh:178
Definition: dep_spec.hh:345
Definition: environment.hh:200
Definition: action.hh:268
Definition: wrapped_value-fwd.hh:29
Definition: metadata_key-fwd.hh:39
Definition: metadata_key-fwd.hh:40
Definition: options-fwd.hh:34
Definition: fake_package_id.hh:34
Definition: action.hh:618
Definition: fake_package_id.hh:193
#define PALUDIS_ATTRIBUTE(x)
Definition: attributes.hh:53
#define PALUDIS_VISIBLE
Definition: attributes.hh:59