This class is used to store profiles used by various tasks. More...
#include <profile_dictionary.h>
Public Types | |
using | ConstPtr = std::shared_ptr< const ProfileDictionary > |
using | Ptr = std::shared_ptr< ProfileDictionary > |
Public Member Functions | |
void | addProfile (const std::string &ns, const std::string &profile_name, const Profile::ConstPtr &profile) |
Add a profile. More... | |
void | addProfile (const std::string &ns, const std::vector< std::string > &profile_names, const Profile::ConstPtr &profile) |
void | clear () |
Clear the dictionary. More... | |
std::unordered_map< std::string, std::unordered_map< std::size_t, std::unordered_map< std::string, Profile::ConstPtr > > > | getAllProfileEntries () const |
Get all profile entries. More... | |
template<typename ProfileType > | |
std::shared_ptr< const ProfileType > | getProfile (const std::string &ns, const std::string &profile_name, std::shared_ptr< const ProfileType > default_profile=nullptr) const |
Gets the profile specified from the profile map. More... | |
Profile::ConstPtr | getProfile (std::size_t key, const std::string &ns, const std::string &profile_name) const |
Get a profile by name. More... | |
std::unordered_map< std::string, Profile::ConstPtr > | getProfileEntry (std::size_t key, const std::string &ns) const |
Get a profile entry. More... | |
bool | hasProfile (std::size_t key, const std::string &ns, const std::string &profile_name) const |
Check if a profile exists. More... | |
bool | hasProfileEntry (std::size_t key, const std::string &ns) const |
Check if a profile entry exists. More... | |
ProfileDictionary & | operator= (const ProfileDictionary &) |
ProfileDictionary & | operator= (ProfileDictionary &&) noexcept |
ProfileDictionary ()=default | |
ProfileDictionary (const ProfileDictionary &) | |
ProfileDictionary (ProfileDictionary &&) noexcept | |
void | removeProfile (std::size_t key, const std::string &ns, const std::string &profile_name) |
Remove a profile. More... | |
void | removeProfileEntry (std::size_t key, const std::string &ns) |
Remove a profile entry. More... | |
~ProfileDictionary ()=default | |
Protected Attributes | |
std::shared_mutex | mutex_ |
std::unordered_map< std::string, std::unordered_map< std::size_t, std::unordered_map< std::string, Profile::ConstPtr > > > | profiles_ |
Private Member Functions | |
template<class Archive > | |
void | serialize (Archive &ar, const unsigned int version) |
Friends | |
class | boost::serialization::access |
struct | tesseract_common::Serialization |
This class is used to store profiles used by various tasks.
This is a thread safe class
Definition at line 46 of file profile_dictionary.h.
using tesseract_common::ProfileDictionary::ConstPtr = std::shared_ptr<const ProfileDictionary> |
Definition at line 50 of file profile_dictionary.h.
using tesseract_common::ProfileDictionary::Ptr = std::shared_ptr<ProfileDictionary> |
Definition at line 49 of file profile_dictionary.h.
|
default |
|
default |
tesseract_common::ProfileDictionary::ProfileDictionary | ( | const ProfileDictionary & | other | ) |
Definition at line 37 of file profile_dictionary.cpp.
|
noexcept |
Definition at line 58 of file profile_dictionary.cpp.
void tesseract_common::ProfileDictionary::addProfile | ( | const std::string & | ns, |
const std::string & | profile_name, | ||
const Profile::ConstPtr & | profile | ||
) |
Add a profile.
If the profile entry does not exist it will create one
ns | The profile namespace |
profile_name | The profile name |
profile | The profile to add |
Definition at line 124 of file profile_dictionary.cpp.
void tesseract_common::ProfileDictionary::addProfile | ( | const std::string & | ns, |
const std::vector< std::string > & | profile_names, | ||
const Profile::ConstPtr & | profile | ||
) |
Definition at line 161 of file profile_dictionary.cpp.
void tesseract_common::ProfileDictionary::clear | ( | ) |
Clear the dictionary.
Definition at line 261 of file profile_dictionary.cpp.
std::unordered_map< std::string, std::unordered_map< std::size_t, std::unordered_map< std::string, Profile::ConstPtr > > > tesseract_common::ProfileDictionary::getAllProfileEntries | ( | ) | const |
Get all profile entries.
Definition at line 118 of file profile_dictionary.cpp.
|
inline |
Gets the profile specified from the profile map.
ns | The profile namespace |
profile_name | The profile name |
default_profile | Profile that is returned if the requested profile is not found. Default = nullptr |
Definition at line 99 of file profile_dictionary.h.
Profile::ConstPtr tesseract_common::ProfileDictionary::getProfile | ( | std::size_t | key, |
const std::string & | ns, | ||
const std::string & | profile_name | ||
) | const |
Get a profile by name.
Check if the profile exist before calling this function, if missing an exception is thrown
key | The profile key |
ns | The profile namespace |
profile_name | The profile name |
Definition at line 233 of file profile_dictionary.cpp.
std::unordered_map< std::string, Profile::ConstPtr > tesseract_common::ProfileDictionary::getProfileEntry | ( | std::size_t | key, |
const std::string & | ns | ||
) | const |
Get a profile entry.
key | The profile key |
ns | The profile namespace |
Definition at line 101 of file profile_dictionary.cpp.
bool tesseract_common::ProfileDictionary::hasProfile | ( | std::size_t | key, |
const std::string & | ns, | ||
const std::string & | profile_name | ||
) | const |
Check if a profile exists.
If profile entry does not exist it also returns false
key | The profile key |
ns | The profile namespace |
profile_name | The profile name |
Definition at line 216 of file profile_dictionary.cpp.
bool tesseract_common::ProfileDictionary::hasProfileEntry | ( | std::size_t | key, |
const std::string & | ns | ||
) | const |
Check if a profile entry exists.
key | The profile key |
ns | The profile namespace |
Definition at line 78 of file profile_dictionary.cpp.
ProfileDictionary & tesseract_common::ProfileDictionary::operator= | ( | const ProfileDictionary & | other | ) |
Definition at line 47 of file profile_dictionary.cpp.
|
noexcept |
Definition at line 68 of file profile_dictionary.cpp.
void tesseract_common::ProfileDictionary::removeProfile | ( | std::size_t | key, |
const std::string & | ns, | ||
const std::string & | profile_name | ||
) |
Remove a profile.
key | The profile key |
ns | The profile namespace |
profile_name | The profile to be removed |
Definition at line 241 of file profile_dictionary.cpp.
void tesseract_common::ProfileDictionary::removeProfileEntry | ( | std::size_t | key, |
const std::string & | ns | ||
) |
Remove a profile entry.
key | The profile key |
ns | The profile namespace |
Definition at line 88 of file profile_dictionary.cpp.
|
private |
Definition at line 268 of file profile_dictionary.cpp.
|
friend |
Definition at line 156 of file profile_dictionary.h.
|
friend |
Definition at line 157 of file profile_dictionary.h.
|
mutableprotected |
Definition at line 151 of file profile_dictionary.h.
|
protected |
Definition at line 153 of file profile_dictionary.h.