10 (*plugin)->Execute(data);
20 std::shared_ptr<rapidjson::Document> config, udp::endpoint target_socket,
22 : plugin_loader_(
"skyway",
"skyway_plugin::SkyWayBinaryPlugin"),
23 config_(
std::move(config)),
24 target_socket_(target_socket) {
28 std::make_shared<std::function<
void(std::vector<uint8_t>)>>(std::bind(
35 (*plugin)->Shutdown();
39 ROS_DEBUG(
"Succeeded in unloading all plugins");
45 return {
false, 0,
"invalid config parameters"};
50 std::make_shared<std::function<void(std::vector<uint8_t>)>>(std::bind(
53 for (rapidjson::Value::ConstValueIterator itr =
config_->Begin();
55 if (!itr->HasMember(
"plugin_name"))
continue;
56 std::string plugin_name = (*itr)[
"plugin_name"].GetString();
61 std::shared_ptr<rapidjson::Document> parameter(
new rapidjson::Document);
62 parameter->CopyFrom(*itr, parameter->GetAllocator());
63 plugin->Initialize(std::move(parameter), callback);
65 ROS_DEBUG(
"plugin %s has been loaded successfully", plugin_name.c_str());
68 std::ostringstream stream;
69 stream <<
"Failed to load " << plugin_name << ex.what();
70 std::string message = stream.str();
71 char* data = (
char*)malloc(strlen(message.c_str()) + 1);
72 ROS_ERROR(
"plugin load error: %s", message.c_str());
73 strcpy(data, message.c_str());
74 return {.is_success =
false, 0, .error_message = (
const char*)data};
81 return {
true,
socket_->Port(),
""};
86 Component<fruit::Annotated<BinaryAnnotation, PluginRouterFactory>>
88 return createComponent()
89 .bind<fruit::Annotated<BinaryAnnotation, PluginRouter>,