27 namespace L4 {
namespace Detail {
29 template<
typename T,
typename IMPL >
30 class Smart_cap_base :
public Cap_base,
protected IMPL
34 static IMPL &impl(Smart_cap_base<X, IMPL> &o) {
return o; }
37 static IMPL
const &impl(Smart_cap_base<X, IMPL>
const &o) {
return o; }
40 template<
typename X,
typename I>
41 friend class ::L4::Detail::Smart_cap_base;
43 Smart_cap_base(Smart_cap_base
const &) =
delete;
44 Smart_cap_base &operator = (Smart_cap_base
const &) =
delete;
46 Smart_cap_base() noexcept : Cap_base(Invalid) {}
53 explicit constexpr Smart_cap_base(Cap<O> c) noexcept
58 explicit constexpr Smart_cap_base(Cap<O> c, IMPL
const &impl) noexcept
62 Cap<T> release() noexcept
65 IMPL::invalidate(*
this);
70 { IMPL::free(*
this); }
72 Cap<T> operator -> () const noexcept {
return Cap<T>(this->
cap()); }
73 Cap<T>
get()
const noexcept {
return Cap<T>(this->
cap()); }
74 ~Smart_cap_base() noexcept { IMPL::free(*
this); }
78 template<
typename T,
typename IMPL >
79 class Unique_cap_impl final :
public Smart_cap_base<T, IMPL>
82 typedef Smart_cap_base<T, IMPL> Base;
86 Unique_cap_impl() noexcept = default;
88 Unique_cap_impl(Unique_cap_impl &&o) noexcept
89 : Base(o.release(), Base::impl(o))
93 Unique_cap_impl(Unique_cap_impl<O, IMPL> &&o) noexcept
94 : Base(o.release(), Base::impl(o))
95 { T* __t = ((O*)100); (void)__t; }
97 Unique_cap_impl &operator = (Unique_cap_impl &&o) noexcept
103 this->_c = o.release().cap();
104 this->IMPL::operator = (Base::impl(o));
109 Unique_cap_impl &operator = (Unique_cap_impl<O, IMPL> &&o) noexcept
111 T* __t = ((O*)100); (void)__t;
114 this->_c = o.release().cap();
115 this->IMPL::operator = (Base::impl(o));
120 template<
typename T,
typename IMPL>
121 class Shared_cap_impl final :
public Smart_cap_base<T, IMPL>
124 typedef Smart_cap_base<T, IMPL> Base;
128 Shared_cap_impl() noexcept = default;
130 Shared_cap_impl(Shared_cap_impl &&o) noexcept
135 Shared_cap_impl(Shared_cap_impl<O, IMPL> &&o) noexcept
137 { T* __t = ((O*)100); (void)__t; }
139 Shared_cap_impl &operator = (Shared_cap_impl &&o) noexcept
145 this->_c = o.release().cap();
146 this->IMPL::operator = (Base::impl(o));
151 Shared_cap_impl &operator = (Shared_cap_impl<O, IMPL> &&o) noexcept
153 T* __t = ((O*)100); (void)__t;
156 this->_c = o.release().cap();
157 this->IMPL::operator = (Base::impl(o));
161 Shared_cap_impl(Shared_cap_impl
const &o) noexcept
166 Shared_cap_impl(Shared_cap_impl<O, IMPL>
const &o) noexcept
167 : Base(IMPL::copy(o))
168 { T* __t = ((O*)100); (void)__t; }
170 Shared_cap_impl &operator = (Shared_cap_impl
const &o) noexcept
176 this->IMPL::operator = (static_cast<IMPL const &>(o));
177 this->_c = this->IMPL::copy(o).cap();
182 Shared_cap_impl &operator = (Shared_cap_impl<O, IMPL>
const &o) noexcept
184 T* __t = ((O*)100); (void)__t;
186 this->IMPL::operator = (static_cast<IMPL const &>(o));
187 this->_c = this->IMPL::copy(o).cap();
L4 low-level kernel interface.
unsigned long l4_cap_idx_t
L4 Capability selector Type.
L4::Cap related definitions.
l4_cap_idx_t cap() const
Return capability selector.
Cap_type
Invalid capability type.
Cap_base(l4_cap_idx_t c)
Generate a capability from its C representation.
C++ interface for capabilities.