16namespace L4 {
namespace Detail {
18template<
typename T,
typename IMPL >
19class Smart_cap_base :
public Cap_base,
protected IMPL
23 static IMPL &impl(Smart_cap_base<X, IMPL> &o) {
return o; }
26 static IMPL
const &impl(Smart_cap_base<X, IMPL>
const &o) {
return o; }
29 template<
typename X,
typename I>
30 friend class ::L4::Detail::Smart_cap_base;
32 Smart_cap_base(Smart_cap_base
const &) =
delete;
33 Smart_cap_base &operator = (Smart_cap_base
const &) =
delete;
42 explicit constexpr Smart_cap_base(Cap<O> c) noexcept
47 explicit constexpr Smart_cap_base(Cap<O> c, IMPL
const &impl) noexcept
51 Cap<T> release() noexcept
54 IMPL::invalidate(*
this);
59 { IMPL::free(*
this); }
61 Cap<T> operator -> () const noexcept {
return Cap<T>(this->
cap()); }
62 Cap<T> get() const noexcept {
return Cap<T>(this->
cap()); }
63 ~Smart_cap_base() noexcept { IMPL::free(*
this); }
67template<
typename T,
typename IMPL >
68class Unique_cap_impl final :
public Smart_cap_base<T, IMPL>
71 typedef Smart_cap_base<T, IMPL> Base;
75 Unique_cap_impl() noexcept = default;
77 Unique_cap_impl(Unique_cap_impl &&o) noexcept
78 : Base(o.release(), Base::impl(o))
82 Unique_cap_impl(Unique_cap_impl<O, IMPL> &&o) noexcept
83 : Base(o.release(), Base::impl(o))
84 { Cap<T>::template check_convertible_from<O>(); }
86 Unique_cap_impl &operator = (Unique_cap_impl &&o)
noexcept
92 this->
_c = o.release().cap();
93 this->IMPL::operator = (Base::impl(o));
98 Unique_cap_impl &operator = (Unique_cap_impl<O, IMPL> &&o)
noexcept
100 Cap<T>::template check_convertible_from<O>();
103 this->
_c = o.release().cap();
104 this->IMPL::operator = (Base::impl(o));
109template<
typename T,
typename IMPL>
110class Shared_cap_impl final :
public Smart_cap_base<T, IMPL>
113 typedef Smart_cap_base<T, IMPL> Base;
117 Shared_cap_impl() noexcept = default;
119 Shared_cap_impl(Shared_cap_impl &&o) noexcept
120 : Base(o.release(), Base::impl(o))
124 Shared_cap_impl(Shared_cap_impl<O, IMPL> &&o) noexcept
125 : Base(o.release(), Base::impl(o))
126 { Cap<T>::template check_convertible_from<O>(); }
128 Shared_cap_impl &operator = (Shared_cap_impl &&o)
noexcept
134 this->
_c = o.release().cap();
135 this->IMPL::operator = (Base::impl(o));
140 Shared_cap_impl &operator = (Shared_cap_impl<O, IMPL> &&o)
noexcept
142 Cap<T>::template check_convertible_from<O>();
145 this->
_c = o.release().cap();
146 this->IMPL::operator = (Base::impl(o));
150 Shared_cap_impl(Shared_cap_impl
const &o) noexcept
153 this->IMPL::operator = (Base::impl(o));
154 this->
_c = IMPL::copy(o).cap();
158 Shared_cap_impl(Shared_cap_impl<O, IMPL>
const &o) noexcept
161 Cap<T>::template check_convertible_from<O>();
162 this->IMPL::operator = (Base::impl(o));
163 this->
_c = IMPL::copy(o).cap();
166 Shared_cap_impl &operator = (Shared_cap_impl
const &o)
noexcept
172 this->IMPL::operator = (
static_cast<IMPL
const &
>(o));
173 this->
_c = this->IMPL::copy(o).cap();
178 Shared_cap_impl &operator = (Shared_cap_impl<O, IMPL>
const &o)
noexcept
180 Cap<T>::template check_convertible_from<O>();
182 this->IMPL::operator = (
static_cast<IMPL
const &
>(o));
183 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.
unsigned long l4_cap_idx_t
Capability selector type.
L4 low-level kernel interface.