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, 2009 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 #include <paludis/contents-fwd.hh>
00030 #include <tr1/functional>
00031 
00032 /** \file
00033  * Declarations for the Unmerger class, which can be used by Repository
00034  * to implement from-filesystem unmerging.
00035  *
00036  * \ingroup g_repository
00037  *
00038  * \section Examples
00039  *
00040  * - None at this time.
00041  */
00042 
00043 namespace paludis
00044 {
00045     class Hook;
00046     class Environment;
00047 
00048     namespace n
00049     {
00050         struct environment;
00051         struct ignore;
00052         struct root;
00053     }
00054 
00055     /**
00056      * Options for a basic Unmerger.
00057      *
00058      * \see Unmerger
00059      * \ingroup g_repository
00060      * \since 0.30
00061      */
00062     struct UnmergerOptions
00063     {
00064         NamedValue<n::environment, const Environment *> environment;
00065         NamedValue<n::ignore, const std::tr1::function<bool (const FSEntry &)> > ignore;
00066         NamedValue<n::root, FSEntry> root;
00067     };
00068 
00069     /**
00070      * Thrown if an error occurs during an unmerge.
00071      *
00072      * \ingroup g_repository
00073      * \ingroup g_exceptions
00074      * \nosubgrouping
00075      */
00076     class PALUDIS_VISIBLE UnmergerError :
00077         public Exception
00078     {
00079         public:
00080             ///\name Basic operations
00081             ///\{
00082 
00083             UnmergerError(const std::string & msg) throw ();
00084 
00085             ///\}
00086     };
00087 
00088     /**
00089      * Handles unmerging items.
00090      *
00091      * \ingroup g_repository
00092      * \nosubgrouping
00093      */
00094     class PALUDIS_VISIBLE Unmerger :
00095         private PrivateImplementationPattern<Unmerger>
00096     {
00097         protected:
00098             ///\name Basic operations
00099             ///\{
00100 
00101             Unmerger(const UnmergerOptions &);
00102 
00103             ///\}
00104 
00105             /**
00106              * Add entry to the unmerge set.
00107              */
00108             void add_unmerge_entry(const EntryType, const std::tr1::shared_ptr<const ContentsEntry> &);
00109 
00110             /**
00111              * Populate the unmerge set.
00112              */
00113             virtual void populate_unmerge_set() = 0;
00114 
00115             /**
00116              * Extend a hook with extra options.
00117              */
00118             virtual Hook extend_hook(const Hook &) const;
00119 
00120             ///\name Unmerge operations
00121             ///\{
00122 
00123             virtual void unmerge_file(const std::tr1::shared_ptr<const ContentsEntry> &) const;
00124             virtual void unmerge_dir(const std::tr1::shared_ptr<const ContentsEntry> &) const;
00125             virtual void unmerge_sym(const std::tr1::shared_ptr<const ContentsEntry> &) const;
00126             virtual void unmerge_misc(const std::tr1::shared_ptr<const ContentsEntry> &) const;
00127 
00128             ///\}
00129 
00130             ///\name Check operations
00131             ///\{
00132 
00133             virtual bool check_file(const std::tr1::shared_ptr<const ContentsEntry> &) const;
00134             virtual bool check_dir(const std::tr1::shared_ptr<const ContentsEntry> &) const;
00135             virtual bool check_sym(const std::tr1::shared_ptr<const ContentsEntry> &) const;
00136             virtual bool check_misc(const std::tr1::shared_ptr<const ContentsEntry> &) const;
00137 
00138             ///\}
00139 
00140             ///\name Unlink operations
00141             ///\{
00142 
00143             virtual void unlink_file(FSEntry, const std::tr1::shared_ptr<const ContentsEntry> &) const;
00144             virtual void unlink_dir(FSEntry, const std::tr1::shared_ptr<const ContentsEntry> &) const;
00145             virtual void unlink_sym(FSEntry, const std::tr1::shared_ptr<const ContentsEntry> &) const;
00146             virtual void unlink_misc(FSEntry, const std::tr1::shared_ptr<const ContentsEntry> &) const;
00147 
00148             ///\}
00149 
00150             virtual void display(const std::string &) const = 0;
00151 
00152         public:
00153             ///\name Basic operations
00154             ///\{
00155 
00156             virtual ~Unmerger() = 0;
00157 
00158             ///\}
00159 
00160             /**
00161              * Perform the unmerge.
00162              */
00163             void unmerge();
00164     };
00165 }
00166 
00167 #endif

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