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

Thin wrapper over command queue and world for deferred ECS operations. More...

#include <commands.hpp>

Public Member Functions

constexpr Commands (PmrCmdQueue &queue, World &world, std::pmr::memory_resource *resource=std::pmr::get_default_resource()) noexcept
 Commands (const Commands &)=delete
 Commands (Commands &&)=delete
constexpr ~Commands ()=default
Commandsoperator= (const Commands &)=delete
Commandsoperator= (Commands &&)=delete
PmrEntityCmdBuffer Spawn ()
 Spawns a new entity and returns a command buffer for it.
void Despawn (Entity entity)
 Enqueues a command to despawn an entity.
constexpr PmrEntityCmdBuffer Entity (Entity entity)
 Returns a command buffer for an existing entity.
constexpr PmrWorldCmdBuffer World ()
 Returns a command buffer for world-level operations.
template<CommandTrait Cmd>
void Enqueue (Cmd &&cmd)
 Enqueues a command.
template<std::ranges::input_range R>
requires CommandTrait<std::ranges::range_value_t<R>>
void EnqueueBulk (R &&range)
 Enqueues multiple commands in bulk.

Detailed Description

Thin wrapper over command queue and world for deferred ECS operations.

Provides a convenient interface for spawning, despawning, and manipulating entities and world state through command buffers.

Note
Not thread-safe.

Definition at line 24 of file commands.hpp.

Constructor & Destructor Documentation

◆ Commands() [1/3]

helios::ecs::Commands::Commands ( PmrCmdQueue & queue,
World & world,
std::pmr::memory_resource * resource = std::pmr::get_default_resource() )
inlineconstexprnoexcept

Definition at line 26 of file commands.hpp.

◆ Commands() [2/3]

helios::ecs::Commands::Commands ( const Commands & )
delete

◆ Commands() [3/3]

helios::ecs::Commands::Commands ( Commands && )
delete

◆ ~Commands()

helios::ecs::Commands::~Commands ( )
constexprdefault

Member Function Documentation

◆ Despawn()

void helios::ecs::Commands::Despawn ( Entity entity)
inline

Enqueues a command to despawn an entity.

Warning
Triggers assertion if entity is invalid.
Parameters
entityEntity to despawn

Definition at line 51 of file commands.hpp.

◆ Enqueue()

template<CommandTrait Cmd>
void helios::ecs::Commands::Enqueue ( Cmd && cmd)
inline

Enqueues a command.

Template Parameters
CmdCommand type, must satisfy CommandTrait
Parameters
cmdCommand to enqueue

Definition at line 78 of file commands.hpp.

◆ EnqueueBulk()

template<std::ranges::input_range R>
requires CommandTrait<std::ranges::range_value_t<R>>
void helios::ecs::Commands::EnqueueBulk ( R && range)
inline

Enqueues multiple commands in bulk.

Template Parameters
RRange type
Parameters
rangeRange of commands to enqueue

Definition at line 89 of file commands.hpp.

◆ Entity()

PmrEntityCmdBuffer helios::ecs::Commands::Entity ( Entity entity)
nodiscardconstexpr

Returns a command buffer for an existing entity.

Warning
Triggers assertion if entity is invalid or does not exist in the world.
Parameters
entityEntity to get command buffer for
Returns
Command buffer for the entity

Definition at line 104 of file commands.hpp.

◆ operator=() [1/2]

Commands & helios::ecs::Commands::operator= ( Commands && )
delete

◆ operator=() [2/2]

Commands & helios::ecs::Commands::operator= ( const Commands & )
delete

◆ Spawn()

PmrEntityCmdBuffer helios::ecs::Commands::Spawn ( )
inline

Spawns a new entity and returns a command buffer for it.

Reserves a new entity ID and returns a command buffer to schedule operations on it.

Returns
Command buffer for the newly reserved entity

Definition at line 99 of file commands.hpp.

◆ World()

PmrWorldCmdBuffer helios::ecs::Commands::World ( )
inlinenodiscardconstexpr

Returns a command buffer for world-level operations.

Returns
Command buffer for world operations

Definition at line 68 of file commands.hpp.