sbuild  1.6.0
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  {
69  };
70 
73 
75  typedef std::shared_ptr<chroot_config> ptr;
76 
78  chroot_config ();
79 
88  chroot_config (std::string const& chroot_namespace,
89  std::string const& file);
90 
92  virtual ~chroot_config ();
93 
103  void
104  add (std::string const& chroot_namespace,
105  std::string const& location);
106 
107  private:
116  void
117  add_config_file (std::string const& chroot_namespace,
118  std::string const& file);
119 
128  void
129  add_config_directory (std::string const& chroot_namespace,
130  std::string const& dir);
131 
132  protected:
144  void
145  add (std::string const& chroot_namespace,
147  keyfile const& kconfig);
148 
149  public:
158  get_chroots (std::string const& chroot_namespace) const;
159 
160  protected:
168  chroot_map&
169  find_namespace (std::string const& chroot_namespace);
170 
178  chroot_map const&
179  find_namespace (std::string const& chroot_namespace) const;
180 
181  public:
189  const chroot::ptr
190  find_chroot (std::string const& name) const;
191 
200  const chroot::ptr
201  find_chroot (std::string const& namespace_hint,
202  std::string const& name) const;
203 
211  const sbuild::chroot::ptr
212  find_chroot_in_namespace (std::string const& chroot_namespace,
213  std::string const& name) const;
214 
223  const chroot::ptr
224  find_alias (std::string const& namespace_hint,
225  std::string const& name) const;
226 
235  std::string
236  lookup_alias (std::string const& namespace_hint,
237  std::string const& name) const;
238 
248  get_chroot_list (std::string const& chroot_namespace) const;
249 
259  get_alias_list (std::string const& chroot_namespace) const;
260 
269  void
270  print_chroot_list (string_list const& chroots,
271  std::ostream& stream) const;
272 
279  void
280  print_chroot_list_simple (std::ostream& stream) const;
281 
289  void
290  print_chroot_info (string_list const& chroots,
291  std::ostream& stream) const;
292 
300  void
301  print_chroot_location (string_list const& chroots,
302  std::ostream& stream) const;
303 
311  void
312  print_chroot_config (string_list const& chroots,
313  std::ostream& stream) const;
314 
328  validate_chroots (std::string const& namespace_hint,
329  string_list& chroots) const;
330 
331  private:
341  void
342  load_data (std::string const& chroot_namespace,
343  std::string const& file);
344 
345  protected:
354  virtual void
355  parse_data (std::string const& chroot_namespace,
356  std::istream& stream);
357 
366  virtual void
367  load_keyfile (std::string const& chroot_namespace,
368  keyfile& kconfig);
369 
374  };
375 
376 }
377 
378 #endif /* SBUILD_CHROOT_CONFIG_H */
379 
380 /*
381  * Local Variables:
382  * mode:C++
383  * End:
384  */