Skip to content

Commit cc729b1

Browse files
Update to leverage boost_plugin_loader
1 parent 143bcd5 commit cc729b1

File tree

11 files changed

+38
-20
lines changed

11 files changed

+38
-20
lines changed

tesseract_task_composer/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ endif()
1111

1212
find_package(console_bridge REQUIRED)
1313
find_package(tesseract_common REQUIRED)
14+
find_package(boost_plugin_loader REQUIRED)
1415
find_package(Boost REQUIRED COMPONENTS serialization)
1516
find_package(yaml-cpp REQUIRED)
1617

tesseract_task_composer/core/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ target_link_libraries(
2222
${PROJECT_NAME}
2323
PUBLIC console_bridge::console_bridge
2424
tesseract::tesseract_common
25+
boost_plugin_loader::boost_plugin_loader
2526
Boost::boost
2627
Boost::serialization
2728
yaml-cpp)
@@ -125,6 +126,7 @@ configure_component(
125126
DEPENDENCIES
126127
console_bridge
127128
tesseract_common
129+
boost_plugin_loader
128130
"Boost REQUIRED COMPONENTS serialization"
129131
yaml-cpp
130132
CFG_EXTRAS cmake/core-extras.cmake)
@@ -134,6 +136,10 @@ if(TESSERACT_PACKAGE)
134136
COMPONENT core
135137
VERSION ${pkg_extracted_version}
136138
DESCRIPTION "Tesseract task composer core components"
137-
LINUX_DEPENDS "libconsole-bridge-dev" "libyaml-cpp-dev" "${TESSERACT_PACKAGE_PREFIX}tesseract-common"
139+
LINUX_DEPENDS
140+
"libconsole-bridge-dev"
141+
"libyaml-cpp-dev"
142+
"boost-plugin-loader"
143+
"${TESSERACT_PACKAGE_PREFIX}tesseract-common"
138144
WINDOWS_DEPENDS "console-bridge" "yaml-cpp" "${TESSERACT_PACKAGE_PREFIX}tesseract-common")
139145
endif()

tesseract_task_composer/core/include/tesseract_task_composer/core/task_composer_plugin_factory.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,15 @@ TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
3535
TESSERACT_COMMON_IGNORE_WARNINGS_POP
3636

3737
#include <tesseract_common/fwd.h>
38+
#include <boost_plugin_loader/macros.h>
3839
#include <filesystem>
3940

4041
// clang-format off
4142
#define TESSERACT_ADD_TASK_COMPOSER_EXECUTOR_PLUGIN(DERIVED_CLASS, ALIAS) \
42-
TESSERACT_ADD_PLUGIN_SECTIONED(DERIVED_CLASS, ALIAS, TaskExec)
43+
EXPORT_CLASS_SECTIONED(DERIVED_CLASS, ALIAS, TaskExec)
4344

4445
#define TESSERACT_ADD_TASK_COMPOSER_NODE_PLUGIN(DERIVED_CLASS, ALIAS) \
45-
TESSERACT_ADD_PLUGIN_SECTIONED(DERIVED_CLASS, ALIAS, TaskNode)
46+
EXPORT_CLASS_SECTIONED(DERIVED_CLASS, ALIAS, TaskNode)
4647
// clang-format on
4748

4849
namespace YAML
@@ -71,7 +72,7 @@ class TaskComposerNodeFactory
7172
const TaskComposerPluginFactory& plugin_factory) const = 0;
7273

7374
protected:
74-
static const std::string SECTION_NAME;
75+
static std::string getSection();
7576
friend class PluginLoader;
7677
};
7778

@@ -88,7 +89,7 @@ class TaskComposerExecutorFactory
8889
virtual std::unique_ptr<TaskComposerExecutor> create(const std::string& name, const YAML::Node& config) const = 0;
8990

9091
protected:
91-
static const std::string SECTION_NAME;
92+
static std::string getSection();
9293
friend class PluginLoader;
9394
};
9495

tesseract_task_composer/core/include/tesseract_task_composer/core/task_composer_task_plugin_factory.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
#ifndef TESSERACT_TASK_COMPOSER_TASK_COMPOSER_TASK_PLUGIN_FACTORIES_H
2727
#define TESSERACT_TASK_COMPOSER_TASK_COMPOSER_TASK_PLUGIN_FACTORIES_H
2828

