paludis Version 3.0.2
The one true package mangler
distribution.hh
Go to the documentation of this file.
1/* vim: set sw=4 sts=4 et foldmethod=syntax : */
2
3/*
4 * Copyright (c) 2007, 2008, 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_DISTRIBUTION_HH
21#define PALUDIS_GUARD_PALUDIS_DISTRIBUTION_HH 1
22
26#include <paludis/util/pimp.hh>
27#include <paludis/util/named_value.hh>
28#include <paludis/util/fs_path.hh>
30#include <memory>
31
32/** \file
33 * Declarations for distributions.
34 *
35 * \ingroup g_distribution
36 *
37 * \section Examples
38 *
39 * - None at this time. The Distribution classes are of little direct use to
40 * clients; they are mainly used by Repository and Environment implementations.
41 */
42
43namespace paludis
44{
45 extern template class PALUDIS_VISIBLE Singleton<DistributionData>;
46
47 namespace n
48 {
49 typedef Name<struct name_concept_keyword> concept_keyword;
50 typedef Name<struct name_concept_license> concept_license;
51 typedef Name<struct name_concept_use> concept_use;
52 typedef Name<struct name_default_environment> default_environment;
53 typedef Name<struct name_extra_data_dir> extra_data_dir;
54 typedef Name<struct name_fallback_environment> fallback_environment;
55 typedef Name<struct name_name> name;
56 typedef Name<struct name_paludis_package> paludis_package;
57 typedef Name<struct name_supports_cross_compile> supports_cross_compile;
58 }
59
60 /**
61 * Information about a distribution.
62 *
63 * The Distribution::config_dir key points to a directory that can be used
64 * by submodules to store their own configuration.
65 *
66 * \see DistributionData
67 * \ingroup g_distribution
68 * \since 0.30
69 * \nosubgrouping
70 */
83
84 /**
85 * Thrown if an invalid distribution file is encountered.
86 *
87 * \ingroup g_distribution
88 * \ingroup g_exceptions
89 * \since 0.26
90 * \nosubgrouping
91 */
92 class PALUDIS_VISIBLE DistributionConfigurationError :
94 {
95 public:
96 ///\name Basic operations
97 ///\{
98
99 DistributionConfigurationError(const std::string &) noexcept;
100
101 ///\}
102 };
103
104 /**
105 * Fetch information about a distribution.
106 *
107 * Paludis avoids hardcoding certain distribution-related information to
108 * make things easier for other distributions. Instead, DistributionData
109 * is used to fetch a Distribution class instance. The
110 * distribution_from_string method is almost always called with the return
111 * value of Environment::distribution as its parameter.
112 *
113 * \ingroup g_distribution
114 * \since 0.26
115 * \nosubgrouping
116 */
117 class PALUDIS_VISIBLE DistributionData :
118 public Singleton<DistributionData>
119 {
120 friend class Singleton<DistributionData>;
121
122 private:
124
125 DistributionData();
126 ~DistributionData();
127
128 public:
129 /**
130 * Fetch a distribution from a named string.
131 */
132 std::shared_ptr<const Distribution> distribution_from_string(const std::string &) const;
133 };
134
135 /**
136 * Fetch module-specific information about a distribution.
137 *
138 * Various modules provide typedefs for instantiations of this template,
139 * allowing access to additional information abotu a distribution.
140 *
141 * \ingroup g_distribution
142 * \since 0.30
143 */
144 template <typename Data_>
145 class PALUDIS_VISIBLE ExtraDistributionData :
146 public Singleton<ExtraDistributionData<Data_> >
147 {
148 friend class Singleton<ExtraDistributionData<Data_> >;
149
150 private:
152
153 ExtraDistributionData();
154 ~ExtraDistributionData();
155
156 public:
157 /**
158 * Fetch our data from a given distribution.
159 */
160 const std::shared_ptr<const Data_> data_from_distribution(
161 const Distribution &) const
162 PALUDIS_ATTRIBUTE((warn_unused_result));
163 };
164}
165
166#endif
ConfigurationError(const std::string &msg) noexcept
std::shared_ptr< const Distribution > distribution_from_string(const std::string &) const
const std::shared_ptr< const Data_ > data_from_distribution(const Distribution &) const PALUDIS_ATTRIBUTE((warn_unused_result))
Definition named_value.hh:110
Definition named_value.hh:51
Definition pimp.hh:52
Definition singleton.hh:45
#define PALUDIS_ATTRIBUTE(x)
Definition attributes.hh:53
#define PALUDIS_VISIBLE
Definition attributes.hh:59
Definition about_metadata-fwd.hh:24
Definition distribution.hh:72