From 24a84b1c9f70b26d4c0015448aa4cfb22f596f77 Mon Sep 17 00:00:00 2001 From: Levi Armstrong Date: Sun, 17 Sep 2023 07:53:32 -0500 Subject: [PATCH] fixup --- .../core/src/task_composer_node_info.cpp | 10 ++++++++-- .../test/tesseract_task_composer_core_unit.cpp | 7 +++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tesseract_task_composer/core/src/task_composer_node_info.cpp b/tesseract_task_composer/core/src/task_composer_node_info.cpp index 72953de1fc9..fc2c853a896 100644 --- a/tesseract_task_composer/core/src/task_composer_node_info.cpp +++ b/tesseract_task_composer/core/src/task_composer_node_info.cpp @@ -103,7 +103,9 @@ TaskComposerNodeInfoContainer::TaskComposerNodeInfoContainer(const TaskComposerN std::shared_lock rhs_lock(other.mutex_, std::defer_lock); std::scoped_lock lock{ lhs_lock, rhs_lock }; - *this = other; + aborting_node_ = other.aborting_node_; + for (const auto& pair : other.info_map_) + info_map_[pair.first] = pair.second->clone(); } TaskComposerNodeInfoContainer& TaskComposerNodeInfoContainer::operator=(const TaskComposerNodeInfoContainer& other) { @@ -111,6 +113,7 @@ TaskComposerNodeInfoContainer& TaskComposerNodeInfoContainer::operator=(const Ta std::shared_lock rhs_lock(other.mutex_, std::defer_lock); std::scoped_lock lock{ lhs_lock, rhs_lock }; + aborting_node_ = other.aborting_node_; for (const auto& pair : other.info_map_) info_map_[pair.first] = pair.second->clone(); @@ -123,7 +126,8 @@ TaskComposerNodeInfoContainer::TaskComposerNodeInfoContainer(TaskComposerNodeInf std::unique_lock rhs_lock(other.mutex_, std::defer_lock); std::scoped_lock lock{ lhs_lock, rhs_lock }; - *this = std::move(other); + aborting_node_ = other.aborting_node_; + info_map_ = std::move(other.info_map_); } TaskComposerNodeInfoContainer& TaskComposerNodeInfoContainer::operator=(TaskComposerNodeInfoContainer&& other) noexcept { @@ -131,6 +135,7 @@ TaskComposerNodeInfoContainer& TaskComposerNodeInfoContainer::operator=(TaskComp std::unique_lock rhs_lock(other.mutex_, std::defer_lock); std::scoped_lock lock{ lhs_lock, rhs_lock }; + aborting_node_ = other.aborting_node_; info_map_ = std::move(other.info_map_); return *this; @@ -252,6 +257,7 @@ template void TaskComposerNodeInfoContainer::serialize(Archive& ar, const unsigned int /*version*/) { std::unique_lock lock(mutex_); + ar& BOOST_SERIALIZATION_NVP(aborting_node_); ar& BOOST_SERIALIZATION_NVP(info_map_); } diff --git a/tesseract_task_composer/test/tesseract_task_composer_core_unit.cpp b/tesseract_task_composer/test/tesseract_task_composer_core_unit.cpp index 067d9a36c6e..d97fe267618 100644 --- a/tesseract_task_composer/test/tesseract_task_composer_core_unit.cpp +++ b/tesseract_task_composer/test/tesseract_task_composer_core_unit.cpp @@ -168,10 +168,14 @@ TEST(TesseractTaskComposerCoreUnit, TaskComposerNodeInfoContainerTests) // NOLI auto node_info = std::make_unique(node); auto node_info_container = std::make_unique(); + EXPECT_TRUE(node_info_container->getAbortingNode().is_nil()); EXPECT_TRUE(node_info_container->getInfoMap().empty()); + auto aborted_uuid = node.getUUID(); node_info_container->addInfo(std::move(node_info)); + node_info_container->setAborted(aborted_uuid); EXPECT_EQ(node_info_container->getInfoMap().size(), 1); EXPECT_TRUE(node_info_container->getInfo(node.getUUID()) != nullptr); + EXPECT_TRUE(node_info_container->getAbortingNode() == aborted_uuid); // Serialization test_suite::runSerializationPointerTest(node_info_container, "TaskComposerNodeInfoContainerTests"); @@ -180,15 +184,18 @@ TEST(TesseractTaskComposerCoreUnit, TaskComposerNodeInfoContainerTests) // NOLI auto copy_node_info_container = std::make_unique(*node_info_container); EXPECT_EQ(copy_node_info_container->getInfoMap().size(), 1); EXPECT_TRUE(copy_node_info_container->getInfo(node.getUUID()) != nullptr); + EXPECT_TRUE(copy_node_info_container->getAbortingNode() == aborted_uuid); // Move auto move_node_info_container = std::make_unique(std::move(*node_info_container)); EXPECT_EQ(move_node_info_container->getInfoMap().size(), 1); EXPECT_TRUE(move_node_info_container->getInfo(node.getUUID()) != nullptr); + EXPECT_TRUE(move_node_info_container->getAbortingNode() == aborted_uuid); move_node_info_container->clear(); EXPECT_TRUE(move_node_info_container->getInfoMap().empty()); EXPECT_TRUE(move_node_info_container->getInfo(node.getUUID()) == nullptr); + EXPECT_TRUE(move_node_info_container->getAbortingNode().is_nil()); } TEST(TesseractTaskComposerCoreUnit, TaskComposerNodeTests) // NOLINT