Helios Engine
A modular ECS based data-oriented C++23 game engine framework
Loading...
Searching...
No Matches
helios::ecs::AsyncMessageWrapper< T > Class Template Reference

A wrapper around an async message that provides convenient access to the message's data and type information. More...

#include <async_wrapper.hpp>

Public Member Functions

constexpr AsyncMessageWrapper (T &&message) noexcept(std::is_nothrow_move_constructible_v< T >)
 Constructs an AsyncMessageWrapper by moving in an message.
constexpr AsyncMessageWrapper (const AsyncMessageWrapper &) noexcept(std::is_nothrow_copy_constructible_v< T >)=default
constexpr AsyncMessageWrapper (AsyncMessageWrapper &&) noexcept(std::is_nothrow_move_constructible_v< T >)=default
constexpr ~AsyncMessageWrapper () noexcept(std::is_nothrow_destructible_v< T >)=default
constexpr AsyncMessageWrapperoperator= (const AsyncMessageWrapper &) noexcept(std::is_nothrow_copy_assignable_v< T >)=default
constexpr AsyncMessageWrapperoperator= (AsyncMessageWrapper &&) noexcept(std::is_nothrow_move_assignable_v< T >)=default
constexpr T * operator-> () noexcept
 Provides member access to the underlying message (mutable).
constexpr const T * operator-> () const noexcept
 Provides member access to the underlying message (const).
constexpr T & operator* () noexcept
 Dereferences to the underlying message (mutable).
constexpr const T & operator* () const noexcept
 Dereferences to the underlying message (const).
constexpr std::string_view Name () const noexcept
 Gets the name of the message type.
constexpr MessageTypeIndex TypeIndex () const noexcept
 Gets the type index of the message.
constexpr T & Unwrap () noexcept
 Unwraps the message wrapper, returning a mutable reference.
constexpr const T & Unwrap () const noexcept
 Unwraps the message wrapper, returning a const reference.
constexpr T Take () noexcept(std::is_nothrow_move_constructible_v< T >)
 Moves the message out of the wrapper.

Detailed Description

template<AsyncMessageTrait T>
class helios::ecs::AsyncMessageWrapper< T >

A wrapper around an async message that provides convenient access to the message's data and type information.

Unlike MessageWrapper for regular messages, AsyncMessageWrapper owns the message.

Note
Thread-safe.
Template Parameters
TThe type of the message being wrapped. Must satisfy AsyncMessageTrait

Definition at line 21 of file async_wrapper.hpp.

Constructor & Destructor Documentation

◆ AsyncMessageWrapper() [1/3]

template<AsyncMessageTrait T>
helios::ecs::AsyncMessageWrapper< T >::AsyncMessageWrapper ( T && message)
inlineexplicitconstexprnoexcept

Constructs an AsyncMessageWrapper by moving in an message.

Parameters
messageMessage to wrap (moved)

Definition at line 27 of file async_wrapper.hpp.

◆ AsyncMessageWrapper() [2/3]

template<AsyncMessageTrait T>
helios::ecs::AsyncMessageWrapper< T >::AsyncMessageWrapper ( const AsyncMessageWrapper< T > & ) const
constexprdefaultnoexcept

◆ AsyncMessageWrapper() [3/3]

template<AsyncMessageTrait T>
helios::ecs::AsyncMessageWrapper< T >::AsyncMessageWrapper ( AsyncMessageWrapper< T > && ) const
constexprdefaultnoexcept

◆ ~AsyncMessageWrapper()

template<AsyncMessageTrait T>
helios::ecs::AsyncMessageWrapper< T >::~AsyncMessageWrapper ( )
constexprdefaultnoexcept

Member Function Documentation

◆ Name()

template<AsyncMessageTrait T>
std::string_view helios::ecs::AsyncMessageWrapper< T >::Name ( ) const
inlinenodiscardconstexprnoexcept

Gets the name of the message type.

Returns
A string view containing the name of the message type

Definition at line 72 of file async_wrapper.hpp.

◆ operator*() [1/2]

template<AsyncMessageTrait T>
const T & helios::ecs::AsyncMessageWrapper< T >::operator* ( ) const
inlinenodiscardconstexprnoexcept

Dereferences to the underlying message (const).

Returns
A const reference to the underlying message data

Definition at line 64 of file async_wrapper.hpp.

◆ operator*() [2/2]

template<AsyncMessageTrait T>
T & helios::ecs::AsyncMessageWrapper< T >::operator* ( )
inlinenodiscardconstexprnoexcept

Dereferences to the underlying message (mutable).

Returns
A reference to the underlying message data

Definition at line 58 of file async_wrapper.hpp.

◆ operator->() [1/2]

template<AsyncMessageTrait T>
const T * helios::ecs::AsyncMessageWrapper< T >::operator-> ( ) const
inlineconstexprnoexcept

Provides member access to the underlying message (const).

Returns
A const pointer to the underlying message data

Definition at line 52 of file async_wrapper.hpp.

◆ operator->() [2/2]

template<AsyncMessageTrait T>
T * helios::ecs::AsyncMessageWrapper< T >::operator-> ( )
inlineconstexprnoexcept

Provides member access to the underlying message (mutable).

Returns
A pointer to the underlying message data

Definition at line 46 of file async_wrapper.hpp.

◆ operator=() [1/2]

template<AsyncMessageTrait T>
AsyncMessageWrapper & helios::ecs::AsyncMessageWrapper< T >::operator= ( AsyncMessageWrapper< T > && )
constexprdefaultnoexcept

◆ operator=() [2/2]

template<AsyncMessageTrait T>
AsyncMessageWrapper & helios::ecs::AsyncMessageWrapper< T >::operator= ( const AsyncMessageWrapper< T > & )
constexprdefaultnoexcept

◆ Take()

template<AsyncMessageTrait T>
T helios::ecs::AsyncMessageWrapper< T >::Take ( )
inlinenodiscardconstexprnoexcept

Moves the message out of the wrapper.

After calling this, the wrapper's message is in a moved-from state.

Returns
The message, moved out of the wrapper

Definition at line 102 of file async_wrapper.hpp.

◆ TypeIndex()

template<AsyncMessageTrait T>
MessageTypeIndex helios::ecs::AsyncMessageWrapper< T >::TypeIndex ( ) const
inlinenodiscardconstexprnoexcept

Gets the type index of the message.

Returns
An MessageTypeIndex representing the type index of the message

Definition at line 80 of file async_wrapper.hpp.

◆ Unwrap() [1/2]

template<AsyncMessageTrait T>
const T & helios::ecs::AsyncMessageWrapper< T >::Unwrap ( ) const
inlinenodiscardconstexprnoexcept

Unwraps the message wrapper, returning a const reference.

Returns
A const reference to the underlying message data

Definition at line 94 of file async_wrapper.hpp.

◆ Unwrap() [2/2]

template<AsyncMessageTrait T>
T & helios::ecs::AsyncMessageWrapper< T >::Unwrap ( )
inlinenodiscardconstexprnoexcept

Unwraps the message wrapper, returning a mutable reference.

Returns
A mutable reference to the underlying message data

Definition at line 88 of file async_wrapper.hpp.