sbuild  1.7.1
config.h
1 /* Copyright © 2005-2013 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/chroot/chroot.h>
23 #include <sbuild/custom-error.h>
24 
25 #include <map>
26 #include <ostream>
27 #include <vector>
28 #include <string>
29 
30 namespace sbuild
31 {
32  namespace chroot
33  {
34 
44  class config
45  {
46  public:
48  typedef std::vector<chroot::chroot::ptr> chroot_list;
50  typedef std::map<std::string, std::string> string_map;
52  typedef std::map<std::string, chroot::chroot::ptr> chroot_map;
54  typedef std::map<std::string, chroot_map> chroot_namespace_map;
55 
57  static const std::string namespace_separator;
58 
61  {
72  };
73 
76 
78  typedef std::shared_ptr<config> ptr;
79 
81  config ();
82 
91  config (const std::string& chroot_namespace,
92  const std::string& file);
93 
95  virtual ~config ();
96 
106  void
107  add (const std::string& chroot_namespace,
108  const std::string& location);
109 
110  private:
119  void
120  add_config_file (const std::string& chroot_namespace,
121  const std::string& file);
122 
131  void
132  add_config_directory (const std::string& chroot_namespace,
133  const std::string& dir);
134 
135  protected:
147  void
148  add (const std::string& chroot_namespace,
150  const keyfile& kconfig);
151 
152  public:
161  get_chroots (const std::string& chroot_namespace) const;
162 
163  protected:
171  chroot_map&
172  find_namespace (const std::string& chroot_namespace);
173 
181  chroot_map const&
182  find_namespace (const std::string& chroot_namespace) const;
183 
184  public:
192  static void
193  get_namespace(const std::string& name,
194  std::string& chroot_namespace,
195  std::string& chroot_name);
196 
204  const chroot::chroot::ptr
205  find_chroot (const std::string& name) const;
206 
215  const chroot::chroot::ptr
216  find_chroot (const std::string& namespace_hint,
217  const std::string& name) const;
218 
226  const chroot::chroot::ptr
227  find_chroot_in_namespace (const std::string& chroot_namespace,
228  const std::string& name) const;
229 
238  const chroot::chroot::ptr
239  find_alias (const std::string& namespace_hint,
240  const std::string& name) const;
241 
250  std::string
251  lookup_alias (const std::string& namespace_hint,
252  const std::string& name) const;
253 
263  get_chroot_list (const std::string& chroot_namespace) const;
264 
274  get_alias_list (const std::string& chroot_namespace) const;
275 
282  void
283  print_chroot_list_simple (std::ostream& stream) const;
284 
297  chroot_map
298  validate_chroots (const std::string& namespace_hint,
299  const string_list& chroots) const;
300 
301  private:
311  void
312  load_data (const std::string& chroot_namespace,
313  const std::string& file);
314 
315  protected:
324  virtual void
325  parse_data (const std::string& chroot_namespace,
326  std::istream& stream);
327 
336  virtual void
337  load_keyfile (const std::string& chroot_namespace,
338  keyfile& kconfig);
339 
344  };
345 
346  }
347 }
348 
349 #endif /* SBUILD_CHROOT_CONFIG_H */
350 
351 /*
352  * Local Variables:
353  * mode:C++
354  * End:
355  */