paludis  Version 2.6.0
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 
43 namespace 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  }
58 
59  /**
60  * Information about a distribution.
61  *
62  * The Distribution::config_dir key points to a directory that can be used
63  * by submodules to store their own configuration.
64  *
65  * \see DistributionData
66  * \ingroup g_distribution
67  * \since 0.30
68  * \nosubgrouping
69  */
70  struct Distribution
71  {
80  };
81 
82  /**
83  * Thrown if an invalid distribution file is encountered.
84  *
85  * \ingroup g_distribution
86  * \ingroup g_exceptions
87  * \since 0.26
88  * \nosubgrouping
89  */
91  public ConfigurationError
92  {
93  public:
94  ///\name Basic operations
95  ///\{
96 
97  DistributionConfigurationError(const std::string &) noexcept;
98 
99  ///\}
100  };
101 
102  /**
103  * Fetch information about a distribution.
104  *
105  * Paludis avoids hardcoding certain distribution-related information to
106  * make things easier for other distributions. Instead, DistributionData
107  * is used to fetch a Distribution class instance. The
108  * distribution_from_string method is almost always called with the return
109  * value of Environment::distribution as its parameter.
110  *
111  * \ingroup g_distribution
112  * \since 0.26
113  * \nosubgrouping
114  */
116  public Singleton<DistributionData>
117  {
118  friend class Singleton<DistributionData>;
119 
120  private:
122 
124  ~DistributionData();
125 
126  public:
127  /**
128  * Fetch a distribution from a named string.
129  */
130  std::shared_ptr<const Distribution> distribution_from_string(const std::string &) const;
131  };
132 
133  /**
134  * Fetch module-specific information about a distribution.
135  *
136  * Various modules provide typedefs for instantiations of this template,
137  * allowing access to additional information abotu a distribution.
138  *
139  * \ingroup g_distribution
140  * \since 0.30
141  */
142  template <typename Data_>
145  {
146  friend class Singleton<ExtraDistributionData<Data_> >;
147 
148  private:
150 
151  ExtraDistributionData();
152  ~ExtraDistributionData();
153 
154  public:
155  /**
156  * Fetch our data from a given distribution.
157  */
158  const std::shared_ptr<const Data_> data_from_distribution(
159  const Distribution &) const
160  PALUDIS_ATTRIBUTE((warn_unused_result));
161  };
162 }
163 
164 #endif
Definition: pimp.hh:51
Definition: about_metadata-fwd.hh:23
Definition: distribution.hh:90
Definition: distribution-fwd.hh:36
Definition: singleton.hh:44
Definition: distribution.hh:70
Definition: distribution.hh:115
Definition: exception.hh:200
#define PALUDIS_ATTRIBUTE(x)
Definition: attributes.hh:53
#define PALUDIS_VISIBLE
Definition: attributes.hh:59