Go to the documentation of this file.
9 #ifndef EAGINE_HANDLE_HPP
10 #define EAGINE_HANDLE_HPP
25 template <
typename Tag,
typename Handle, Handle inval
id = ~Handle(0)>
42 : _name{tmp._release()} {}
46 _name = tmp._release();
61 constexpr
auto is_valid() const noexcept ->
bool {
62 return _name != invalid;
67 explicit constexpr
operator bool() const noexcept {
72 explicit constexpr
operator Handle() const noexcept {
77 constexpr
auto operator()(Handle hndl)
const noexcept {
83 auto _release() noexcept {
84 return std::exchange(_name, invalid);
88 Handle _name{invalid};
97 template <
typename Tag,
typename Handle, Handle inval
id = ~Handle(0)>
110 :
base{tmp.release()} {}
114 *
static_cast<base*
>(
this) =
static_cast<base&&
>(tmp);
135 return this->_release();
139 template <
typename BasicHandle,
typename Container>
140 class basic_handle_container;
144 template <
typename Tag,
typename Handle, Handle inval
id,
typename Container>
145 class basic_handle_container<
basic_handle<Tag, Handle, invalid>, Container>
148 basic_handle<Tag, Handle, invalid>,
162 return this->raw_items();
167 return this->raw_items();
176 template <
typename BasicHandle>
178 basic_handle_container<BasicHandle, span<typename BasicHandle::handle_type>>;
185 template <
typename BasicHandle>
188 span<const typename BasicHandle::handle_type>>;
195 template <
typename BasicHandle, std::
size_t N>
198 std::array<typename BasicHandle::handle_type, N>>;
205 template <
typename BasicHandle>
208 std::vector<typename BasicHandle::handle_type>>;
212 #endif // EAGINE_HANDLE_HPP
constexpr basic_owned_handle() noexcept=default
Default constructor.
auto release() noexcept -> Handle
Releases the underlying handle value.
Definition: handle.hpp:134
Common code is placed in this namespace.
Definition: eagine.hpp:21
constexpr basic_owned_handle(base adopted) noexcept
Constructor adopting a non-owning handle wrapper.
Definition: handle.hpp:125
auto operator=(basic_handle &&tmp) noexcept -> auto &
Move assignment operator.
Definition: handle.hpp:45
constexpr auto raw_handles() noexcept
Returns the raw handles.
Definition: handle.hpp:161
constexpr basic_owned_handle(basic_owned_handle &&tmp) noexcept
Move constructor.
Definition: handle.hpp:109
basic_handle_container< BasicHandle, std::vector< typename BasicHandle::handle_type > > basic_handle_vector
Alias for basic handle container based on std::vector.
Definition: handle.hpp:208
buffer_tag tag_type
Alias for the tag type.
Definition: handle.hpp:29
Handle handle_type
Alias for the underlying handle type.
Definition: handle.hpp:32
constexpr basic_handle(Handle name) noexcept
Construction from the underlying handle type.
Definition: handle.hpp:57
Non-owning wrapper for C-API opaque handle types.
Definition: handle.hpp:26
constexpr basic_handle() noexcept=default
Default constructor.
auto operator=(basic_owned_handle &&tmp) noexcept -> auto &
Move assignment operator.
Definition: handle.hpp:113
basic_handle_container< BasicHandle, std::array< typename BasicHandle::handle_type, N > > basic_handle_array
Alias for basic handle container based on std::array.
Definition: handle.hpp:198
basic_handle_container< BasicHandle, span< const typename BasicHandle::handle_type > > basic_handle_view
Alias for basic handle container based on const span.
Definition: handle.hpp:188
static auto transform(basic_span< T, P, S > spn, Transform function) -> basic_span< T, P, S >
Transforms the elements of a span with a function.
Definition: span_algo.hpp:572
constexpr auto is_valid() const noexcept -> bool
Indicates if this instance contains a valid handle.
Definition: handle.hpp:61
Owning wrapper for C-API opaque handle types.
Definition: handle.hpp:98
Template used in implementation of containers with wrapped elements.
Definition: wrapping_container.hpp:26
constexpr basic_owned_handle(Handle name) noexcept
Constructor adopting an underlying handle value.
Definition: handle.hpp:129
basic_handle_container< BasicHandle, span< typename BasicHandle::handle_type > > basic_handle_span
Alias for basic handle container based on non-const span.
Definition: handle.hpp:178
constexpr auto raw_handles() const noexcept
Returns the raw handles.
Definition: handle.hpp:166