1 | /* Copyright © 2005-2009 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_FACET_H |
---|
20 | #define SBUILD_CHROOT_FACET_H |
---|
21 | |
---|
22 | #include <sbuild/sbuild-environment.h> |
---|
23 | #include <sbuild/sbuild-format-detail.h> |
---|
24 | #include <sbuild/sbuild-keyfile.h> |
---|
25 | #include <sbuild/sbuild-types.h> |
---|
26 | #include <sbuild/sbuild-chroot.h> |
---|
27 | |
---|
28 | #include <string> |
---|
29 | |
---|
30 | namespace sbuild |
---|
31 | { |
---|
32 | |
---|
33 | /** |
---|
34 | * Common chroot data. This class contains all of the metadata |
---|
35 | * associated with a single chroot, for all chroot types. This is |
---|
36 | * the in-core representation of a chroot definition in the |
---|
37 | * configuration file, and may be initialised directly from an open |
---|
38 | * keyfile. |
---|
39 | */ |
---|
40 | class chroot_facet |
---|
41 | { |
---|
42 | public: |
---|
43 | /// A shared_ptr to a chroot facet object. |
---|
44 | typedef std::tr1::shared_ptr<chroot_facet> ptr; |
---|
45 | |
---|
46 | /// A shared_ptr to a const chroot facet object. |
---|
47 | typedef std::tr1::shared_ptr<const chroot_facet> const_ptr; |
---|
48 | |
---|
49 | protected: |
---|
50 | /// The constructor. |
---|
51 | chroot_facet(): owner(0) {}; |
---|
52 | |
---|
53 | void |
---|
54 | set_chroot(chroot& chroot) |
---|
55 | { |
---|
56 | this->owner = &chroot; |
---|
57 | } |
---|
58 | |
---|
59 | friend class chroot; |
---|
60 | |
---|
61 | public: |
---|
62 | /// The destructor. |
---|
63 | virtual ~chroot_facet () {}; |
---|
64 | |
---|
65 | /** |
---|
66 | * Copy the chroot facet. This is a virtual copy constructor. |
---|
67 | * |
---|
68 | * @returns a shared_ptr to the new copy of the chroot facet. |
---|
69 | */ |
---|
70 | virtual ptr |
---|
71 | clone () const = 0; |
---|
72 | |
---|
73 | /** |
---|
74 | * Get the name of the chroot facet. |
---|
75 | * |
---|
76 | * @returns the chroot facet name. |
---|
77 | */ |
---|
78 | virtual std::string const& |
---|
79 | get_name () const = 0; |
---|
80 | |
---|
81 | /** |
---|
82 | * Set environment. Set the environment that the setup scripts |
---|
83 | * will see during execution. |
---|
84 | * |
---|
85 | * @param chroot the chroot to use. |
---|
86 | * @param env the environment to set. |
---|
87 | */ |
---|
88 | virtual void |
---|
89 | setup_env (chroot const& chroot, |
---|
90 | environment& env) const = 0; |
---|
91 | |
---|
92 | /** |
---|
93 | * Get the session flags of the chroot. These determine how the |
---|
94 | * Session controlling the chroot will operate. |
---|
95 | * |
---|
96 | * @param chroot the chroot to use. |
---|
97 | * @returns the session flags. |
---|
98 | */ |
---|
99 | virtual chroot::session_flags |
---|
100 | get_session_flags (chroot const& chroot) const = 0; |
---|
101 | |
---|
102 | /** |
---|
103 | * Get detailed information about the chroot for output. |
---|
104 | * |
---|
105 | * @param chroot the chroot to use. |
---|
106 | * @param detail the details to output to. |
---|
107 | */ |
---|
108 | virtual void |
---|
109 | get_details (chroot const& chroot, |
---|
110 | format_detail& detail) const = 0; |
---|
111 | |
---|
112 | /** |
---|
113 | * Copy the chroot properties into a keyfile. The keyfile group |
---|
114 | * with the name of the chroot will be set; if it already exists, |
---|
115 | * it will be removed before setting it. |
---|
116 | * |
---|
117 | * @param chroot the chroot to use. |
---|
118 | * @param keyfile the keyfile to use. |
---|
119 | */ |
---|
120 | virtual void |
---|
121 | get_keyfile (chroot const& chroot, |
---|
122 | keyfile& keyfile) const = 0; |
---|
123 | |
---|
124 | /** |
---|
125 | * Set the chroot properties from a keyfile. The chroot name must |
---|
126 | * have previously been set, so that the correct keyfile group may |
---|
127 | * be determined. |
---|
128 | * |
---|
129 | * @param chroot the chroot to use. |
---|
130 | * @param keyfile the keyfile to get the properties from. |
---|
131 | * @param used_keys a list of the keys used will be set. |
---|
132 | */ |
---|
133 | virtual void |
---|
134 | set_keyfile (chroot& chroot, |
---|
135 | keyfile const& keyfile, |
---|
136 | string_list& used_keys) = 0; |
---|
137 | |
---|
138 | protected: |
---|
139 | /// Chroot owning this facet. |
---|
140 | chroot *owner; |
---|
141 | }; |
---|
142 | |
---|
143 | } |
---|
144 | |
---|
145 | #endif /* SBUILD_CHROOT_FACET_H */ |
---|
146 | |
---|
147 | /* |
---|
148 | * Local Variables: |
---|
149 | * mode:C++ |
---|
150 | * End: |
---|
151 | */ |
---|