This commit is contained in:
Nav
2022-12-17 14:46:08 +00:00
parent 9097e37375
commit 529438b9e4
2 changed files with 12 additions and 7 deletions

View File

@@ -165,12 +165,15 @@ namespace Bloom::TargetController
*/
template<class CommandType>
void registerCommandHandler(std::function<std::unique_ptr<Responses::Response>(CommandType&)> callback) {
auto parentCallback = [callback] (Commands::Command& command) {
// Downcast the command to the expected type
return callback(dynamic_cast<CommandType&>(command));
};
this->commandHandlersByCommandType.insert(std::pair(CommandType::type, parentCallback));
this->commandHandlersByCommandType.insert(
std::pair(
CommandType::type,
[callback] (Commands::Command& command) {
// Downcast the command to the expected type
return callback(dynamic_cast<CommandType&>(command));
}
)
);
}
/**