sbuild  1.7.2
facet.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_FACET_FACET_H
20 #define SBUILD_CHROOT_FACET_FACET_H
21 
22 #include <sbuild/environment.h>
23 #include <sbuild/format-detail.h>
24 #include <sbuild/keyfile.h>
25 #include <sbuild/types.h>
26 #include <sbuild/chroot/chroot.h>
27 
28 #include <string>
29 
30 namespace sbuild
31 {
32  namespace chroot
33  {
34  class chroot;
35 
39  namespace facet
40  {
41 
50  class facet
51  {
52  public:
55  {
57  SESSION_CREATE = 1 << 0,
58  SESSION_CLONE = 1 << 1,
59  SESSION_PURGE = 1 << 2
60  };
61 
63  typedef std::shared_ptr<facet> ptr;
64 
66  typedef std::shared_ptr<const facet> const_ptr;
67 
68  protected:
70  facet ();
71 
83  virtual void
85  bool copy = false);
86 
87  friend class ::sbuild::chroot::chroot;
88 
89  public:
91  virtual ~facet ();
92 
98  virtual ptr
99  clone () const = 0;
100 
106  virtual std::string const&
107  get_name () const = 0;
108 
115  virtual void
116  setup_env (environment& env) const;
117 
125  virtual session_flags
126  get_session_flags () const;
127 
133  virtual void
134  get_details (format_detail& detail) const;
135 
141  virtual void
142  get_used_keys (string_list& used_keys) const;
143 
151  virtual void
152  get_keyfile (keyfile& keyfile) const;
153 
161  virtual void
162  set_keyfile (const keyfile& keyfile);
163 
164  protected:
167  };
168 
177  const facet::session_flags& rhs)
178  {
179  return static_cast<facet::session_flags>
180  (static_cast<int>(lhs) | static_cast<int>(rhs));
181  }
182 
189  facet::session_flags
191  const facet::session_flags& rhs)
192  {
193  return static_cast<facet::session_flags>
194  (static_cast<int>(lhs) & static_cast<int>(rhs));
195  }
196 
197  }
198  }
199 }
200 
201 #endif /* SBUILD_CHROOT_FACET_FACET_H */
202 
203 /*
204  * Local Variables:
205  * mode:C++
206  * End:
207  */
virtual void set_chroot(chroot &chroot, bool copy=false)
Set containing chroot.
Definition: facet.cc:45
The chroot should be purged.
Definition: facet.h:59
virtual session_flags get_session_flags() const
Get the session flags of the chroot.
Definition: facet.cc:65
Debian source builder components.
Definition: ctty.cc:31
facet::session_flags operator|(const facet::session_flags &lhs, const facet::session_flags &rhs)
Bitwise-OR of specifed session properties.
Definition: facet.h:176
The chroot supports session creation.
Definition: facet.h:57
chroot * owner
Chroot owning this facet.
Definition: facet.h:166
Container of environment variables.
Definition: environment.h:38
virtual std::string const & get_name() const =0
Get the name of the chroot facet.
Definition: facet.cc:52
Common chroot data.
Definition: chroot.h:50
No flags are set.
Definition: facet.h:56
virtual void get_used_keys(string_list &used_keys) const
Get a list of the keys used during keyfile parsing.
Definition: facet.cc:76
session_flags
Chroot session properties.
Definition: facet.h:54
Base class for all facets.
Definition: facet.h:50
facet()
The constructor.
Definition: facet.cc:35
virtual ~facet()
The destructor.
Definition: facet.cc:40
std::vector< std::string > string_list
A string vector.
Definition: types.h:38
std::shared_ptr< const facet > const_ptr
A shared_ptr to a const chroot facet object.
Definition: facet.h:66
Format names and values for output.
Definition: format-detail.h:38
virtual void setup_env(environment &env) const
Set environment.
Definition: facet.cc:60
virtual ptr clone() const =0
Copy the chroot facet.
facet::session_flags operator&(const facet::session_flags &lhs, const facet::session_flags &rhs)
Bitwise-AND of specifed session properties.
Definition: facet.h:190
Configuration file parser.
Definition: keyfile.h:46
std::shared_ptr< facet > ptr
A shared_ptr to a chroot facet object.
Definition: facet.h:63
virtual void get_details(format_detail &detail) const
Get detailed information about the chroot for output.
Definition: facet.cc:71
The chroot supports cloning.
Definition: facet.h:58
virtual void set_keyfile(const keyfile &keyfile)
Set the chroot properties from a keyfile.
Definition: facet.cc:86
virtual void get_keyfile(keyfile &keyfile) const
Copy the chroot properties into a keyfile.
Definition: facet.cc:81