Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dependencies.repos
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
- git:
local-name: boost_plugin_loader
uri: 'https://github.com/tesseract-robotics/boost_plugin_loader.git'
version: 0.3.2
version: 0.4.3
3 changes: 0 additions & 3 deletions noether_gui/include/noether_gui/plugin_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,6 @@ class WidgetFactory : public Factory
BaseWidget* createToolPathModifierWidget(const std::string& name,
const YAML::Node& config = {},
QWidget* parent = nullptr) const;

private:
mutable std::map<std::string, WidgetPlugin::Ptr> widget_plugins_;
};

} // namespace noether
Expand Down
10 changes: 4 additions & 6 deletions noether_gui/src/plugin_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ std::string ToolPathModifierWidgetPlugin::getSection() { return STRINGIFY(NOETHE
WidgetFactory::WidgetFactory()
{
auto loader = std::make_shared<boost_plugin_loader::PluginLoader>();
loader->search_libraries.insert(NOETHER_PLUGIN_LIB);
loader->search_libraries.insert(NOETHER_GUI_PLUGIN_LIB);
loader->search_libraries.emplace_back(NOETHER_PLUGIN_LIB);
loader->search_libraries.emplace_back(NOETHER_GUI_PLUGIN_LIB);
loader->search_libraries_env = NOETHER_PLUGIN_LIBS_ENV;
loader->search_paths_env = NOETHER_PLUGIN_PATHS_ENV;
loader_ = loader;
Expand All @@ -30,11 +30,9 @@ WidgetFactory::WidgetFactory(std::shared_ptr<const boost_plugin_loader::PluginLo
template <typename PluginT>
BaseWidget* WidgetFactory::createWidget(const std::string& name, const YAML::Node& config, QWidget* parent) const
{
if (widget_plugins_.find(name) == widget_plugins_.end())
widget_plugins_[name] = loader_->createInstance<PluginT>(name);

auto plugin = loader_->createInstance<PluginT>(name);
auto this_shared = std::shared_ptr<const WidgetFactory>(this, [](const WidgetFactory*) {});
return widget_plugins_[name]->create(config, this_shared, parent);
return plugin->create(config, this_shared, parent);
}

BaseWidget* WidgetFactory::createMeshModifierWidget(const std::string& name,
Expand Down
10 changes: 1 addition & 9 deletions noether_tpp/include/noether_tpp/plugin_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,8 @@ class Factory
protected:
std::shared_ptr<const boost_plugin_loader::PluginLoader> loader_;

private:
template <typename PluginT>
typename PluginT::ComponentT::Ptr create(std::map<std::string, typename PluginT::Ptr>& plugin_map,
const YAML::Node& config) const;

mutable std::map<std::string, MeshModifierPlugin::Ptr> mesh_modifier_plugins_;
mutable std::map<std::string, ToolPathPlannerPlugin::Ptr> tool_path_planner_plugins_;
mutable std::map<std::string, DirectionGeneratorPlugin::Ptr> direction_generator_plugins_;
mutable std::map<std::string, OriginGeneratorPlugin::Ptr> origin_generator_plugins_;
mutable std::map<std::string, ToolPathModifierPlugin::Ptr> tool_path_modifier_plugins_;
typename PluginT::ComponentT::Ptr create(const YAML::Node& config) const;
};

} // namespace noether
Expand Down
21 changes: 9 additions & 12 deletions noether_tpp/src/plugin_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ std::string MeshModifierPlugin::getSection()
Factory::Factory()
{
auto loader = std::make_shared<boost_plugin_loader::PluginLoader>();
loader->search_libraries.insert(NOETHER_PLUGIN_LIB);
loader->search_libraries.emplace_back(NOETHER_PLUGIN_LIB);
loader->search_libraries_env = NOETHER_PLUGIN_LIBS_ENV;
loader->search_paths_env = NOETHER_PLUGIN_PATHS_ENV;
loader_ = loader;
Expand All @@ -61,40 +61,37 @@ Factory::Factory()
Factory::Factory(std::shared_ptr<const boost_plugin_loader::PluginLoader> loader) : loader_(loader) {}

template <typename PluginT>
typename PluginT::ComponentT::Ptr Factory::create(std::map<std::string, typename PluginT::Ptr>& plugin_map,
const YAML::Node& config) const
typename PluginT::ComponentT::Ptr Factory::create(const YAML::Node& config) const
{
auto name = YAML::getMember<std::string>(config, "name");
if (plugin_map.find(name) == plugin_map.end())
plugin_map[name] = loader_->createInstance<PluginT>(name);

auto plugin = loader_->createInstance<PluginT>(name);
auto this_shared = std::shared_ptr<const Factory>(this, [](const Factory*) {});
return plugin_map[name]->create(config, this_shared);
return plugin->create(config, this_shared);
}

MeshModifier::Ptr Factory::createMeshModifier(const YAML::Node& config) const
{
return create<MeshModifierPlugin>(mesh_modifier_plugins_, config);
return create<MeshModifierPlugin>(config);
}

ToolPathPlanner::Ptr Factory::createToolPathPlanner(const YAML::Node& config) const
{
return create<ToolPathPlannerPlugin>(tool_path_planner_plugins_, config);
return create<ToolPathPlannerPlugin>(config);
}

OriginGenerator::Ptr Factory::createOriginGenerator(const YAML::Node& config) const
{
return create<OriginGeneratorPlugin>(origin_generator_plugins_, config);
return create<OriginGeneratorPlugin>(config);
}

DirectionGenerator::Ptr Factory::createDirectionGenerator(const YAML::Node& config) const
{
return create<DirectionGeneratorPlugin>(direction_generator_plugins_, config);
return create<DirectionGeneratorPlugin>(config);
}

ToolPathModifier::Ptr Factory::createToolPathModifier(const YAML::Node& config) const
{
return create<ToolPathModifierPlugin>(tool_path_modifier_plugins_, config);
return create<ToolPathModifierPlugin>(config);
}

template std::vector<std::string> Factory::getAvailablePlugins<MeshModifierPlugin>() const;
Expand Down
4 changes: 2 additions & 2 deletions noether_tpp/test/mesh_modifier_utest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ std::vector<std::shared_ptr<const MeshModifier>> createModifiers(const std::stri
{
// Create the factory
auto loader = std::make_shared<boost_plugin_loader::PluginLoader>();
loader->search_libraries.insert(NOETHER_PLUGIN_LIB);
loader->search_paths.insert(PLUGIN_DIR);
loader->search_libraries.emplace_back(NOETHER_PLUGIN_LIB);
loader->search_paths.emplace_back(PLUGIN_DIR);
Factory factory(loader);

// Load the plugin YAML config
Expand Down
4 changes: 2 additions & 2 deletions noether_tpp/test/tool_path_modifier_utest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ std::vector<std::shared_ptr<const ToolPathModifier>> createModifiers()
{
// Create the factory
auto loader = std::make_shared<boost_plugin_loader::PluginLoader>();
loader->search_libraries.insert(NOETHER_PLUGIN_LIB);
loader->search_paths.insert(PLUGIN_DIR);
loader->search_libraries.emplace_back(NOETHER_PLUGIN_LIB);
loader->search_paths.emplace_back(PLUGIN_DIR);

Factory factory(loader);

Expand Down
Loading