9 std::string message(data.begin(), data.end());
12 (*plugin)->Execute(message);
17 std::vector<uint8_t> data(message.begin(), message.end());
23 std::shared_ptr<rapidjson::Document> config, udp::endpoint target_socket,
25 : plugin_loader_(
"skyway",
"skyway_plugin::SkyWayStringPlugin"),
26 config_(
std::move(config)),
27 target_socket_(target_socket) {
31 std::make_shared<std::function<
void(std::vector<uint8_t>)>>(std::bind(
38 (*plugin)->Shutdown();
42 ROS_DEBUG(
"Succeeded in unloading all plugins");
49 return {
false, 0,
"invalid config parameters"};
52 auto callback = std::make_shared<std::function<void(std::string)>>(std::bind(
55 for (rapidjson::Value::ConstValueIterator itr =
config_->Begin();
57 if (!itr->HasMember(
"plugin_name"))
continue;
58 std::string plugin_name = (*itr)[
"plugin_name"].GetString();
63 std::shared_ptr<rapidjson::Document> parameter(
new rapidjson::Document);
64 parameter->CopyFrom(*itr, parameter->GetAllocator());
65 plugin->Initialize(std::move(parameter), callback);
66 ROS_DEBUG(
"plugin %s has been loaded successfully", plugin_name.c_str());
70 std::ostringstream stream;
71 stream <<
"Failed to load " << plugin_name << ex.what();
72 std::string message = stream.str();
73 char* data = (
char*)malloc(strlen(message.c_str()) + 1);
74 ROS_ERROR(
"plugin load error: %s", message.c_str());
75 strcpy(data, message.c_str());
76 return {
false, 0, (
const char*)data};
83 return {
true,
socket_->Port(),
""};
88 Component<fruit::Annotated<StringAnnotation, PluginRouterFactory>>
90 return createComponent()
91 .bind<fruit::Annotated<StringAnnotation, PluginRouter>,