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

Command to try add a component (only if missing). More...

#include <commands.hpp>

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

Public Member Functions

constexpr TryAddComponentCmd (Entity entity, const T &component) noexcept(std::is_nothrow_copy_constructible_v< T >)
 Constructs try add component command with copy.
 
constexpr TryAddComponentCmd (Entity entity, T &&component) noexcept(std::is_nothrow_move_constructible_v< T >)
 Constructs try add component command with move.
 
constexpr TryAddComponentCmd (const TryAddComponentCmd &) noexcept=default
 
constexpr TryAddComponentCmd (TryAddComponentCmd &&) noexcept=default
 
constexpr ~TryAddComponentCmd () noexcept override=default
 
constexpr TryAddComponentCmdoperator= (const TryAddComponentCmd &) noexcept=default
 
constexpr TryAddComponentCmdoperator= (TryAddComponentCmd &&) noexcept=default
 
void Execute (World &world) override
 Executes component addition if entity is missing it.
 
- Public Member Functions inherited from helios::ecs::Command
virtual constexpr ~Command () noexcept=default
 

Detailed Description

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

Command to try add a component (only if missing).

Template Parameters
TComponent type

Definition at line 331 of file commands.hpp.

Constructor & Destructor Documentation

◆ TryAddComponentCmd() [1/4]

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

Constructs try add component command with copy.

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

Definition at line 367 of file commands.hpp.

369 : entity_(entity), component_(component) {
370 HELIOS_ASSERT(entity.Valid(), "Failed to construct try add component command: Entity with index '{}' is invalid!",
371 entity.Index());
372}
#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

◆ TryAddComponentCmd() [2/4]

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

Constructs try add component command with move.

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

Definition at line 375 of file commands.hpp.

377 : entity_(entity), component_(std::move(component)) {
378 HELIOS_ASSERT(entity.Valid(), "Failed to construct try add component command: Entity with index '{}' is invalid!",
379 entity.Index());
380}

◆ TryAddComponentCmd() [3/4]

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

◆ TryAddComponentCmd() [4/4]

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

◆ ~TryAddComponentCmd()

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

Member Function Documentation

◆ Execute()

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

Executes component addition if entity is missing it.

Parameters
worldWorld to add component in

Implements helios::ecs::Command.

Definition at line 359 of file commands.hpp.

359{ world.TryAddComponent(entity_, std::move(component_)); }

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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