29-
#include <tesseract_common/class_loader.h>
29+
#include <boost_plugin_loader/macros.h>
3030

3131
namespace tesseract_planning
3232
{
3333
// LCOV_EXCL_START
34-
TESSERACT_PLUGIN_ANCHOR_DECL(TaskComposerTaskFactoryAnchor)
34+
PLUGIN_ANCHOR_DECL(TaskComposerTaskFactoryAnchor)
3535
// LCOV_EXCL_STOP
3636
} // namespace tesseract_planning
3737

tesseract_task_composer/core/src/task_composer_plugin_factory.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,32 @@ TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
3131
TESSERACT_COMMON_IGNORE_WARNINGS_POP
3232

3333
#include <tesseract_common/resource_locator.h>
34-
#include <tesseract_common/plugin_loader.h>
3534
#include <tesseract_common/yaml_utils.h>
3635
#include <tesseract_common/yaml_extenstions.h>
3736
#include <tesseract_task_composer/core/task_composer_plugin_factory.h>
3837
#include <tesseract_task_composer/core/task_composer_node.h>
3938
#include <tesseract_task_composer/core/task_composer_executor.h>
39+
#include <boost_plugin_loader/plugin_loader.hpp>
40+
#include <boost/algorithm/string.hpp>
41+
#include <console_bridge/console.h>
4042

4143
static const std::string TESSERACT_TASK_COMPOSER_PLUGIN_DIRECTORIES_ENV = "TESSERACT_TASK_COMPOSER_PLUGIN_"
4244
"DIRECTORIES";
4345
static const std::string TESSERACT_TASK_COMPOSER_PLUGINS_ENV = "TESSERACT_TASK_COMPOSER_PLUGINS";
4446

