Helios Engine 0.1.0
A modular ECS based data-oriented C++23 game engine
 
Loading...
Searching...
No Matches
helios::ecs::details::CmdBuffer Class Reference

Command buffer to record operations to be executed later. More...

#include <command_buffer.hpp>

Public Member Functions

 CmdBuffer (SystemLocalStorage &local_storage) noexcept
 
 CmdBuffer (const CmdBuffer &)=delete
 
 CmdBuffer (CmdBuffer &&)=delete
 
 ~CmdBuffer () noexcept=default
 
CmdBufferoperator= (const CmdBuffer &)=delete
 
CmdBufferoperator= (CmdBuffer &&)=delete
 
void Push (std::unique_ptr< Command > command)
 Pushes a pre-constructed command to the buffer.
 
template<CommandTrait T, typename... Args>
requires std::constructible_from<T, Args...>
void Emplace (Args &&... args)
 Constructs and pushes a command to the buffer.
 

Detailed Description

Command buffer to record operations to be executed later.

All operations are recorded to system local storage and executed in the order they were recorded when World::Update() is called.

Note
Command buffer is not thread-safe but doesn't need to be since each system has its own local storage.

Definition at line 22 of file command_buffer.hpp.

Constructor & Destructor Documentation

◆ CmdBuffer() [1/3]

helios::ecs::details::CmdBuffer::CmdBuffer ( SystemLocalStorage local_storage)
inlineexplicitnoexcept

Definition at line 24 of file command_buffer.hpp.

24: local_storage_(local_storage) {}

◆ CmdBuffer() [2/3]

helios::ecs::details::CmdBuffer::CmdBuffer ( const CmdBuffer )
delete

◆ CmdBuffer() [3/3]

helios::ecs::details::CmdBuffer::CmdBuffer ( CmdBuffer &&  )
delete

◆ ~CmdBuffer()

helios::ecs::details::CmdBuffer::~CmdBuffer ( )
defaultnoexcept

Member Function Documentation

◆ Emplace()

template<CommandTrait T, typename... Args>
requires std::constructible_from<T, Args...>
void helios::ecs::details::CmdBuffer::Emplace ( Args &&...  args)
inline

Constructs and pushes a command to the buffer.

Template Parameters
TCommand type
ArgsConstructor argument types
Parameters
argsArguments to forward to command constructor

Definition at line 46 of file command_buffer.hpp.

46 {
47 local_storage_.EmplaceCommand<T>(std::forward<Args>(args)...);
48 }
void EmplaceCommand(Args &&... args)
Adds a command to the local command buffer.
BasicQuery< World, Allocator, Components... > Query
Type alias for query with mutable world access.
Definition query.hpp:2481

◆ operator=() [1/2]

CmdBuffer & helios::ecs::details::CmdBuffer::operator= ( CmdBuffer &&  )
delete

◆ operator=() [2/2]

CmdBuffer & helios::ecs::details::CmdBuffer::operator= ( const CmdBuffer )
delete

◆ Push()

void helios::ecs::details::CmdBuffer::Push ( std::unique_ptr< Command command)
inline

Pushes a pre-constructed command to the buffer.

Parameters
commandUnique pointer to command

Definition at line 54 of file command_buffer.hpp.

54 {
55 HELIOS_ASSERT(command != nullptr, "Failed to push command to command buffer: command is nullptr!");
56 local_storage_.AddCommand(std::move(command));
57}
#define HELIOS_ASSERT(condition,...)
Assertion macro that aborts execution in debug builds.
Definition assert.hpp:140
void AddCommand(std::unique_ptr< Command > command)
Adds a pre-constructed command to the local buffer.