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

Command that executes a function with World reference. More...

#include <commands.hpp>

Inheritance diagram for helios::ecs::details::FunctionCmd< F >:
helios::ecs::Command

Public Member Functions

template<typename G >
requires std::invocable<G, World&> && std::constructible_from<F, G&&>
constexpr FunctionCmd (G &&func) noexcept(std::is_nothrow_constructible_v< F, G && >)
 Constructs function command.
 
constexpr FunctionCmd (const FunctionCmd &) noexcept(std::is_nothrow_copy_constructible_v< F >)=default
 
constexpr FunctionCmd (FunctionCmd &&) noexcept(std::is_nothrow_move_constructible_v< F >)=default
 
constexpr ~FunctionCmd () noexcept(std::is_nothrow_destructible_v< F >) override=default
 
constexpr FunctionCmdoperator= (const FunctionCmd &) noexcept(std::is_nothrow_copy_assignable_v< F >)=default
 
constexpr FunctionCmdoperator= (FunctionCmd &&) noexcept(std::is_nothrow_move_assignable_v< F >)=default
 
void Execute (World &world) override
 Executes the wrapped function.
 
- Public Member Functions inherited from helios::ecs::Command
virtual constexpr ~Command () noexcept=default
 

Detailed Description

template<typename F>
requires std::invocable<F, World&>
class helios::ecs::details::FunctionCmd< F >

Command that executes a function with World reference.

Wraps arbitrary functions for deferred execution during World::Update(). The function must be invocable with a World& parameter.

Template Parameters
FFunction type that accepts World&

Definition at line 32 of file commands.hpp.

Constructor & Destructor Documentation

◆ FunctionCmd() [1/3]

template<typename F >
template<typename G >
requires std::invocable<G, World&> && std::constructible_from<F, G&&>
constexpr helios::ecs::details::FunctionCmd< F >::FunctionCmd ( G &&  func)
inlineexplicitconstexprnoexcept

Constructs function command.

Template Parameters
GType of function to wrap
Parameters
funcFunction to execute, must accept World& parameter

Definition at line 41 of file commands.hpp.

42 : func_(std::forward<G>(func)) {}
BasicQuery< World, Allocator, Components... > Query
Type alias for query with mutable world access.
Definition query.hpp:2481

◆ FunctionCmd() [2/3]

template<typename F >
constexpr helios::ecs::details::FunctionCmd< F >::FunctionCmd ( const FunctionCmd< F > &  ) const
constexprdefaultnoexcept

◆ FunctionCmd() [3/3]

template<typename F >
constexpr helios::ecs::details::FunctionCmd< F >::FunctionCmd ( FunctionCmd< F > &&  ) const
constexprdefaultnoexcept

◆ ~FunctionCmd()

template<typename F >
constexpr helios::ecs::details::FunctionCmd< F >::~FunctionCmd ( )
constexproverridedefaultnoexcept

Member Function Documentation

◆ Execute()

template<typename F >
void helios::ecs::details::FunctionCmd< F >::Execute ( World world)
inlineoverridevirtual

Executes the wrapped function.

Parameters
worldWorld reference to pass to the function

Implements helios::ecs::Command.

Definition at line 55 of file commands.hpp.

55{ func_(world); }

◆ operator=() [1/2]

template<typename F >
constexpr FunctionCmd & helios::ecs::details::FunctionCmd< F >::operator= ( const FunctionCmd< F > &  )
constexprdefaultnoexcept

◆ operator=() [2/2]

template<typename F >
constexpr FunctionCmd & helios::ecs::details::FunctionCmd< F >::operator= ( FunctionCmd< F > &&  )
constexprdefaultnoexcept