set_file.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_SET_FILE_HH
00021 #define PALUDIS_GUARD_PALUDIS_SET_FILE_HH 1
00022 
00023 #include <paludis/util/instantiation_policy.hh>
00024 #include <paludis/util/private_implementation_pattern.hh>
00025 #include <paludis/util/exception.hh>
00026 #include <paludis/util/fs_entry.hh>
00027 #include <paludis/util/options.hh>
00028 #include <paludis/util/named_value.hh>
00029 #include <paludis/name.hh>
00030 #include <paludis/spec_tree.hh>
00031 #include <paludis/dep_spec-fwd.hh>
00032 #include <paludis/dep_tag-fwd.hh>
00033 #include <tr1/functional>
00034 #include <iosfwd>
00035 
00036 /** \file
00037  * Declarations for the SetFile classes, which are used by Environment and
00038  * Repository implementations for files containing a package set.
00039  *
00040  * \ingroup g_environment
00041  * \ingroup g_repository
00042  *
00043  * \section Examples
00044  *
00045  * - None at this time.
00046  */
00047 
00048 namespace paludis
00049 {
00050     class Environment;
00051 
00052 #include <paludis/set_file-se.hh>
00053 
00054     namespace n
00055     {
00056         struct environment;
00057         struct file_name;
00058         struct parser;
00059         struct set_operator_mode;
00060         struct tag;
00061         struct type;
00062     }
00063 
00064     /**
00065      * Parameters for a SetFile.
00066      *
00067      * \ingroup g_environment
00068      * \ingroup g_repository
00069      */
00070     struct SetFileParams
00071     {
00072         NamedValue<n::environment, const Environment *> environment;
00073         NamedValue<n::file_name, FSEntry> file_name;
00074         NamedValue<n::parser, std::tr1::function<PackageDepSpec (const std::string &)> > parser;
00075         NamedValue<n::set_operator_mode, SetFileSetOperatorMode> set_operator_mode;
00076         NamedValue<n::tag, std::tr1::shared_ptr<const DepTag> > tag;
00077         NamedValue<n::type, SetFileType> type;
00078     };
00079 
00080     /**
00081      * Thrown if there is a problem reading or writing a SetFile.
00082      *
00083      * \ingroup g_environment
00084      * \ingroup g_repository
00085      * \ingroup g_exceptions
00086      * \nosubgrouping
00087      */
00088     class PALUDIS_VISIBLE SetFileError :
00089         public ConfigurationError
00090     {
00091         public:
00092             ///\name Basic operations
00093             ///\{
00094 
00095             SetFileError(const FSEntry &, const std::string &) throw ();
00096 
00097             ///\}
00098     };
00099 
00100     /**
00101      * Shared code for files containing a package set.
00102      *
00103      * Various set file formats are supported:
00104      *
00105      * - sft_paludis_conf, a line-based set file with prefixed entries
00106      * - sft_paludis_bash, a bash script that outputs an sft_paludis_conf
00107      * - sft_simple, a simple line-based file
00108      *
00109      * The file can be modified if it is sft_paludis_conf or sft_simple.
00110      *
00111      * \ingroup g_environment
00112      * \ingroup g_repository
00113      * \nosubgrouping
00114      */
00115     class PALUDIS_VISIBLE SetFile :
00116         private InstantiationPolicy<SetFile, instantiation_method::NonCopyableTag>,
00117         private PrivateImplementationPattern<SetFile>
00118     {
00119         public:
00120             ///\name Basic operations
00121             ///\{
00122 
00123             SetFile(const SetFileParams &);
00124             ~SetFile();
00125 
00126             ///\}
00127 
00128             /**
00129              * Fetch our contents.
00130              */
00131             const std::tr1::shared_ptr<const SetSpecTree> contents() const;
00132 
00133             /**
00134              * Rewrite our contents.
00135              */
00136             void rewrite() const;
00137 
00138             /**
00139              * Add an item to our contents, if it is not there already.
00140              */
00141             void add(const std::string &);
00142 
00143             /**
00144              * Remove any matching lines.
00145              */
00146             void remove(const std::string &);
00147     };
00148 
00149     /**
00150      * Split a SetName into a SetName and a SetFileSetOperatorMode.
00151      *
00152      * \see SetName
00153      * \ingroup g_repository
00154      * \since 0.26
00155      */
00156     std::pair<SetName, SetFileSetOperatorMode> find_base_set_name_and_suffix_mode(const SetName &)
00157         PALUDIS_VISIBLE PALUDIS_ATTRIBUTE((warn_unused_result));
00158 }
00159 
00160 #endif

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