sbuild  1.7.1
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  */