unmerger.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  * Copyright (c) 2007 Piotr JaroszyƄski
00006  *
00007  * This file is part of the Paludis package manager. Paludis is free software;
00008  * you can redistribute it and/or modify it under the terms of the GNU General
00009  * Public License version 2, as published by the Free Software Foundation.
00010  *
00011  * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
00012  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00013  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
00014  * details.
00015  *
00016  * You should have received a copy of the GNU General Public License along with
00017  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00018  * Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 
00021 #ifndef PALUDIS_GUARD_PALUDIS_MERGER_UNMERGER_HH
00022 #define PALUDIS_GUARD_PALUDIS_MERGER_UNMERGER_HH 1
00023 
00024 #include <paludis/util/exception.hh>
00025 #include <paludis/util/fs_entry.hh>
00026 #include <paludis/util/private_implementation_pattern.hh>
00027 #include <paludis/util/named_value.hh>
00028 #include <paludis/merger_entry_type.hh>
00029 
00030 /** \file
00031  * Declarations for the Unmerger class, which can be used by Repository
00032  * to implement from-filesystem unmerging.
00033  *
00034  * \ingroup g_repository
00035  *
00036  * \section Examples
00037  *
00038  * - None at this time.
00039  */
00040 
00041 namespace paludis
00042 {
00043     class Hook;
00044     class Environment;
00045 
00046     namespace n
00047     {
00048         struct environment;
00049         struct root;
00050     }
00051 
00052     /**
00053      * Options for a basic Unmerger.
00054      *
00055      * \see Unmerger
00056      * \ingroup g_repository
00057      * \since 0.30
00058      */
00059     struct UnmergerOptions
00060     {
00061         NamedValue<n::environment, const Environment *> environment;
00062         NamedValue<n::root, FSEntry> root;
00063     };
00064 
00065     /**
00066      * Thrown if an error occurs during an unmerge.
00067      *
00068      * \ingroup g_repository
00069      * \ingroup g_exceptions
00070      * \nosubgrouping
00071      */
00072     class PALUDIS_VISIBLE UnmergerError :
00073         public Exception
00074     {
00075         public:
00076             ///\name Basic operations
00077             ///\{
00078 
00079             UnmergerError(const std::string & msg) throw ();
00080 
00081             ///\}
00082     };
00083 
00084     /**
00085      * Handles unmerging items.
00086      *
00087      * \ingroup g_repository
00088      * \nosubgrouping
00089      */
00090     class PALUDIS_VISIBLE Unmerger :
00091         private PrivateImplementationPattern<Unmerger>
00092     {
00093         protected:
00094             ///\name Basic operations
00095             ///\{
00096 
00097             Unmerger(const UnmergerOptions &);
00098 
00099             ///\}
00100 
00101             /**
00102              * Base class for extra information associated with a file
00103              * to be unmerged.
00104              *
00105              * \ingroup g_repository
00106              * \nosubgrouping
00107              */
00108             class PALUDIS_VISIBLE ExtraInfo
00109             {
00110                 public:
00111                     virtual ~ExtraInfo();
00112             };
00113 
00114             friend class Implementation<Unmerger>;
00115 
00116             /**
00117              * Add entry to the unmerge set.
00118              */
00119             void add_unmerge_entry(const std::string &, EntryType, const std::tr1::shared_ptr<ExtraInfo> &);
00120 
00121             /**
00122              * Populate the unmerge set.
00123              */
00124             virtual void populate_unmerge_set() = 0;
00125 
00126             /**
00127              * Extend a hook with extra options.
00128              */
00129             virtual Hook extend_hook(const Hook &) const;
00130 
00131             ///\name Unmerge operations
00132             ///\{
00133 
00134             virtual void unmerge_file(FSEntry &, const std::tr1::shared_ptr<ExtraInfo> &) const;
00135             virtual void unmerge_dir(FSEntry &, const std::tr1::shared_ptr<ExtraInfo> &) const;
00136             virtual void unmerge_sym(FSEntry &, const std::tr1::shared_ptr<ExtraInfo> &) const;
00137             virtual void unmerge_misc(FSEntry &, const std::tr1::shared_ptr<ExtraInfo> &) const;
00138 
00139             ///\}
00140 
00141             ///\name Check operations
00142             ///\{
00143 
00144             virtual bool check_file(const FSEntry &, const std::tr1::shared_ptr<ExtraInfo> &) const
00145             {
00146                 return true;
00147             }
00148 
00149             virtual bool check_dir(const FSEntry &, const std::tr1::shared_ptr<ExtraInfo> &) const
00150             {
00151                 return true;
00152             }
00153 
00154             virtual bool check_sym(const FSEntry &, const std::tr1::shared_ptr<ExtraInfo> &) const
00155             {
00156                 return true;
00157             }
00158 
00159             virtual bool check_misc(const FSEntry &, const std::tr1::shared_ptr<ExtraInfo> &) const
00160             {
00161                 return true;
00162             }
00163 
00164             ///\}
00165 
00166             ///\name Unlink operations
00167             ///\{
00168 
00169             virtual void unlink_file(FSEntry &, const std::tr1::shared_ptr<ExtraInfo> &) const;
00170             virtual void unlink_dir(FSEntry &, const std::tr1::shared_ptr<ExtraInfo> &) const;
00171             virtual void unlink_sym(FSEntry &, const std::tr1::shared_ptr<ExtraInfo> &) const;
00172             virtual void unlink_misc(FSEntry &, const std::tr1::shared_ptr<ExtraInfo> &) const;
00173 
00174             ///\}
00175 
00176             virtual void display(const std::string &) const = 0;
00177 
00178         public:
00179             ///\name Basic operations
00180             ///\{
00181 
00182             virtual ~Unmerger() = 0;
00183 
00184             ///\}
00185 
00186             /**
00187              * Perform the unmerge.
00188              */
00189             void unmerge();
00190     };
00191 }
00192 
00193 #endif

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