buffet: Allow setting command results.
Next step in command results support: now there is
CommandInstance::SetResults method which allows results
modifications.
BUG=chromium:435607
TEST=cros_workon_make --test buffet
Change-Id: I1f5da9c3613a2996cea3f65f07945cc64bfeda2e
Reviewed-on: https://chromium-review.googlesource.com/231337
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Tested-by: Anton Muhin <antonm@chromium.org>
Commit-Queue: Anton Muhin <antonm@chromium.org>
diff --git a/buffet/commands/command_dictionary.cc b/buffet/commands/command_dictionary.cc
index 930e044..58ab823 100644
--- a/buffet/commands/command_dictionary.cc
+++ b/buffet/commands/command_dictionary.cc
@@ -70,8 +70,7 @@
const ObjectSchema* base_parameters_def = nullptr;
const ObjectSchema* base_results_def = nullptr;
if (base_commands) {
- const CommandDefinition* cmd =
- base_commands->FindCommand(full_command_name);
+ auto cmd = base_commands->FindCommand(full_command_name);
if (cmd) {
base_parameters_def = cmd->GetParameters().get();
base_results_def = cmd->GetResults().get();
@@ -210,10 +209,11 @@
return dict;
}
-const CommandDefinition* CommandDictionary::FindCommand(
+std::shared_ptr<const CommandDefinition> CommandDictionary::FindCommand(
const std::string& command_name) const {
auto pair = definitions_.find(command_name);
- return (pair != definitions_.end()) ? pair->second.get() : nullptr;
+ return (pair != definitions_.end()) ? pair->second :
+ std::shared_ptr<const CommandDefinition>();
}
void CommandDictionary::Clear() {