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

Type-safe writer for regular messages with a configurable queue allocator. More...

#include <writer.hpp>

Public Member Functions

constexpr BasicMessageWriter (MessageQueue< Allocator > &queue) noexcept
 Constructs a BasicMessageWriter that writes to a message queue.
 BasicMessageWriter (const BasicMessageWriter &)=delete
constexpr BasicMessageWriter (BasicMessageWriter &&) noexcept=default
constexpr ~BasicMessageWriter () noexcept=default
BasicMessageWriteroperator= (const BasicMessageWriter &)=delete
constexpr BasicMessageWriteroperator= (BasicMessageWriter &&) noexcept=default
template<typename U = T>
requires std::same_as<std::remove_cvref_t<U>, T>
void Write (U &&message) const
 Writes a single message to the local queue.
template<std::ranges::input_range R>
requires std::same_as<std::ranges::range_value_t<R>, T>
void WriteBulk (R &&messages) const
 Writes multiple messages to the local queue in bulk.
template<typename... Args>
requires std::constructible_from<T, Args...>
void Emplace (Args &&... args) const
 Constructs an message in-place and writes it to the local queue.

Detailed Description

template<MessageTrait T, typename Allocator = std::allocator<std::byte>>
class helios::ecs::BasicMessageWriter< T, Allocator >

Type-safe writer for regular messages with a configurable queue allocator.

Messages written through BasicMessageWriter are buffered in a message queue and merged into the global MessageManager at sync time when used from system local data.

Note
Not thread-safe.
Template Parameters
TMessage type satisfying MessageTrait
AllocatorAllocator type for the underlying message queue (default: std::allocator<std::byte>)

Definition at line 26 of file writer.hpp.

Constructor & Destructor Documentation

◆ BasicMessageWriter() [1/3]

template<MessageTrait T, typename Allocator = std::allocator<std::byte>>
helios::ecs::BasicMessageWriter< T, Allocator >::BasicMessageWriter ( MessageQueue< Allocator > & queue)
inlineexplicitconstexprnoexcept

Constructs a BasicMessageWriter that writes to a message queue.

Parameters
queueReference to the message queue

Definition at line 32 of file writer.hpp.

◆ BasicMessageWriter() [2/3]

template<MessageTrait T, typename Allocator = std::allocator<std::byte>>
helios::ecs::BasicMessageWriter< T, Allocator >::BasicMessageWriter ( const BasicMessageWriter< T, Allocator > & )
delete

◆ BasicMessageWriter() [3/3]

template<MessageTrait T, typename Allocator = std::allocator<std::byte>>
helios::ecs::BasicMessageWriter< T, Allocator >::BasicMessageWriter ( BasicMessageWriter< T, Allocator > && )
constexprdefaultnoexcept

◆ ~BasicMessageWriter()

template<MessageTrait T, typename Allocator = std::allocator<std::byte>>
helios::ecs::BasicMessageWriter< T, Allocator >::~BasicMessageWriter ( )
constexprdefaultnoexcept

Member Function Documentation

◆ Emplace()

template<MessageTrait T, typename Allocator = std::allocator<std::byte>>
template<typename... Args>
requires std::constructible_from<T, Args...>
void helios::ecs::BasicMessageWriter< T, Allocator >::Emplace ( Args &&... args) const
inline

Constructs an message in-place and writes it to the local queue.

Template Parameters
ArgsConstructor argument types
Parameters
argsArguments to forward to the message constructor

Definition at line 71 of file writer.hpp.

◆ operator=() [1/2]

template<MessageTrait T, typename Allocator = std::allocator<std::byte>>
BasicMessageWriter & helios::ecs::BasicMessageWriter< T, Allocator >::operator= ( BasicMessageWriter< T, Allocator > && )
constexprdefaultnoexcept

◆ operator=() [2/2]

template<MessageTrait T, typename Allocator = std::allocator<std::byte>>
BasicMessageWriter & helios::ecs::BasicMessageWriter< T, Allocator >::operator= ( const BasicMessageWriter< T, Allocator > & )
delete

◆ Write()

template<MessageTrait T, typename Allocator = std::allocator<std::byte>>
template<typename U = T>
requires std::same_as<std::remove_cvref_t<U>, T>
void helios::ecs::BasicMessageWriter< T, Allocator >::Write ( U && message) const
inline

Writes a single message to the local queue.

Template Parameters
UMessage type, must be the same as T
Parameters
messageMessage to write

Definition at line 49 of file writer.hpp.

◆ WriteBulk()

template<MessageTrait T, typename Allocator = std::allocator<std::byte>>
template<std::ranges::input_range R>
requires std::same_as<std::ranges::range_value_t<R>, T>
void helios::ecs::BasicMessageWriter< T, Allocator >::WriteBulk ( R && messages) const
inline

Writes multiple messages to the local queue in bulk.

Template Parameters
RRange of messages
Parameters
messagesRange of messages to write

Definition at line 60 of file writer.hpp.