From d307c66f22c06e1d08017a45708d8fde04f7bb72 Mon Sep 17 00:00:00 2001 From: Levi Armstrong Date: Tue, 23 Jul 2024 15:54:32 -0500 Subject: [PATCH] Add boost serialization support to Profile dictionary --- tesseract_command_language/CMakeLists.txt | 1 + .../profile_dictionary.h | 16 +++++-- .../src/profile_dictionary.cpp | 48 +++++++++++++++++++ 3 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 tesseract_command_language/src/profile_dictionary.cpp diff --git a/tesseract_command_language/CMakeLists.txt b/tesseract_command_language/CMakeLists.txt index 5ff098e29c..b2db2633c0 100644 --- a/tesseract_command_language/CMakeLists.txt +++ b/tesseract_command_language/CMakeLists.txt @@ -48,6 +48,7 @@ add_library( src/poly/state_waypoint_poly.cpp src/poly/waypoint_poly.cpp src/move_instruction.cpp + src/profile_dictionary.cpp src/set_analog_instruction.cpp src/set_tool_instruction.cpp src/timer_instruction.cpp diff --git a/tesseract_command_language/include/tesseract_command_language/profile_dictionary.h b/tesseract_command_language/include/tesseract_command_language/profile_dictionary.h index 44b20becc2..0e3fb693b5 100644 --- a/tesseract_command_language/include/tesseract_command_language/profile_dictionary.h +++ b/tesseract_command_language/include/tesseract_command_language/profile_dictionary.h @@ -36,6 +36,8 @@ TESSERACT_COMMON_IGNORE_WARNINGS_PUSH #include TESSERACT_COMMON_IGNORE_WARNINGS_POP +#include + namespace tesseract_planning { /** @@ -216,16 +218,20 @@ class ProfileDictionary } /** @brief Clear the dictionary */ - void clear() - { - std::unique_lock lock(mutex_); - profiles_.clear(); - } + void clear(); protected: std::unordered_map> profiles_; mutable std::shared_mutex mutex_; + + friend class boost::serialization::access; + template + void serialize(Archive& ar, const unsigned int version); // NOLINT }; } // namespace tesseract_planning +BOOST_CLASS_EXPORT_KEY(tesseract_planning::ProfileDictionary) +TESSERACT_ANY_EXPORT_KEY(std::shared_ptr, + TesseractPlanningProfileDictionarySharedPtr) + #endif // TESSERACT_MOTION_PLANNERS_PROFILE_DICTIONARY_H diff --git a/tesseract_command_language/src/profile_dictionary.cpp b/tesseract_command_language/src/profile_dictionary.cpp new file mode 100644 index 0000000000..b1305ef10f --- /dev/null +++ b/tesseract_command_language/src/profile_dictionary.cpp @@ -0,0 +1,48 @@ +/** + * @file profile_dictionary.cpp + * @brief This is a profile dictionary for storing all profiles + * + * @author Levi Armstrong + * @date December 2, 2020 + * @version TODO + * @bug No known bugs + * + * @copyright Copyright (c) 2020, Southwest Research Institute + * + * @par License + * Software License Agreement (Apache License) + * @par + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * @par + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +namespace tesseract_planning +{ +void ProfileDictionary::clear() +{ + std::unique_lock lock(mutex_); + profiles_.clear(); +} + +template +void ProfileDictionary::serialize(Archive& /*ar*/, const unsigned int /*version*/) +{ +} + +} // namespace tesseract_planning + +#include +BOOST_CLASS_EXPORT_IMPLEMENT(tesseract_planning::ProfileDictionary) +TESSERACT_SERIALIZE_ARCHIVES_INSTANTIATE(tesseract_planning::ProfileDictionary) +TESSERACT_ANY_EXPORT_IMPLEMENT(TesseractPlanningProfileDictionarySharedPtr)