CommandDispatcher.hpp
1 #pragma once
2 #include <score/command/Dispatchers/ICommandDispatcher.hpp>
3 #include <score/command/Dispatchers/SendStrategy.hpp>
4 
5 #include <memory>
6 template <typename SendStrategy = SendStrategy::Simple>
13 {
14 public:
15  template <typename... Args>
16  CommandDispatcher(Args&&... args)
17  : ICommandDispatcher{std::forward<Args&&>(args)...}
18  {
19  }
20 
21  void submit(score::Command* cmd) const { SendStrategy::send(stack(), cmd); }
22 
23  template <typename T, typename... Args>
24  void submit(Args&&... args) const
25  {
26  SendStrategy::send(stack(), new T{std::forward<Args>(args)...});
27  }
28 
29  void submit(std::unique_ptr<score::Command> cmd) const
30  {
31  SendStrategy::send(stack(), cmd.release());
32  }
33 };
The CommandDispatcher class.
Definition: CommandDispatcher.hpp:13
The ICommandDispatcher class.
Definition: ICommandDispatcher.hpp:21
The Command class.
Definition: Command.hpp:34