Skip to content

Commit

Permalink
Add boost serialization support to Profile dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
Levi-Armstrong committed Jul 24, 2024
1 parent 6b2d7c8 commit d307c66
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 5 deletions.
1 change: 1 addition & 0 deletions tesseract_command_language/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
#include <shared_mutex>
TESSERACT_COMMON_IGNORE_WARNINGS_POP

#include <tesseract_common/any_poly.h>

namespace tesseract_planning
{
/**
Expand Down Expand Up @@ -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<std::string, std::unordered_map<std::type_index, std::any>> profiles_;
mutable std::shared_mutex mutex_;

friend class boost::serialization::access;
template <class Archive>
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<tesseract_planning::ProfileDictionary>,
TesseractPlanningProfileDictionarySharedPtr)

#endif // TESSERACT_MOTION_PLANNERS_PROFILE_DICTIONARY_H
48 changes: 48 additions & 0 deletions tesseract_command_language/src/profile_dictionary.cpp
Original file line number Diff line number Diff line change
@@ -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 <tesseract_command_language/profile_dictionary.h>
#include <boost/serialization/shared_ptr.hpp>

namespace tesseract_planning
{
void ProfileDictionary::clear()
{
std::unique_lock lock(mutex_);
profiles_.clear();
}

template <class Archive>
void ProfileDictionary::serialize(Archive& /*ar*/, const unsigned int /*version*/)
{
}

} // namespace tesseract_planning

#include <tesseract_common/serialization.h>
BOOST_CLASS_EXPORT_IMPLEMENT(tesseract_planning::ProfileDictionary)
TESSERACT_SERIALIZE_ARCHIVES_INSTANTIATE(tesseract_planning::ProfileDictionary)
TESSERACT_ANY_EXPORT_IMPLEMENT(TesseractPlanningProfileDictionarySharedPtr)

0 comments on commit d307c66

Please sign in to comment.