mirror of
https://github.com/moveit/moveit_task_constructor.git
synced 2025-11-04 14:49:57 +08:00
Container::remove(): return removed Stage
This commit is contained in:
parent
e9c56c9c64
commit
4089d5eefa
@ -65,8 +65,8 @@ public:
|
||||
void add(Stage::pointer&& stage);
|
||||
|
||||
virtual bool insert(Stage::pointer&& stage, int before = -1);
|
||||
virtual bool remove(int pos);
|
||||
virtual bool remove(Stage* child);
|
||||
virtual Stage::pointer remove(int pos);
|
||||
virtual Stage::pointer remove(Stage* child);
|
||||
virtual void clear();
|
||||
|
||||
void reset() override;
|
||||
|
||||
@ -89,7 +89,7 @@ public:
|
||||
const_iterator childByIndex(int index, bool for_insert = false) const;
|
||||
|
||||
/// remove child at given iterator position, returns fals if pos is invalid
|
||||
bool remove(ContainerBasePrivate::const_iterator pos);
|
||||
Stage::pointer remove(ContainerBasePrivate::const_iterator pos);
|
||||
|
||||
/// traversing all stages up to max_depth
|
||||
bool traverseStages(const ContainerBase::StageCallback& processor, unsigned int cur_depth,
|
||||
|
||||
@ -204,20 +204,21 @@ bool ContainerBase::insert(Stage::pointer&& stage, int before) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContainerBasePrivate::remove(ContainerBasePrivate::const_iterator pos) {
|
||||
Stage::pointer ContainerBasePrivate::remove(ContainerBasePrivate::const_iterator pos) {
|
||||
if (pos == children_.end())
|
||||
return false;
|
||||
return Stage::pointer();
|
||||
|
||||
(*pos)->pimpl()->unparent();
|
||||
children_.erase(pos);
|
||||
return true;
|
||||
Stage::pointer result = std::move(*children_.erase(pos, pos)); // stage from non-const iterator to pos
|
||||
children_.erase(pos); // actually erase stage
|
||||
return result;
|
||||
}
|
||||
|
||||
bool ContainerBase::remove(int pos) {
|
||||
Stage::pointer ContainerBase::remove(int pos) {
|
||||
return pimpl()->remove(pimpl()->childByIndex(pos, false));
|
||||
}
|
||||
|
||||
bool ContainerBase::remove(Stage* child) {
|
||||
Stage::pointer ContainerBase::remove(Stage* child) {
|
||||
auto it = pimpl()->children_.begin(), end = pimpl()->children_.end();
|
||||
for (; it != end && it->get() != child; ++it)
|
||||
;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user