@@ -88,6 +88,24 @@ class ProfileDictionary
8888 */
8989 Profile::ConstPtr getProfile (std::size_t key, const std::string& ns, const std::string& profile_name) const ;
9090
91+ /* *
92+ * @brief Gets the profile specified from the profile map
93+ * @param ns The profile namespace
94+ * @param profile_name The profile name
95+ * @param default_profile Profile that is returned if the requested profile is not found. Default = nullptr
96+ * @return The profile requested if found. Otherwise the default_profile
97+ */
98+ template <typename ProfileType>
99+ std::shared_ptr<const ProfileType> getProfile (const std::string& ns,
100+ const std::string& profile_name,
101+ std::shared_ptr<const ProfileType> default_profile = nullptr ) const
102+ {
103+ if (hasProfile (ProfileType::getStaticKey (), ns, profile_name))
104+ return std::static_pointer_cast<const ProfileType>(getProfile (ProfileType::getStaticKey (), ns, profile_name));
105+
106+ return default_profile;
107+ }
108+
91109 /* *
92110 * @brief Remove a profile
93111 * @param key The profile key
@@ -142,6 +160,7 @@ class ProfileDictionary
142160};
143161
144162using ProfileDictionaryPtrAnyPoly = tesseract_common::AnyWrapper<std::shared_ptr<ProfileDictionary>>;
163+
145164} // namespace tesseract_common
146165
147166BOOST_CLASS_EXPORT_KEY (tesseract_common::ProfileDictionary)
0 commit comments