sbuild  1.6.5
sbuild-chroot-config.h
1 /* Copyright © 2005-2007 Roger Leigh <rleigh@debian.org>
2  *
3  * schroot is free software: you can redistribute it and/or modify it
4  * under the terms of the GNU General Public License as published by
5  * the Free Software Foundation, either version 3 of the License, or
6  * (at your option) any later version.
7  *
8  * schroot is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see
15  * <http://www.gnu.org/licenses/>.
16  *
17  *********************************************************************/
18 
19 #ifndef SBUILD_CHROOT_CONFIG_H
20 #define SBUILD_CHROOT_CONFIG_H
21 
22 #include <sbuild/sbuild-chroot.h>
23 #include <sbuild/sbuild-custom-error.h>
24 
25 #include <map>
26 #include <ostream>
27 #include <vector>
28 #include <string>
29 
30 namespace sbuild
31 {
32 
43  {
44  public:
46  typedef std::vector<chroot::ptr> chroot_list;
48  typedef std::map<std::string, std::string> string_map;
50  typedef std::map<std::string, chroot::ptr> chroot_map;
52  typedef std::map<std::string, chroot_map> chroot_namespace_map;
53 
55  static const std::string namespace_separator;
56 
59  {
70  };
71 
74 
76  typedef std::shared_ptr<chroot_config> ptr;
77 
79  chroot_config ();
80 
89  chroot_config (std::string const& chroot_namespace,
90  std::string const& file);
91 
93  virtual ~chroot_config ();
94 
104  void
105  add (std::string const& chroot_namespace,
106  std::string const& location);
107 
108  private:
117  void
118  add_config_file (std::string const& chroot_namespace,
119  std::string const& file);
120 
129  void
130  add_config_directory (std::string const& chroot_namespace,
131  std::string const& dir);
132 
133  protected:
145  void
146  add (std::string const& chroot_namespace,
148  keyfile const& kconfig);
149 
150  public:
159  get_chroots (std::string const& chroot_namespace) const;
160 
161  protected:
169  chroot_map&
170  find_namespace (std::string const& chroot_namespace);
171 
179  chroot_map const&
180  find_namespace (std::string const& chroot_namespace) const;
181 
182  public:
190  static void
191  get_namespace(std::string const& name,
192  std::string& chroot_namespace,
193  std::string& chroot_name);
194 
202  const chroot::ptr
203  find_chroot (std::string const& name) const;
204 
213  const chroot::ptr
214  find_chroot (std::string const& namespace_hint,
215  std::string const& name) const;
216 
224  const sbuild::chroot::ptr
225  find_chroot_in_namespace (std::string const& chroot_namespace,
226  std::string const& name) const;
227 
236  const chroot::ptr
237  find_alias (std::string const& namespace_hint,
238  std::string const& name) const;
239 
248  std::string
249  lookup_alias (std::string const& namespace_hint,
250  std::string const& name) const;
251 
261  get_chroot_list (std::string const& chroot_namespace) const;
262 
272  get_alias_list (std::string const& chroot_namespace) const;
273 
280  void
281  print_chroot_list_simple (std::ostream& stream) const;
282 
295  chroot_map
296  validate_chroots (std::string const& namespace_hint,
297  string_list const& chroots) const;
298 
299  private:
309  void
310  load_data (std::string const& chroot_namespace,
311  std::string const& file);
312 
313  protected:
322  virtual void
323  parse_data (std::string const& chroot_namespace,
324  std::istream& stream);
325 
334  virtual void
335  load_keyfile (std::string const& chroot_namespace,
336  keyfile& kconfig);
337 
342  };
343 
344 }
345 
346 #endif /* SBUILD_CHROOT_CONFIG_H */
347 
348 /*
349  * Local Variables:
350  * mode:C++
351  * End:
352  */