2 #include <score/command/SettingsCommand.hpp>
3 #include <score/plugins/StringFactoryKey.hpp>
4 #include <score/tools/std/HashMap.hpp>
12 template <
typename TheCommand,
typename... Args>
13 void submit(Args&&... args)
15 static_assert(!TheCommand::is_deferred,
"Don't use a deferred command");
16 auto it = commands.find(TheCommand::static_key());
17 if(it != commands.end())
19 static_cast<TheCommand&
>(*it->second).update(std::forward<Args>(args)...);
24 auto cmd = std::make_unique<TheCommand>(std::forward<Args>(args)...);
26 commands.insert(std::make_pair(TheCommand::static_key(), std::move(cmd)));
30 template <
typename TheCommand,
typename... Args>
31 void submitDeferredCommand(Args&&... args)
33 static_assert(TheCommand::is_deferred,
"Use a deferred command");
34 auto it = deferred.find(TheCommand::static_key());
35 if(it != deferred.end())
37 static_cast<TheCommand&
>(*it->second).update(std::forward<Args>(args)...);
41 auto cmd = std::make_unique<TheCommand>(std::forward<Args>(args)...);
42 deferred.insert(std::make_pair(TheCommand::static_key(), std::move(cmd)));
49 for(
auto& it : deferred)
58 for(
auto& it : commands)
67 score::hash_map<CommandKey, std::unique_ptr<score::SettingsCommandBase>> commands;
68 score::hash_map<CommandKey, std::unique_ptr<score::SettingsCommandBase>> deferred;
Definition: SettingsCommandDispatcher.hpp:10
Base toolkit upon which the software is built.
Definition: Application.cpp:90