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

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

#include <wrapper.hpp>

Public Member Functions

constexpr MessageWrapper (const T &message, size_t global_index) noexcept
 Constructs a MessageWrapper.
constexpr MessageWrapper (const MessageWrapper &) noexcept=default
constexpr MessageWrapper (MessageWrapper &&) noexcept=default
constexpr ~MessageWrapper () noexcept=default
constexpr MessageWrapperoperator= (const MessageWrapper &) noexcept=default
constexpr MessageWrapperoperator= (MessageWrapper &&) noexcept=default
constexpr const T & operator* () const noexcept
 Dereferences to the underlying message.
constexpr const T * operator-> () const noexcept
 Provides member access to the underlying message.
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 size_t GlobalIndex () const noexcept
 Gets the global index of this message in the combined (previous + current) view.
constexpr const T & Unwrap () const noexcept
 Unwraps the message wrapper, returning a const reference to the underlying message.

Detailed Description

template<MessageTrait T>
class helios::ecs::MessageWrapper< T >

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

It holds a const reference to the underlying message and the global index of the message within the combined (previous + current) view.

Unlike ConsumableMessageWrapper, this wrapper does not provide message consumption functionality.

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

Definition at line 143 of file wrapper.hpp.

Constructor & Destructor Documentation

◆ MessageWrapper() [1/3]

template<MessageTrait T>
helios::ecs::MessageWrapper< T >::MessageWrapper ( const T & message,
size_t global_index )
inlineconstexprnoexcept

Constructs a MessageWrapper.

Intended to be called by MessageReader; not part of the public construction API.

Parameters
messageConst reference to the message
global_indexGlobal index of the message in the combined (previous + current) view

Definition at line 153 of file wrapper.hpp.

◆ MessageWrapper() [2/3]

template<MessageTrait T>
helios::ecs::MessageWrapper< T >::MessageWrapper ( const MessageWrapper< T > & )
constexprdefaultnoexcept

◆ MessageWrapper() [3/3]

template<MessageTrait T>
helios::ecs::MessageWrapper< T >::MessageWrapper ( MessageWrapper< T > && )
constexprdefaultnoexcept

◆ ~MessageWrapper()

template<MessageTrait T>
helios::ecs::MessageWrapper< T >::~MessageWrapper ( )
constexprdefaultnoexcept

Member Function Documentation

◆ GlobalIndex()

template<MessageTrait T>
size_t helios::ecs::MessageWrapper< T >::GlobalIndex ( ) const
inlinenodiscardconstexprnoexcept

Gets the global index of this message in the combined (previous + current) view.

Returns
Global index

Definition at line 198 of file wrapper.hpp.

◆ Name()

template<MessageTrait T>
std::string_view helios::ecs::MessageWrapper< 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 181 of file wrapper.hpp.

◆ operator*()

template<MessageTrait T>
const T & helios::ecs::MessageWrapper< T >::operator* ( ) const
inlinenodiscardconstexprnoexcept

Dereferences to the underlying message.

Returns
A const reference to the underlying message data

Definition at line 167 of file wrapper.hpp.

◆ operator->()

template<MessageTrait T>
const T * helios::ecs::MessageWrapper< T >::operator-> ( ) const
inlineconstexprnoexcept

Provides member access to the underlying message.

Returns
A pointer to the underlying message data

Definition at line 175 of file wrapper.hpp.

◆ operator=() [1/2]

template<MessageTrait T>
MessageWrapper & helios::ecs::MessageWrapper< T >::operator= ( const MessageWrapper< T > & )
constexprdefaultnoexcept

◆ operator=() [2/2]

template<MessageTrait T>
MessageWrapper & helios::ecs::MessageWrapper< T >::operator= ( MessageWrapper< T > && )
constexprdefaultnoexcept

◆ TypeIndex()

template<MessageTrait T>
MessageTypeIndex helios::ecs::MessageWrapper< T >::TypeIndex ( ) const
inlinenodiscardconstexprnoexcept

Gets the type index of the message.

Returns
A MessageTypeIndex representing the type index of the message

Definition at line 189 of file wrapper.hpp.

◆ Unwrap()

template<MessageTrait T>
const T & helios::ecs::MessageWrapper< T >::Unwrap ( ) const
inlinenodiscardconstexprnoexcept

Unwraps the message wrapper, returning a const reference to the underlying message.

Returns
A const reference to the underlying message data

Definition at line 207 of file wrapper.hpp.