Skip to content

Commit

Permalink
accept const-refs in liftModifiedSolution
Browse files Browse the repository at this point in the history
clang-tidy rightfully complained that moving rvalues doesn't make
sense when the underlying method accepts const refs.

The rvalue parameter interface, as it is used with spawn/etc. indicates
that the solution is submitted to the system. But with the shared_ptr interface
we need for `liftModifiedSolution` it does not make any sense, especially because
we can't even move the passed pointer to the internal datastructures but have to copy...
  • Loading branch information
v4hn committed Jun 8, 2021
1 parent 301ea16 commit 6299110
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
6 changes: 3 additions & 3 deletions core/include/moveit/task_constructor/container.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ class ParallelContainerBase : public ContainerBase
void liftSolution(const SolutionBase& solution, double cost, std::string comment);

/// lift a modified solution based on the solution of a child stage
void liftModifiedSolution(SolutionBasePtr&& new_solution, const SolutionBase& child_solution);
void liftModifiedSolution(const SolutionBasePtr& new_solution, const SolutionBase& child_solution);
/// lift a modified solution, changing the (single!) new associated start or end InterfaceState
void liftModifiedSolution(SolutionBasePtr&& new_solution, InterfaceState&& new_propagated_state,
void liftModifiedSolution(const SolutionBasePtr& new_solution, InterfaceState&& new_propagated_state,
const SolutionBase& child_solution);
/// lift a modified solution, providing new start and end states
/// The new states will only be used if this's should actually create the corresponding states
void liftModifiedSolution(SolutionBasePtr&& new_solution, InterfaceState&& new_start_state,
void liftModifiedSolution(const SolutionBasePtr& new_solution, InterfaceState&& new_start_state,
InterfaceState&& new_end_state, const SolutionBase& child_solution);
};

Expand Down
15 changes: 7 additions & 8 deletions core/src/container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -782,35 +782,34 @@ void ParallelContainerBase::liftSolution(const SolutionBase& solution, double co
solution.start(), solution.end());
}

void ParallelContainerBase::liftModifiedSolution(SolutionBasePtr&& modified_solution, const SolutionBase& child_solution) {
void ParallelContainerBase::liftModifiedSolution(const SolutionBasePtr& modified_solution, const SolutionBase& child_solution) {
// child_solution is correctly prepared by a child of this container
assert(child_solution.creator());
assert(child_solution.creator()->parent() == this);

pimpl()->liftSolution(std::move(modified_solution),
child_solution.start(), child_solution.end());
pimpl()->liftSolution(modified_solution, child_solution.start(), child_solution.end());
}

void ParallelContainerBase::liftModifiedSolution(SolutionBasePtr&& new_solution, InterfaceState&& new_propagated_state, const SolutionBase& child_solution) {
void ParallelContainerBase::liftModifiedSolution(const SolutionBasePtr& new_solution, InterfaceState&& new_propagated_state, const SolutionBase& child_solution) {
assert(child_solution.creator());
assert(child_solution.creator()->parent() == this);

if(pimpl()->requiredInterface() == GENERATE){
// in this case we need a second InterfaceState to move from
InterfaceState new_to{ new_propagated_state };
pimpl()->liftSolution(std::move(new_solution), child_solution.start(), child_solution.end(), &new_propagated_state, &new_to);
pimpl()->liftSolution(new_solution, child_solution.start(), child_solution.end(), &new_propagated_state, &new_to);
}
else {
// pass new_propagated_state as start *and* end. We know at most one will be used.
pimpl()->liftSolution(std::move(new_solution), child_solution.start(), child_solution.end(), &new_propagated_state, &new_propagated_state);
pimpl()->liftSolution(new_solution, child_solution.start(), child_solution.end(), &new_propagated_state, &new_propagated_state);
}
}

void ParallelContainerBase::liftModifiedSolution(SolutionBasePtr&& new_solution, InterfaceState&& new_from, InterfaceState&& new_to, const SolutionBase& child_solution) {
void ParallelContainerBase::liftModifiedSolution(const SolutionBasePtr& new_solution, InterfaceState&& new_from, InterfaceState&& new_to, const SolutionBase& child_solution) {
assert(child_solution.creator());
assert(child_solution.creator()->parent() == this);

pimpl()->liftSolution(std::move(new_solution), child_solution.start(), child_solution.end(), &new_from, &new_to);
pimpl()->liftSolution(new_solution, child_solution.start(), child_solution.end(), &new_from, &new_to);
}


Expand Down

0 comments on commit 6299110

Please sign in to comment.