17#ifndef _FGE_C_COMMANDHANDLER_HPP_INCLUDED
18#define _FGE_C_COMMANDHANDLER_HPP_INCLUDED
20#include "FastEngine/fge_extern.hpp"
21#include "FastEngine/C_property.hpp"
23#include <unordered_map>
31#define FGE_CMD_FUNC(x) static_cast<fge::CommandFunction>(x)
64 fge::CommandFunction _func;
68 using CommandDataType = std::vector<fge::CommandHandler::CommandData>;
132 [[nodiscard]] std::size_t
getCmdIndex(std::string_view name)
const;
139 [[nodiscard]] std::string_view
getCmdName(std::size_t index)
const;
161 [[nodiscard]] fge::CommandHandler::CommandDataType
const&
getCmdList()
const;
164 fge::CommandHandler::CommandDataType g_cmdData;
165 std::unordered_map<std::string_view, std::size_t> g_cmdDataMap;
CommandHandler is a class that can be used to handle commands.
Definition C_commandHandler.hpp:55
void delCmd(std::string_view name)
Delete a command from the handler.
fge::CommandHandler::CommandDataType const & getCmdList() const
Get the commands list.
std::string_view getCmdName(std::size_t index) const
Get the name of a command by its index.
std::size_t getCmdSize() const
Get the number of commands.
fge::Property callCmd(std::size_t index, fge::Object *caller, fge::Property const &arg, fge::Scene *caller_scene)
Call a command by its index.
bool addCmd(std::string_view name, fge::CommandHandler *handle, fge::CommandFunction cmdfunc)
Add a new command to the handler.
void clearCmd()
Clear all commands from the handler.
bool replaceCmd(std::string_view name, fge::CommandHandler *handle, fge::CommandFunction cmdfunc)
Replace a command from the handler.
std::size_t getCmdIndex(std::string_view name) const
Get the index of a command by its name.
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::CommandHandler::CommandData const * getCmd(std::string_view name) const
Get a command by its name.
The Object class is the base class for all objects in the engine.
Definition C_object.hpp:102
A class that can store any type of data.
Definition C_property.hpp:54
A scene contain a collection of object and handle them.
Definition C_scene.hpp:450
This struct contain the data of a command, like the name and the function pointer.
Definition C_commandHandler.hpp:62