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

Generated on Mon Dec 22 19:43:51 2008 for paludis by  doxygen 1.5.7.1