27namespace L4 {
namespace Detail {
29template<
typename T,
typename IMPL >
30class 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;
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); }
78template<
typename T,
typename IMPL >
79class 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 { Cap<T>::template check_convertible_from<O>(); }
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 Cap<T>::template check_convertible_from<O>();
114 this->
_c = o.release().cap();
115 this->IMPL::operator = (Base::impl(o));
120template<
typename T,
typename IMPL>
121class 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 { Cap<T>::template check_convertible_from<O>(); }
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 Cap<T>::template check_convertible_from<O>();
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 { Cap<T>::template check_convertible_from<O>(); }
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 Cap<T>::template check_convertible_from<O>();
186 this->IMPL::operator = (
static_cast<IMPL
const &
>(o));
187 this->
_c = this->IMPL::copy(o).cap();
L4::Cap related definitions.
l4_cap_idx_t _c
The C representation of a capability selector.
l4_cap_idx_t cap() const noexcept
Return capability selector.
Cap_type
Invalid capability type.
@ Invalid
Invalid capability selector.
Cap_base() noexcept
Create an uninitialized instance.
C++ interface for capabilities.
unsigned long l4_cap_idx_t
Capability selector type.
L4 low-level kernel interface.