2 #include <score/command/AggregateCommand.hpp>
3 #include <score/command/Dispatchers/ICommandDispatcher.hpp>
4 #include <score/command/Dispatchers/SendStrategy.hpp>
16 template <
typename Command_T,
typename RedoStrategy_T,
typename SendStrategy_T>
20 template <
typename... Args>
23 , m_aggregateCommand{std::make_unique<Command_T>()}
26 std::is_base_of<score::AggregateCommand, Command_T>::value,
27 "MacroCommandDispatcher: Command_T must be AggregateCommand-derived");
30 template <
typename... Args>
32 std::unique_ptr<score::AggregateCommand> cmd, Args&&... args)
34 , m_aggregateCommand{std::move(cmd)}
36 SCORE_ASSERT(m_aggregateCommand);
41 RedoStrategy_T::redo(stack().context(), *cmd);
42 m_aggregateCommand->addCommand(cmd);
47 if(m_aggregateCommand)
49 if(m_aggregateCommand->count() != 0)
51 SendStrategy_T::send(stack(), m_aggregateCommand.release());
54 m_aggregateCommand.reset();
60 if(m_aggregateCommand)
62 m_aggregateCommand->undo(stack().context());
63 m_aggregateCommand.reset();
67 auto command()
const {
return m_aggregateCommand.get(); }
70 std::unique_ptr<Command_T> m_aggregateCommand;
74 template <
typename Command_T>
79 template <
typename Command_T>
84 template <
typename Command_T>
The MacroCommandDispatcher class.
Definition: MacroCommandDispatcher.hpp:18
The ICommandDispatcher class.
Definition: ICommandDispatcher.hpp:21
The Command class.
Definition: Command.hpp:34
Definition: SendStrategy.hpp:42
Definition: SendStrategy.hpp:7