Helios Engine 0.1.0
A modular ECS based data-oriented C++23 game engine
 
Loading...
Searching...
No Matches
helios::ecs::details::AddComponentCmd< T > Class Template Referencefinal

Command to add a component to an entity. More...

#include <commands.hpp>

Inheritance diagram for helios::ecs::details::AddComponentCmd< T >:
helios::ecs::Command

Public Member Functions

constexpr AddComponentCmd (Entity entity, const T &component) noexcept(std::is_nothrow_copy_constructible_v< T >)
 Constructs add component command with copy.
 
constexpr AddComponentCmd (Entity entity, T &&component) noexcept(std::is_nothrow_move_constructible_v< T >)
 Constructs add component command with move.
 
constexpr AddComponentCmd (const AddComponentCmd &) noexcept(std::is_nothrow_copy_constructible_v< T >)=default
 
constexpr AddComponentCmd (AddComponentCmd &&) noexcept(std::is_nothrow_move_constructible_v< T >)=default
 
constexpr ~AddComponentCmd () noexcept(std::is_nothrow_destructible_v< T >) override=default
 
constexpr AddComponentCmdoperator= (const AddComponentCmd &) noexcept(std::is_nothrow_copy_assignable_v< T >)=default
 
constexpr AddComponentCmdoperator= (AddComponentCmd &&) noexcept(std::is_nothrow_move_assignable_v< T >)=default
 
void Execute (World &world) override
 Executes component addition.
 
- Public Member Functions inherited from helios::ecs::Command
virtual constexpr ~Command () noexcept=default
 

Detailed Description

template<ComponentTrait T>
class helios::ecs::details::AddComponentCmd< T >

Command to add a component to an entity.

Adds component of type T to the specified entity during execution. If entity already has the component, it will be replaced.

Template Parameters
TComponent type to add

Definition at line 225 of file commands.hpp.

Constructor & Destructor Documentation

◆ AddComponentCmd() [1/4]

template<ComponentTrait T>
constexpr helios::ecs::details::AddComponentCmd< T >::AddComponentCmd ( Entity  entity,
const T &  component 
)
constexprnoexcept

Constructs add component command with copy.

Warning
Triggers assertion if entity is invalid.
Parameters
entityEntity to add component to
componentComponent to copy

Definition at line 261 of file commands.hpp.

263 : entity_(entity), component_(component) {
264 HELIOS_ASSERT(entity.Valid(), "Failed to construct add component command: Entity with index '{}' is invalid!",
265 entity.Index());
266}
#define HELIOS_ASSERT(condition,...)
Assertion macro that aborts execution in debug builds.
Definition assert.hpp:140
BasicQuery< World, Allocator, Components... > Query
Type alias for query with mutable world access.
Definition query.hpp:2481

◆ AddComponentCmd() [2/4]

template<ComponentTrait T>
constexpr helios::ecs::details::AddComponentCmd< T >::AddComponentCmd ( Entity  entity,
T &&  component 
)
constexprnoexcept

Constructs add component command with move.

Warning
Triggers assertion if entity is invalid.
Parameters
entityEntity to add component to
componentComponent to move

Definition at line 269 of file commands.hpp.

271 : entity_(entity), component_(std::move(component)) {
272 HELIOS_ASSERT(entity.Valid(), "Failed to construct add component command: Entity with index '{}' is invalid!",
273 entity.Index());
274}

◆ AddComponentCmd() [3/4]

template<ComponentTrait T>
constexpr helios::ecs::details::AddComponentCmd< T >::AddComponentCmd ( const AddComponentCmd< T > &  ) const
constexprdefaultnoexcept

◆ AddComponentCmd() [4/4]

template<ComponentTrait T>
constexpr helios::ecs::details::AddComponentCmd< T >::AddComponentCmd ( AddComponentCmd< T > &&  ) const
constexprdefaultnoexcept

◆ ~AddComponentCmd()

template<ComponentTrait T>
constexpr helios::ecs::details::AddComponentCmd< T >::~AddComponentCmd ( )
constexproverridedefaultnoexcept

Member Function Documentation

◆ Execute()

template<ComponentTrait T>
void helios::ecs::details::AddComponentCmd< T >::Execute ( World world)
inlineoverridevirtual

Executes component addition.

Parameters
worldWorld to add component in

Implements helios::ecs::Command.

Definition at line 253 of file commands.hpp.

253{ world.AddComponent(entity_, std::move(component_)); }

◆ operator=() [1/2]

template<ComponentTrait T>
constexpr AddComponentCmd & helios::ecs::details::AddComponentCmd< T >::operator= ( AddComponentCmd< T > &&  )
constexprdefaultnoexcept

◆ operator=() [2/2]

template<ComponentTrait T>
constexpr AddComponentCmd & helios::ecs::details::AddComponentCmd< T >::operator= ( const AddComponentCmd< T > &  )
constexprdefaultnoexcept