Task: only accept containers

This commit is contained in:
Robert Haschke 2018-05-17 17:30:24 +02:00
parent e3ca832497
commit 19fa7349d3
5 changed files with 7 additions and 6 deletions

View File

@ -48,6 +48,7 @@ class ContainerBase : public Stage
{ {
public: public:
PRIVATE_CLASS(ContainerBase) PRIVATE_CLASS(ContainerBase)
typedef std::unique_ptr<ContainerBase> pointer;
size_t numChildren() const; size_t numChildren() const;
@ -227,7 +228,7 @@ class WrapperBase : public ParallelContainerBase
{ {
public: public:
PRIVATE_CLASS(WrapperBase) PRIVATE_CLASS(WrapperBase)
WrapperBase(const std::string &name, pointer &&child = Stage::pointer()); WrapperBase(const std::string &name, Stage::pointer &&child = Stage::pointer());
/// insertion is only allowed if children() is empty /// insertion is only allowed if children() is empty
bool insert(Stage::pointer&& stage, int before = -1) override; bool insert(Stage::pointer&& stage, int before = -1) override;
@ -242,7 +243,7 @@ public:
bool compute() override; bool compute() override;
protected: protected:
WrapperBase(WrapperBasePrivate* impl, pointer &&child = Stage::pointer()); WrapperBase(WrapperBasePrivate* impl, Stage::pointer &&child = Stage::pointer());
/// called by a (direct) child when a new solution becomes available /// called by a (direct) child when a new solution becomes available
void onNewSolution(const SolutionBase &s) override = 0; void onNewSolution(const SolutionBase &s) override = 0;

View File

@ -60,7 +60,7 @@ namespace moveit { namespace task_constructor { namespace stages {
*/ */
class ComputeIK : public WrapperBase { class ComputeIK : public WrapperBase {
public: public:
ComputeIK(const std::string &name, pointer &&child = Stage::pointer()); ComputeIK(const std::string &name, Stage::pointer &&child = Stage::pointer());
void init(const core::RobotModelConstPtr &robot_model); void init(const core::RobotModelConstPtr &robot_model);
void onNewSolution(const SolutionBase &s) override; void onNewSolution(const SolutionBase &s) override;

View File

@ -70,7 +70,7 @@ public:
const std::string &planning_plugin_param_name = "planning_plugin", const std::string &planning_plugin_param_name = "planning_plugin",
const std::string &adapter_plugins_param_name = "request_adapters"); const std::string &adapter_plugins_param_name = "request_adapters");
Task(const std::string& id = "", Task(const std::string& id = "",
Stage::pointer &&container = std::make_unique<SerialContainer>("task pipeline")); ContainerBase::pointer &&container = std::make_unique<SerialContainer>("task pipeline"));
Task(Task &&other); Task(Task &&other);
Task& operator=(Task&& other); Task& operator=(Task&& other);
~Task(); ~Task();

View File

@ -115,7 +115,7 @@ void Task::loadRobotModel(const std::string& robot_description) {
throw Exception("Task failed to construct RobotModel"); throw Exception("Task failed to construct RobotModel");
} }
void Task::add(pointer &&stage) { void Task::add(Stage::pointer &&stage) {
if (!stage) if (!stage)
throw std::runtime_error("stage insertion failed: invalid stage pointer"); throw std::runtime_error("stage insertion failed: invalid stage pointer");

View File

@ -84,7 +84,7 @@ LocalTaskModel::LocalTaskModel(QObject *parent)
flags_ |= LOCAL_MODEL; flags_ |= LOCAL_MODEL;
} }
LocalTaskModel::LocalTaskModel(Stage::pointer &&container, QObject *parent) LocalTaskModel::LocalTaskModel(ContainerBase::pointer &&container, QObject *parent)
: BaseTaskModel(parent) : BaseTaskModel(parent)
, Task("", std::move(container)) , Task("", std::move(container))
{ {