The Open Master Hearing Aid (openMHA)
openMHA
Open community platform for hearing aid algorithm research
|
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_t & | retrieve (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_t > | map |
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... | |
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.
|
private |
Update the member variable entries because an AC variable has been inserted or removed.
Only permitted if is_prepared == false.
|
inline |
Query the map if some AC variable name is present in the AC space.
name | Name of AC variable to check. |
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.
name | Name of the AC variable to create or update. May not be empty. Must not contain space character. |
var | Metadata of the AC variable. |
void MHA_AC::comm_var_map_t::erase_by_name | ( | const std::string & | name | ) |
Remove variable.
Only permitted if is_prepared == false.
name | Name of the AC variable to remove. |
MHA_Error | if called while prepared. |
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.
MHA_Error | if called while prepared. |
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.
name | The name of the AC variable. |
MHA_Error | if no such variable exists in the AC space. |
const std::vector< std::string > & MHA_AC::comm_var_map_t::get_entries | ( | ) | const |
|
inline |
|
private |
The std::map used for organizing the AC space.
|
private |
A list containing the names of all AC variables.
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.