paludis  Version 1.4.2
unmerger.hh
Go to the documentation of this file.
1 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
2 
3 /*
4  * Copyright (c) 2007, 2008, 2009, 2010, 2011 Ciaran McCreesh
5  * Copyright (c) 2007 Piotr JaroszyƄski
6  *
7  * This file is part of the Paludis package manager. Paludis is free software;
8  * you can redistribute it and/or modify it under the terms of the GNU General
9  * Public License version 2, as published by the Free Software Foundation.
10  *
11  * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14  * details.
15  *
16  * You should have received a copy of the GNU General Public License along with
17  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
18  * Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 
21 #ifndef PALUDIS_GUARD_PALUDIS_MERGER_UNMERGER_HH
22 #define PALUDIS_GUARD_PALUDIS_MERGER_UNMERGER_HH 1
23 
25 #include <paludis/util/fs_path.hh>
26 #include <paludis/util/pimp.hh>
27 #include <paludis/util/named_value.hh>
29 #include <paludis/contents-fwd.hh>
30 #include <paludis/output_manager-fwd.hh>
31 #include <functional>
32 
33 /** \file
34  * Declarations for the Unmerger class, which can be used by Repository
35  * to implement from-filesystem unmerging.
36  *
37  * \ingroup g_repository
38  *
39  * \section Examples
40  *
41  * - None at this time.
42  */
43 
44 namespace paludis
45 {
46  class Hook;
47  class Environment;
48 
49  namespace n
50  {
51  typedef Name<struct name_environment> environment;
52  typedef Name<struct name_ignore> ignore;
53  typedef Name<struct name_maybe_output_manager> maybe_output_manager;
54  typedef Name<struct name_root> root;
55  }
56 
57  /**
58  * Options for a basic Unmerger.
59  *
60  * \see Unmerger
61  * \ingroup g_repository
62  * \since 0.30
63  */
65  {
70  };
71 
72  /**
73  * Thrown if an error occurs during an unmerge.
74  *
75  * \ingroup g_repository
76  * \ingroup g_exceptions
77  * \nosubgrouping
78  */
80  public Exception
81  {
82  public:
83  ///\name Basic operations
84  ///\{
85 
86  UnmergerError(const std::string & msg) throw ();
87 
88  ///\}
89  };
90 
91  /**
92  * Handles unmerging items.
93  *
94  * \ingroup g_repository
95  * \nosubgrouping
96  */
98  {
99  private:
100  Pimp<Unmerger> _imp;
101 
102  protected:
103  ///\name Basic operations
104  ///\{
105 
106  Unmerger(const UnmergerOptions &);
107 
108  ///\}
109 
110  /**
111  * Add entry to the unmerge set.
112  */
113  void add_unmerge_entry(const EntryType, const std::shared_ptr<const ContentsEntry> &);
114 
115  /**
116  * Populate the unmerge set.
117  */
118  virtual void populate_unmerge_set() = 0;
119 
120  /**
121  * Extend a hook with extra options.
122  */
123  virtual Hook extend_hook(const Hook &) const;
124 
125  ///\name Unmerge operations
126  ///\{
127 
128  virtual void unmerge_file(const std::shared_ptr<const ContentsEntry> &) const;
129  virtual void unmerge_dir(const std::shared_ptr<const ContentsEntry> &) const;
130  virtual void unmerge_sym(const std::shared_ptr<const ContentsEntry> &) const;
131  virtual void unmerge_misc(const std::shared_ptr<const ContentsEntry> &) const;
132 
133  ///\}
134 
135  ///\name Check operations
136  ///\{
137 
138  virtual bool check_file(const std::shared_ptr<const ContentsEntry> &) const;
139  virtual bool check_dir(const std::shared_ptr<const ContentsEntry> &) const;
140  virtual bool check_sym(const std::shared_ptr<const ContentsEntry> &) const;
141  virtual bool check_misc(const std::shared_ptr<const ContentsEntry> &) const;
142 
143  ///\}
144 
145  ///\name Unlink operations
146  ///\{
147 
148  virtual void unlink_file(FSPath, const std::shared_ptr<const ContentsEntry> &) const;
149  virtual void unlink_dir(FSPath, const std::shared_ptr<const ContentsEntry> &) const;
150  virtual void unlink_sym(FSPath, const std::shared_ptr<const ContentsEntry> &) const;
151  virtual void unlink_misc(FSPath, const std::shared_ptr<const ContentsEntry> &) const;
152 
153  ///\}
154 
155  virtual void display(const std::string &) const = 0;
156 
157  public:
158  ///\name Basic operations
159  ///\{
160 
161  virtual ~Unmerger() = 0;
162 
163  ///\}
164 
165  /**
166  * Perform the unmerge.
167  */
168  void unmerge();
169  };
170 }
171 
172 #endif
Definition: pimp.hh:51
Definition: unmerger.hh:64
Definition: exception.hh:74
Definition: unmerger.hh:97
Definition: hook.hh:74
Definition: unmerger.hh:79
Definition: named_value-fwd.hh:26
EntryType
Definition: merger_entry_type.hh:14
Definition: fs_path.hh:33
#define PALUDIS_VISIBLE
Definition: attributes.hh:71