4547
namespace tesseract_planning
4648
{
47-
const std::string TaskComposerExecutorFactory::SECTION_NAME = "TaskExec";
48-
const std::string TaskComposerNodeFactory::SECTION_NAME = "TaskNode";
49+
std::string TaskComposerExecutorFactory::getSection() { return "TaskExec"; }
50+
51+
std::string TaskComposerNodeFactory::getSection() { return "TaskNode"; }
4952

5053
struct TaskComposerPluginFactory::Implementation
5154
{
5255
mutable std::map<std::string, TaskComposerExecutorFactory::Ptr> executor_factories;
5356
mutable std::map<std::string, TaskComposerNodeFactory::Ptr> node_factories;
5457
tesseract_common::PluginInfoContainer executor_plugin_info;
5558
tesseract_common::PluginInfoContainer task_plugin_info;
56-
tesseract_common::PluginLoader plugin_loader;
59+
boost_plugin_loader::PluginLoader plugin_loader;
5760
};
5861

5962
TaskComposerPluginFactory::TaskComposerPluginFactory() : impl_(std::make_unique<Implementation>())
@@ -303,7 +306,7 @@ TaskComposerPluginFactory::createTaskComposerExecutor(const std::string& name,
303306
if (it != executor_factories.end())
304307
return it->second->create(name, plugin_info.config);
305308

306-
auto plugin = impl_->plugin_loader.instantiate<TaskComposerExecutorFactory>(plugin_info.class_name);
309+
auto plugin = impl_->plugin_loader.createInstance<TaskComposerExecutorFactory>(plugin_info.class_name);
307310
if (plugin == nullptr)
308311
{
309312
CONSOLE_BRIDGE_logWarn("Failed to load symbol '%s'", plugin_info.class_name.c_str());
@@ -345,7 +348,7 @@ TaskComposerPluginFactory::createTaskComposerNode(const std::string& name,
345348
if (it != node_factories.end())
346349
return it->second->create(name, plugin_info.config, *this);
347350

348-
auto plugin = impl_->plugin_loader.instantiate<TaskComposerNodeFactory>(plugin_info.class_name);
351+
auto plugin = impl_->plugin_loader.createInstance<TaskComposerNodeFactory>(plugin_info.class_name);
349352
if (plugin == nullptr)
350353
{
351354
CONSOLE_BRIDGE_logWarn("Failed to load symbol '%s'", plugin_info.class_name.c_str());

tesseract_task_composer/core/src/task_composer_task_plugin_factory.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
#include <tesseract_task_composer/core/nodes/sync_task.h>
3838
#include <tesseract_task_composer/core/test_suite/test_task.h>
3939

40+
#include <boost_plugin_loader/macros.h>
41+
4042
namespace tesseract_planning
4143
{
4244
using DoneTaskFactory = TaskComposerTaskFactory<DoneTask>;
@@ -49,7 +51,7 @@ using GraphTaskFactory = TaskComposerTaskFactory<TaskComposerGraph>;
4951
using PipelineTaskFactory = TaskComposerTaskFactory<TaskComposerPipeline>;
5052

5153
// LCOV_EXCL_START
52-
TESSERACT_PLUGIN_ANCHOR_IMPL(TaskComposerTaskFactoryAnchor)
54+
PLUGIN_ANCHOR_IMPL(TaskComposerTaskFactoryAnchor)
5355
// LCOV_EXCL_STOP
5456

5557
} // namespace tesseract_planning

tesseract_task_composer/package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<depend>tesseract_command_language</depend>
1919
<depend>tesseract_motion_planners</depend>
2020
<depend>tesseract_time_parameterization</depend>
21+
<depend>boost_plugin_loader</depend>
2122
<depend>taskflow</depend>
2223

2324
<build_depend>eigen</build_depend>

tesseract_task_composer/planning/include/tesseract_task_composer/planning/planning_task_composer_plugin_factories.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
#ifndef TESSERACT_TASK_COMPOSER_PLANNING_TASK_COMPOSER_PLUGIN_FACTORIES_H
2727
#define TESSERACT_TASK_COMPOSER_PLANNING_TASK_COMPOSER_PLUGIN_FACTORIES_H
2828

29-
#include <tesseract_common/class_loader.h>
29+
#include <boost_plugin_loader/macros.h>
3030

3131
namespace tesseract_planning
3232
{
3333
// LCOV_EXCL_START
34-
TESSERACT_PLUGIN_ANCHOR_DECL(TaskComposerPlanningFactoriesAnchor)
34+
PLUGIN_ANCHOR_DECL(TaskComposerPlanningFactoriesAnchor)
3535
// LCOV_EXCL_STOP
3636
} // namespace tesseract_planning
3737

tesseract_task_composer/planning/src/factories/planning_task_composer_core_plugin_factories.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444

4545
#include <tesseract_motion_planners/simple/simple_motion_planner.h>
4646

47+
#include <boost_plugin_loader/macros.h>
48+
4749
namespace tesseract_planning
4850
{
4951
using ContinuousContactCheckTaskFactory = TaskComposerTaskFactory<ContinuousContactCheckTask>;
@@ -62,7 +64,7 @@ using SimpleMotionPlannerTaskFactory = TaskComposerTaskFactory<MotionPlannerTask
6264
using ProcessPlanningInputTaskFactory = TaskComposerTaskFactory<ProcessPlanningInputTask>;
6365

6466
// LCOV_EXCL_START
65-
TESSERACT_PLUGIN_ANCHOR_IMPL(TaskComposerPlanningFactoriesAnchor)
67+
PLUGIN_ANCHOR_IMPL(TaskComposerPlanningFactoriesAnchor)
6668
// LCOV_EXCL_STOP
6769

6870
} // namespace tesseract_planning

tesseract_task_composer/taskflow/include/tesseract_task_composer/taskflow/taskflow_task_composer_plugin_factories.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
#ifndef TESSERACT_TASK_COMPOSER_TASKFLOW_TASK_COMPOSER_PLUGIN_FACTORIES_H
2727
#define TESSERACT_TASK_COMPOSER_TASKFLOW_TASK_COMPOSER_PLUGIN_FACTORIES_H
2828

29-
#include <tesseract_common/class_loader.h>
29+
#include <boost_plugin_loader/macros.h>
3030

3131
namespace tesseract_planning
3232
{
3333
// LCOV_EXCL_START
34-
TESSERACT_PLUGIN_ANCHOR_DECL(TaskComposerTaskflowFactoriesAnchor)
34+
PLUGIN_ANCHOR_DECL(TaskComposerTaskflowFactoriesAnchor)
3535
// LCOV_EXCL_STOP
3636
} // namespace tesseract_planning
3737

0 commit comments

Comments
 (0)