The Open Master Hearing Aid (openMHA)  openMHA
Open community platform for hearing aid algorithm research
MHA_AC::comm_var_map_t Class Reference

Storage class for the AC variable space. More...

Public Member Functions

bool has_key (const std::string &name) const
 Query the map if some AC variable name is present in the AC space. More...
 
void insert (const std::string &name, const comm_var_t &var)
 Create or replace variable. More...
 
void erase_by_name (const std::string &name)
 Remove variable. More...
 
void erase_by_pointer (void *ptr)
 Find variables that point to the given address. More...
 
const comm_var_tretrieve (const std::string &name) const
 Get the comm_var_t of an existing variable. More...
 
const std::vector< std::string > & get_entries () const
 
size_t size () const
 

Public Attributes

bool is_prepared = {false}
 is_prepared stores whether the provider of the AC space has entered MHA state "prepared" or not. More...
 

Private Member Functions

void update_entries ()
 Update the member variable entries because an AC variable has been inserted or removed. More...
 

Private Attributes

std::map< std::string, comm_var_tmap
 The std::map used for organizing the AC space. More...
 
std::vector< std::string > entries
 A list containing the names of all AC variables. More...
 

Detailed Description

Storage class for the AC variable space.

Uses an std::map for associating AC variable names with AC variable metadata (comm_var_t). Acts as a delegator for the std::map storage. Allows operations that may require memory allocations/deallocations only when is_prepared == false.

Member Function Documentation

◆ update_entries()

void MHA_AC::comm_var_map_t::update_entries ( )
private

Update the member variable entries because an AC variable has been inserted or removed.

Only permitted if is_prepared == false.

◆ has_key()

bool MHA_AC::comm_var_map_t::has_key ( const std::string &  name) const
inline

Query the map if some AC variable name is present in the AC space.

Parameters
nameName of AC variable to check.
Returns
true if the variable is present in the AC space.
false if no variable with this name exists in the AC space.

◆ insert()

void MHA_AC::comm_var_map_t::insert ( const std::string &  name,
const comm_var_t var 
)

Create or replace variable.

Creating is only permitted if is_prepared == false.

Parameters
nameName of the AC variable to create or update. May not be empty. Must not contain space character.
varMetadata of the AC variable.
Exceptions
MHA_Errorif asked to create in prepared state.
MHA_Errorif name is emtpy or contains space.

◆ erase_by_name()

void MHA_AC::comm_var_map_t::erase_by_name ( const std::string &  name)

Remove variable.

Only permitted if is_prepared == false.

Parameters
nameName of the AC variable to remove.
Exceptions
MHA_Errorif called while prepared.

◆ erase_by_pointer()

void MHA_AC::comm_var_map_t::erase_by_pointer ( void *  ptr)

Find variables that point to the given address.

Erase all that are found. It is not an error if no variable points there. Only permitted if is_prepared == false. @ptr Pointer to memory where the variables data is stored.

Exceptions
MHA_Errorif called while prepared.

◆ retrieve()

const MHA_AC::comm_var_t & MHA_AC::comm_var_map_t::retrieve ( const std::string &  name) const

Get the comm_var_t of an existing variable.

Parameters
nameThe name of the AC variable.
Exceptions
MHA_Errorif no such variable exists in the AC space.

◆ get_entries()

const std::vector< std::string > & MHA_AC::comm_var_map_t::get_entries ( ) const
Returns
A list of names of all AC variables in this AC space.

◆ size()

size_t MHA_AC::comm_var_map_t::size ( ) const
inline
Returns
number of stored AC variables

Member Data Documentation

◆ map

std::map<std::string, comm_var_t> MHA_AC::comm_var_map_t::map
private

The std::map used for organizing the AC space.

◆ entries

std::vector<std::string> MHA_AC::comm_var_map_t::entries
private

A list containing the names of all AC variables.

◆ is_prepared

bool MHA_AC::comm_var_map_t::is_prepared = {false}

is_prepared stores whether the provider of the AC space has entered MHA state "prepared" or not.

Operations on map that require memory allocations or deallocations are only allowed when not prepared. Needs to be set by the containing
algo_comm_class_t AC space instance.


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