Public Types | Public Member Functions | Protected Attributes | Private Member Functions | Friends | List of all members
tesseract_common::ProfileDictionary Class Reference

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::ConstPtrgetProfileEntry (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...
 
ProfileDictionaryoperator= (const ProfileDictionary &)
 
ProfileDictionaryoperator= (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
 

Detailed Description

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.

Member Typedef Documentation

◆ ConstPtr

Definition at line 50 of file profile_dictionary.h.

◆ Ptr

Definition at line 49 of file profile_dictionary.h.

Constructor & Destructor Documentation

◆ ProfileDictionary() [1/3]

tesseract_common::ProfileDictionary::ProfileDictionary ( )
default

◆ ~ProfileDictionary()

tesseract_common::ProfileDictionary::~ProfileDictionary ( )
default

◆ ProfileDictionary() [2/3]

tesseract_common::ProfileDictionary::ProfileDictionary ( const ProfileDictionary other)

Definition at line 37 of file profile_dictionary.cpp.

◆ ProfileDictionary() [3/3]

tesseract_common::ProfileDictionary::ProfileDictionary ( ProfileDictionary &&  other)
noexcept

Definition at line 58 of file profile_dictionary.cpp.

Member Function Documentation

◆ addProfile() [1/2]

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

Parameters
nsThe profile namespace
profile_nameThe profile name
profileThe profile to add

Definition at line 124 of file profile_dictionary.cpp.

◆ addProfile() [2/2]

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.

◆ clear()

void tesseract_common::ProfileDictionary::clear ( )

Clear the dictionary.

Definition at line 261 of file profile_dictionary.cpp.

◆ getAllProfileEntries()

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.

Returns
All profile entries

Definition at line 118 of file profile_dictionary.cpp.

◆ getProfile() [1/2]

template<typename ProfileType >
std::shared_ptr<const ProfileType> tesseract_common::ProfileDictionary::getProfile ( const std::string &  ns,
const std::string &  profile_name,
std::shared_ptr< const ProfileType >  default_profile = nullptr 
) const
inline

Gets the profile specified from the profile map.

Parameters
nsThe profile namespace
profile_nameThe profile name
default_profileProfile that is returned if the requested profile is not found. Default = nullptr
Returns
The profile requested if found. Otherwise the default_profile

Definition at line 99 of file profile_dictionary.h.

◆ getProfile() [2/2]

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

Parameters
keyThe profile key
nsThe profile namespace
profile_nameThe profile name
Returns
The profile

Definition at line 233 of file profile_dictionary.cpp.

◆ getProfileEntry()

std::unordered_map< std::string, Profile::ConstPtr > tesseract_common::ProfileDictionary::getProfileEntry ( std::size_t  key,
const std::string &  ns 
) const

Get a profile entry.

Parameters
keyThe profile key
nsThe profile namespace
Returns
The profile map associated with the profile entry

Definition at line 101 of file profile_dictionary.cpp.

◆ hasProfile()

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

Parameters
keyThe profile key
nsThe profile namespace
profile_nameThe profile name
Returns
True if profile exists, otherwise false

Definition at line 216 of file profile_dictionary.cpp.

◆ hasProfileEntry()

bool tesseract_common::ProfileDictionary::hasProfileEntry ( std::size_t  key,
const std::string &  ns 
) const

Check if a profile entry exists.

Parameters
keyThe profile key
nsThe profile namespace
Returns
True if exists, otherwise false

Definition at line 78 of file profile_dictionary.cpp.

◆ operator=() [1/2]

ProfileDictionary & tesseract_common::ProfileDictionary::operator= ( const ProfileDictionary other)

Definition at line 47 of file profile_dictionary.cpp.

◆ operator=() [2/2]

ProfileDictionary & tesseract_common::ProfileDictionary::operator= ( ProfileDictionary &&  other)
noexcept

Definition at line 68 of file profile_dictionary.cpp.

◆ removeProfile()

void tesseract_common::ProfileDictionary::removeProfile ( std::size_t  key,
const std::string &  ns,
const std::string &  profile_name 
)

Remove a profile.

Parameters
keyThe profile key
nsThe profile namespace
profile_nameThe profile to be removed

Definition at line 241 of file profile_dictionary.cpp.

◆ removeProfileEntry()

void tesseract_common::ProfileDictionary::removeProfileEntry ( std::size_t  key,
const std::string &  ns 
)

Remove a profile entry.

Parameters
keyThe profile key
nsThe profile namespace

Definition at line 88 of file profile_dictionary.cpp.

◆ serialize()

template<class Archive >
void tesseract_common::ProfileDictionary::serialize ( Archive &  ar,
const unsigned int  version 
)
private

Definition at line 268 of file profile_dictionary.cpp.

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Definition at line 156 of file profile_dictionary.h.

◆ tesseract_common::Serialization

friend struct tesseract_common::Serialization
friend

Definition at line 157 of file profile_dictionary.h.

Member Data Documentation

◆ mutex_

std::shared_mutex tesseract_common::ProfileDictionary::mutex_
mutableprotected

Definition at line 151 of file profile_dictionary.h.

◆ profiles_

std::unordered_map<std::string, std::unordered_map<std::size_t, std::unordered_map<std::string, Profile::ConstPtr> > > tesseract_common::ProfileDictionary::profiles_
protected

Definition at line 153 of file profile_dictionary.h.


The documentation for this class was generated from the following files:


tesseract_common
Author(s): Levi Armstrong
autogenerated on Sun May 18 2025 03:01:40