/* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* * Copyright (c) 2007, 2008, 2010, 2011 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General * Public License version 2, as published by the Free Software Foundation. * * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with * this program; if not, write to the Free Software Foundation, Inc., 59 Temple * Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef PALUDIS_GUARD_PALUDIS_DISTRIBUTION_HH #define PALUDIS_GUARD_PALUDIS_DISTRIBUTION_HH 1 #include #include #include #include #include #include #include #include /** \file * Declarations for distributions. * * \ingroup g_distribution * * \section Examples * * - None at this time. The Distribution classes are of little direct use to * clients; they are mainly used by Repository and Environment implementations. */ namespace paludis { namespace n { typedef Name concept_keyword; typedef Name concept_license; typedef Name concept_use; typedef Name default_environment; typedef Name extra_data_dir; typedef Name fallback_environment; typedef Name name; typedef Name paludis_package; } /** * Information about a distribution. * * The Distribution::config_dir key points to a directory that can be used * by submodules to store their own configuration. * * \see DistributionData * \ingroup g_distribution * \since 0.30 * \nosubgrouping */ struct Distribution { NamedValue concept_keyword; NamedValue concept_license; NamedValue concept_use; NamedValue default_environment; NamedValue extra_data_dir; NamedValue fallback_environment; NamedValue name; NamedValue paludis_package; }; /** * Thrown if an invalid distribution file is encountered. * * \ingroup g_distribution * \ingroup g_exceptions * \since 0.26 * \nosubgrouping */ class PALUDIS_VISIBLE DistributionConfigurationError : public ConfigurationError { public: ///\name Basic operations ///\{ DistributionConfigurationError(const std::string &) throw (); ///\} }; /** * Fetch information about a distribution. * * Paludis avoids hardcoding certain distribution-related information to * make things easier for other distributions. Instead, DistributionData * is used to fetch a Distribution class instance. The * distribution_from_string method is almost always called with the return * value of Environment::distribution as its parameter. * * \ingroup g_distribution * \since 0.26 * \nosubgrouping */ class PALUDIS_VISIBLE DistributionData : public Singleton { friend class Singleton; private: Pimp _imp; DistributionData(); ~DistributionData(); public: /** * Fetch a distribution from a named string. */ std::shared_ptr distribution_from_string(const std::string &) const; }; /** * Fetch module-specific information about a distribution. * * Various modules provide typedefs for instantiations of this template, * allowing access to additional information abotu a distribution. * * \ingroup g_distribution * \since 0.30 */ template class PALUDIS_VISIBLE ExtraDistributionData : public Singleton > { friend class Singleton >; private: Pimp _imp; ExtraDistributionData(); ~ExtraDistributionData(); public: /** * Fetch our data from a given distribution. */ const std::shared_ptr data_from_distribution( const Distribution &) const PALUDIS_ATTRIBUTE((warn_unused_result)); }; extern template class Singleton; } #endif