2 #include <score/command/Dispatchers/ICommandDispatcher.hpp>
3 #include <score/command/Dispatchers/SendStrategy.hpp>
4 #include <score/plugins/StringFactoryKey.hpp>
5 #include <score/tools/Debug.hpp>
6 #include <score/tools/SafeCast.hpp>
36 template <
typename TheCommand,
typename... Args>
41 stack().disableActions();
42 m_cmd = std::make_unique<TheCommand>(std::forward<Args>(args)...);
43 m_cmd->redo(stack().context());
47 if(m_cmd->key() != TheCommand::static_key())
49 throw std::runtime_error(
50 "Ongoing command mismatch: current command " + m_cmd->key().toString()
51 +
" does not match new command " + TheCommand{}.key().toString());
54 safe_cast<TheCommand*>(m_cmd.get())->update(std::forward<Args>(args)...);
55 m_cmd->redo(stack().context());
65 SendStrategy::Quiet::send(stack(), m_cmd.release());
66 stack().enableActions();
75 m_cmd->undo(stack().context());
76 stack().enableActions();
82 std::unique_ptr<score::Command> m_cmd;
The ICommandDispatcher class.
Definition: ICommandDispatcher.hpp:21
The OngoingCommandDispatcher class.
Definition: OngoingCommandDispatcher.hpp:27
void submit(Args &&... args)
Definition: OngoingCommandDispatcher.hpp:37
void commit()
Definition: OngoingCommandDispatcher.hpp:61
void rollback()
If the command has to be reverted, for instance when pressing escape.
Definition: OngoingCommandDispatcher.hpp:71
A small abstraction layer over the score::CommandStack.
Definition: CommandStackFacade.hpp:20