distribution.hh

Go to the documentation of this file.
00001 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
00002 
00003 /*
00004  * Copyright (c) 2007, 2008 Ciaran McCreesh
00005  *
00006  * This file is part of the Paludis package manager. Paludis is free software;
00007  * you can redistribute it and/or modify it under the terms of the GNU General
00008  * Public License version 2, as published by the Free Software Foundation.
00009  *
00010  * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
00011  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00012  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
00013  * details.
00014  *
00015  * You should have received a copy of the GNU General Public License along with
00016  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00017  * Place, Suite 330, Boston, MA  02111-1307  USA
00018  */
00019 
00020 #ifndef PALUDIS_GUARD_PALUDIS_DISTRIBUTION_HH
00021 #define PALUDIS_GUARD_PALUDIS_DISTRIBUTION_HH 1
00022 
00023 #include <paludis/distribution-fwd.hh>
00024 #include <paludis/util/attributes.hh>
00025 #include <paludis/util/exception.hh>
00026 #include <paludis/util/private_implementation_pattern.hh>
00027 #include <paludis/util/instantiation_policy.hh>
00028 #include <paludis/util/named_value.hh>
00029 #include <paludis/util/fs_entry.hh>
00030 #include <tr1/memory>
00031 
00032 /** \file
00033  * Declarations for distributions.
00034  *
00035  * \ingroup g_distribution
00036  *
00037  * \section Examples
00038  *
00039  * - None at this time. The Distribution classes are of little direct use to
00040  *   clients; they are mainly used by Repository and Environment implementations.
00041  */
00042 
00043 namespace paludis
00044 {
00045     namespace n
00046     {
00047         struct concept_keyword;
00048         struct concept_license;
00049         struct concept_use;
00050         struct default_environment;
00051         struct extra_data_dir;
00052         struct fallback_environment;
00053         struct name;
00054         struct paludis_package;
00055         struct support_old_style_virtuals;
00056     }
00057 
00058     /**
00059      * Information about a distribution.
00060      *
00061      * The Distribution::config_dir key points to a directory that can be used
00062      * by submodules to store their own configuration.
00063      *
00064      * \see DistributionData
00065      * \ingroup g_distribution
00066      * \since 0.30
00067      * \nosubgrouping
00068      */
00069     struct Distribution
00070     {
00071         NamedValue<n::concept_keyword, std::string> concept_keyword;
00072         NamedValue<n::concept_license, std::string> concept_license;
00073         NamedValue<n::concept_use, std::string> concept_use;
00074         NamedValue<n::default_environment, std::string> default_environment;
00075         NamedValue<n::extra_data_dir, FSEntry> extra_data_dir;
00076         NamedValue<n::fallback_environment, std::string> fallback_environment;
00077         NamedValue<n::name, std::string> name;
00078         NamedValue<n::paludis_package, std::string> paludis_package;
00079         NamedValue<n::support_old_style_virtuals, bool> support_old_style_virtuals;
00080     };
00081 
00082     /**
00083      * Thrown if an invalid distribution file is encountered.
00084      *
00085      * \ingroup g_distribution
00086      * \ingroup g_exceptions
00087      * \since 0.26
00088      * \nosubgrouping
00089      */
00090     class PALUDIS_VISIBLE DistributionConfigurationError :
00091         public ConfigurationError
00092     {
00093         public:
00094             ///\name Basic operations
00095             ///\{
00096 
00097             DistributionConfigurationError(const std::string &) throw ();
00098 
00099             ///\}
00100     };
00101 
00102     /**
00103      * Fetch information about a distribution.
00104      *
00105      * Paludis avoids hardcoding certain distribution-related information to
00106      * make things easier for other distributions. Instead, DistributionData
00107      * is used to fetch a Distribution class instance. The
00108      * distribution_from_string method is almost always called with the return
00109      * value of Environment::distribution as its parameter.
00110      *
00111      * \ingroup g_distribution
00112      * \since 0.26
00113      * \nosubgrouping
00114      */
00115     class PALUDIS_VISIBLE DistributionData :
00116         private PrivateImplementationPattern<DistributionData>,
00117         public InstantiationPolicy<DistributionData, instantiation_method::SingletonTag>
00118     {
00119         friend class InstantiationPolicy<DistributionData, instantiation_method::SingletonTag>;
00120 
00121         private:
00122             DistributionData();
00123             ~DistributionData();
00124 
00125         public:
00126             /**
00127              * Fetch a distribution from a named string.
00128              */
00129             std::tr1::shared_ptr<const Distribution> distribution_from_string(const std::string &) const;
00130     };
00131 
00132     /**
00133      * Fetch module-specific information about a distribution.
00134      *
00135      * Various modules provide typedefs for instantiations of this template,
00136      * allowing access to additional information abotu a distribution.
00137      *
00138      * \ingroup g_distribution
00139      * \since 0.30
00140      */
00141     template <typename Data_>
00142     class PALUDIS_VISIBLE ExtraDistributionData :
00143         private PrivateImplementationPattern<ExtraDistributionData<Data_> >,
00144         public InstantiationPolicy<ExtraDistributionData<Data_>, instantiation_method::SingletonTag>
00145     {
00146         friend class InstantiationPolicy<ExtraDistributionData<Data_>, instantiation_method::SingletonTag>;
00147 
00148         private:
00149             ExtraDistributionData();
00150             ~ExtraDistributionData();
00151 
00152         public:
00153             /**
00154              * Fetch our data from a given distribution.
00155              */
00156             const std::tr1::shared_ptr<const Data_> data_from_distribution(
00157                     const Distribution &) const
00158                 PALUDIS_ATTRIBUTE((warn_unused_result));
00159     };
00160 }
00161 
00162 #endif

Generated on Mon Sep 21 10:36:08 2009 for paludis by  doxygen 1.5.4