Tesseract 0.28.4
Loading...
Searching...
No Matches
tesseract::common::ProfileDictionary Class Reference

This class is used to store profiles used by various tasks. More...

#include <profile_dictionary.h>

Public Types

using Ptr = std::shared_ptr<ProfileDictionary>
using ConstPtr = std::shared_ptr<const ProfileDictionary>

Public Member Functions

 ProfileDictionary (const ProfileDictionary &)
ProfileDictionary & operator= (const ProfileDictionary &)
 ProfileDictionary (ProfileDictionary &&) noexcept
ProfileDictionary & operator= (ProfileDictionary &&) noexcept
void addProfile (const std::string &ns, const std::string &profile_name, const Profile::ConstPtr &profile)
 Add a profile.
void addProfile (const std::string &ns, const std::vector< std::string > &profile_names, const Profile::ConstPtr &profile)
bool hasProfile (std::size_t key, const std::string &ns, const std::string &profile_name) const
 Check if a profile exists.
Profile::ConstPtr getProfile (std::size_t key, const std::string &ns, const std::string &profile_name) const
 Get a profile by name.
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.
void removeProfile (std::size_t key, const std::string &ns, const std::string &profile_name)
 Remove a profile.
bool hasProfileEntry (std::size_t key, const std::string &ns) const
 Check if a profile entry exists.
void removeProfileEntry (std::size_t key, const std::string &ns)
 Remove a profile entry.
std::unordered_map< std::string, Profile::ConstPtr > getProfileEntry (std::size_t key, const std::string &ns) const
 Get a profile entry.
std::unordered_map< std::string, std::unordered_map< std::size_t, std::unordered_map< std::string, Profile::ConstPtr > > > getAllProfileEntries () const
 Get all profile entries.
void clear ()
 Clear the dictionary.

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_

Friends

template<class Archive>
friend void::tesseract::common::serialize (Archive &ar, ProfileDictionary &obj)

Detailed Description

This class is used to store profiles used by various tasks.

This is a thread safe class

Member Function Documentation

◆ addProfile()

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

◆ 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

◆ getProfile() [1/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

◆ getProfile() [2/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

◆ 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

◆ 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

◆ 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

◆ 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

◆ 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