Skip to content

Commit 9ee6534

Browse files
committed
Container: abort traversal with false return value of processor
So far, returning false from the processor function, just skipped further traversing the current child (depth-wise). Now, traversal is completely aborted, even not traversing the remaining siblings of the current child. Having a single boolean return value, we cannot distinguish both cases. We need the new behaviour for 8061945c15bea22e8f8899c987bc28e3542885aa.
1 parent 5037bc7 commit 9ee6534

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

core/include/moveit/task_constructor/container.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ class ContainerBase : public Stage
5454
size_t numChildren() const;
5555
Stage* findChild(const std::string& name) const;
5656

57+
/** Callback function type used by traverse functions
58+
* The callback should return false if traversal should be stopped. */
5759
typedef std::function<bool(const Stage&, int depth)> StageCallback;
5860
/// traverse direct children of this container, calling the callback for each of them
5961
bool traverseChildren(const StageCallback& processor) const;

core/src/container.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ bool ContainerBasePrivate::traverseStages(const ContainerBase::StageCallback& pr
8181

8282
for (auto& stage : children_) {
8383
if (!processor(*stage, cur_depth))
84-
continue;
84+
return false;
8585
const ContainerBasePrivate* container = dynamic_cast<const ContainerBasePrivate*>(stage->pimpl());
8686
if (container)
8787
container->traverseStages(processor, cur_depth + 1, max_depth);

0 commit comments

Comments
 (0)