34 {
35
36 ProcessComponentConfig config;
38 AERROR <<
"Unable to load ExternalCommandProcessComponent conf file: "
40 return false;
41 }
43 for (const auto& processor_class_name : config.processor()) {
44 command_processors_.emplace_back(
45 plugin_manager->CreateInstance<CommandProcessorBase>(
46 processor_class_name));
47 command_processors_.back()->Init(
node_);
48 }
49 command_status_service_ =
50 node_->CreateService<CommandStatusRequest, CommandStatus>(
51 config.output_command_status_name(),
52 [this](const std::shared_ptr<CommandStatusRequest>& request,
53 std::shared_ptr<CommandStatus>& response) {
54 bool is_get_status = false;
55
56 for (const auto& processor : command_processors_) {
57 if (processor->GetCommandStatus(request->command_id(),
58 response.get())) {
59 is_get_status = true;
60 break;
61 }
62 }
63 if (!is_get_status) {
65 response->set_message("Cannot get the status of command.");
66 }
67 });
68 AINFO <<
"ExternalCommandProcessComponent init finished.";
69 return true;
70}
bool GetProtoConfig(T *config) const
const std::string & ConfigFilePath() const
std::shared_ptr< Node > node_
static PluginManager * Instance()
get singleton instance of PluginManager