![]() |
FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
|
CommandHandler is a class that can be used to handle commands. More...
#include <C_commandHandler.hpp>
Classes | |
struct | CommandData |
This struct contain the data of a command, like the name and the function pointer. More... | |
Public Types | |
using | CommandDataType = std::vector<fge::CommandHandler::CommandData> |
Public Member Functions | |
bool | addCmd (std::string_view name, fge::CommandHandler *handle, fge::CommandFunction cmdfunc) |
Add a new command to the handler. | |
void | delCmd (std::string_view name) |
Delete a command from the handler. | |
bool | replaceCmd (std::string_view name, fge::CommandHandler *handle, fge::CommandFunction cmdfunc) |
Replace a command from the handler. | |
void | clearCmd () |
Clear all commands from the handler. | |
fge::Property | callCmd (std::string_view name, fge::Object *caller, fge::Property const &arg, fge::Scene *caller_scene) |
Call a command by its name. | |
fge::Property | callCmd (std::size_t index, fge::Object *caller, fge::Property const &arg, fge::Scene *caller_scene) |
Call a command by its index. | |
std::size_t | getCmdIndex (std::string_view name) const |
Get the index of a command by its name. | |
std::string_view | getCmdName (std::size_t index) const |
Get the name of a command by its index. | |
fge::CommandHandler::CommandData const * | getCmd (std::string_view name) const |
Get a command by its name. | |
std::size_t | getCmdSize () const |
Get the number of commands. | |
fge::CommandHandler::CommandDataType const & | getCmdList () const |
Get the commands list. | |
CommandHandler is a class that can be used to handle commands.
A command is a well-defined function signature that can be attributed to an name (string) and be called by another object with ease.
A command is also indexed to avoid sending the command name on a network communication.
bool fge::CommandHandler::addCmd | ( | std::string_view | name, |
fge::CommandHandler * | handle, | ||
fge::CommandFunction | cmdfunc ) |
Add a new command to the handler.
An object should inherit from CommandHandler and add commands to it.
name | The name of the command |
handle | The object that will handle the command |
cmdfunc | The function pointer of the command |
fge::Property fge::CommandHandler::callCmd | ( | std::size_t | index, |
fge::Object * | caller, | ||
fge::Property const & | arg, | ||
fge::Scene * | caller_scene ) |
Call a command by its index.
index | The index of the command |
caller | The object that call the command |
arg | The arguments of the command |
caller_scene | The scene that contains the caller |
fge::Property fge::CommandHandler::callCmd | ( | std::string_view | name, |
fge::Object * | caller, | ||
fge::Property const & | arg, | ||
fge::Scene * | caller_scene ) |
Call a command by its name.
name | The name of the command |
caller | The object that call the command |
arg | The arguments of the command |
caller_scene | The scene that contains the caller |
void fge::CommandHandler::clearCmd | ( | ) |
Clear all commands from the handler.
void fge::CommandHandler::delCmd | ( | std::string_view | name | ) |
Delete a command from the handler.
name | The name of the command |
|
nodiscard |
Get a command by its name.
name | The name of the command |
|
nodiscard |
Get the index of a command by its name.
name | The name of the command |
|
nodiscard |
Get the commands list.
|
nodiscard |
Get the name of a command by its index.
index | The index of the command |
|
nodiscard |
Get the number of commands.
bool fge::CommandHandler::replaceCmd | ( | std::string_view | name, |
fge::CommandHandler * | handle, | ||
fge::CommandFunction | cmdfunc ) |
Replace a command from the handler.
name | The name of the command |
handle | The new object that will handle the command |
cmdfunc | The new function pointer of the command |