Command
Base class for all commands. More...
#include "Commands/Command.h"
Inherits from ICommand
Public Types
| Name | |
|---|---|
| typedef std::function< void(Args &...)> | Callback |
Public Functions
| Name | |
|---|---|
| Command() =default | |
| virtual | ~Command() =default |
| virtual void | execute() override<br>Call all callbacks. |
| void | addListener(Callback function)<br>Add a listener for a command. |
| void | dispatch(Args... args)<br>Tell application that command was issued. |
| void | dispatchImmediate(Args... args) |
Protected Functions
| Name | |
|---|---|
| Command(const std::tuple< Args... > & args)<br>Copy a command and its arguments. |
Additional inherited members
Public Functions inherited from ICommand
| Name | |
|---|---|
| virtual | ~ICommand() =default |
Detailed Description
template <typename Type ,
typename... Args>
class Command;Base class for all commands.
Template Parameters:
- Type command derived class (CloseCommand for example)-
- Args command argument for callback call.
Any derived command can be accessed by calling DerivedCommandName::addListener(fptr); For more information see Curiously recurring template pattern (static m_listeners).
Public Types Documentation
typedef Callback
typedef std::function<void(Args&...)> Command< Type, Args >::Callback;Public Functions Documentation
function Command
Command() =defaultfunction ~Command
virtual ~Command() =defaultfunction execute
inline virtual void execute() overrideCall all callbacks.
Reimplements: ICommand::execute
Expand m_params tuple as function arguments, link.
function addListener
static inline void addListener(
Callback function
)Add a listener for a command.
Parameters:
- function callback to call when the command is issued. Use std::bind for member function of instantiated class or raw function pointer for static member function or plain function.
Todo: Check how std::bind handle this reference.
NEVER use the function from constructor of statically instantiated object.
function dispatch
static inline void dispatch(
Args... args
)Tell application that command was issued.
Pass a copy of command and its arguments to the Application.
function dispatchImmediate
static inline void dispatchImmediate(
Args... args
)Protected Functions Documentation
function Command
inline explicit Command(
const std::tuple< Args... > & args
)Copy a command and its arguments.
Parameters:
- args command arguments.
Updated on 2026-09-11 at 21:24:25 +0000