Skip to content

Commit

Permalink
Simplify profile dictionary by remove profile key and only leverage n…
Browse files Browse the repository at this point in the history
…amespace
  • Loading branch information
Levi-Armstrong committed Dec 7, 2024
1 parent 2b16c84 commit fb7f179
Show file tree
Hide file tree
Showing 36 changed files with 666 additions and 970 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,21 @@

namespace tesseract_planning
{
/**
* @brief The Profile class
*/
/** @brief The Profile class */
class Profile
{
public:
using Ptr = std::shared_ptr<Profile>;
using ConstPtr = std::shared_ptr<const Profile>;

Profile() = default;
Profile(std::size_t key);
Profile(const Profile&) = delete;
Profile& operator=(const Profile&) = delete;
Profile(Profile&&) = delete;
Profile&& operator=(Profile&&) = delete;
virtual ~Profile() = default;

/**
* @brief Get the hash code associated with the profile
* @return The profile's hash code
*/
std::size_t getKey() const;

protected:
std::size_t key_{ 0 };
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive&, const unsigned int); // NOLINT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,61 +69,54 @@ class ProfileDictionary
/**
* @brief Check if a profile exists
* @details If profile entry does not exist it also returns false
* @param key The profile key
* @param ns The profile namespace
* @param profile_name The profile name
* @return True if profile exists, otherwise false
*/
bool hasProfile(std::size_t key, const std::string& ns, const std::string& profile_name) const;
bool hasProfile(const std::string& ns, const std::string& profile_name) const;

/**
* @brief Get a profile by name
* @details Check if the profile exist before calling this function, if missing an exception is thrown
* @param key The profile key
* @param ns The profile namespace
* @param profile_name The profile name
* @return The profile
*/
Profile::ConstPtr getProfile(std::size_t key, const std::string& ns, const std::string& profile_name) const;
Profile::ConstPtr getProfile(const std::string& ns, const std::string& profile_name) const;

/**
* @brief Remove a profile
* @param key The profile key
* @param ns The profile namespace
* @param profile_name The profile to be removed
*/
void removeProfile(std::size_t key, const std::string& ns, const std::string& profile_name);
void removeProfile(const std::string& ns, const std::string& profile_name);

/**
* @brief Check if a profile entry exists
* @param key The profile key
* @param ns The profile namespace
* @return True if exists, otherwise false
*/
bool hasProfileEntry(std::size_t key, const std::string& ns) const;
bool hasProfileEntry(const std::string& ns) const;

/**
* @brief Remove a profile entry
* @param key The profile key
* @param ns The profile namespace
*/
void removeProfileEntry(std::size_t key, const std::string& ns);
void removeProfileEntry(const std::string& ns);

/**
* @brief Get a profile entry
* @param key The profile key
* @param ns The profile namespace
* @return The profile map associated with the profile entry
*/
std::unordered_map<std::string, Profile::ConstPtr> getProfileEntry(std::size_t key, const std::string& ns) const;
std::unordered_map<std::string, Profile::ConstPtr> getProfileEntry(const std::string& ns) const;

/** @brief Clear the dictionary */
void clear();

protected:
mutable std::shared_mutex mutex_;
std::unordered_map<std::string, std::unordered_map<std::size_t, std::unordered_map<std::string, Profile::ConstPtr>>>
profiles_;
std::unordered_map<std::string, std::unordered_map<std::string, Profile::ConstPtr>> profiles_;

friend class boost::serialization::access;
template <class Archive>
Expand Down
Loading

0 comments on commit fb7f179

Please sign in to comment.