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

Algorithm communication variable space interface. More...

Inheritance diagram for MHA_AC::algo_comm_t:
Inheritance graph

Public Member Functions

virtual ~algo_comm_t ()=default
 
virtual void insert_var (const std::string &name, comm_var_t cv)=0
 Interacts with AC space storage to create or replace an AC variable. More...
 
virtual void insert_var_int (const std::string &name, int *ptr)=0
 Convenience method for inserting or replacing a scalar integer AC variable into AC space. More...
 
virtual void insert_var_vfloat (const std::string &name, std::vector< float > &vec)=0
 Convenience function for inserting or replacing a vector of floats as an AC variable into the AC space. More...
 
virtual void insert_var_float (const std::string &name, float *ptr)=0
 Convenience method for inserting or replacing a scalar float AC variable into AC space. More...
 
virtual void insert_var_double (const std::string &name, double *ptr)=0
 Convenience method for inserting or replacing a scalar double AC variable into AC space. More...
 
virtual void remove_var (const std::string &name)=0
 Remove an AC variable from AC space by name. More...
 
virtual void remove_ref (void *addr)=0
 Remove all AC variables from AC space that point to the given memory address. More...
 
virtual bool is_var (const std::string &name) const =0
 Interacts with AC space storage to check if an AC variable with the given name exists. More...
 
virtual comm_var_t get_var (const std::string &name) const =0
 Interacts with AC space storage to retrieve the metadata for an AC variable with the given name. More...
 
virtual int get_var_int (const std::string &name) const =0
 Convenience method for retrieving a scalar integer AC variable from AC space. More...
 
virtual float get_var_float (const std::string &name) const =0
 Convenience method for retrieving a scalar float AC variable from AC space. More...
 
virtual double get_var_double (const std::string &name) const =0
 Convenience method for retrieving a scalar double AC variable from AC space. More...
 
virtual const std::vector< std::string > & get_entries () const =0
 
virtual size_t size () const =0
 Interacts with AC space storage to return the number of AC variables currently stored in the AC space. More...
 

Detailed Description

Algorithm communication variable space interface.

Constructor & Destructor Documentation

◆ ~algo_comm_t()

virtual MHA_AC::algo_comm_t::~algo_comm_t ( )
virtualdefault

Member Function Documentation

◆ insert_var()

virtual void MHA_AC::algo_comm_t::insert_var ( const std::string &  name,
comm_var_t  cv 
)
pure virtual

Interacts with AC space storage to create or replace an AC variable.

When the AC space is already prepared, only replacing existing variables is permitted, not creating new ones. An AC space becomes prepared only after the plugin's prepare() method has finished executing, and becomes unprepared again before the plugin's release() method starts executing. During signal processing, which starts after all plugins have executed their prepare() methods and terminates before any plugin executes its release() method, the AC space stays in prepared state.

Plugins calling this method must ensure that it is called directly or indirectly from every single invocation of their prepare() and their process() methods for each AC variable that they choose to publish. During prepare(), plugins must decide which AC variables to publish and stick to this decision until the next invocation of release().

Parameters
nameName of the AC variable to create or to replace. May not be empty. Must not contain space character.
cvDescriptor of AC variable. The data pointer of this struct must remain valid until at least the next invocation of the calling plugin's process() or release() method, the other fields must correctly describe the data.
Exceptions
MHA_ErrorIf the AC space is already prepared and no AC variable with name name exists yet.
MHA_Errorif name is emtpy or contains space.

Implemented in MHA_AC::algo_comm_class_t.

◆ insert_var_int()

virtual void MHA_AC::algo_comm_t::insert_var_int ( const std::string &  name,
int *  ptr 
)
pure virtual

Convenience method for inserting or replacing a scalar integer AC variable into AC space.

Creates suitable comm_var_t and forwards to insert_var(), therefore see also the documentation of insert_var(). When the AC space is already prepared, only replacing existing variables is permitted, not creating new ones.

Parameters
nameName of the AC variable to create or to replace. May not be empty. Must not contain space character.
ptrPointer to an int variable owned by the calling plugin. The pointer must remain valid until at least the next invocation of the calling plugin's process() or release() method.
Exceptions
MHA_ErrorIf the AC space is already prepared and no AC variable with name name exists yet.
MHA_Errorif name is emtpy or contains space.

Implemented in MHA_AC::algo_comm_class_t.

◆ insert_var_vfloat()

virtual void MHA_AC::algo_comm_t::insert_var_vfloat ( const std::string &  name,
std::vector< float > &  vec 
)
pure virtual

Convenience function for inserting or replacing a vector of floats as an AC variable into the AC space.

Creates suitable comm_var_t and forwards to insert_var(), therefore see also the documentation of insert_var(). When the AC space is prepared, only replacing existing variables is permitted, not creating new ones.

Parameters
nameName of the AC variable to create or to replace. May not be empty. Must not contain space character.
vecReference to a float vector owned by the calling plugin. The internal storage of this vector must remain valid until at least the next invocation of the calling plugin's process() or release() method. No methods that could cause iterator invalidation may be called on this vector until at least then.
Exceptions
MHA_ErrorIf the AC space is already prepared and no AC variable with name name exists yet.
MHA_Errorif name is emtpy or contains space.
MHA_Errorif vec contains more elements than can be represented by comm_var_t::num_entries.

Implemented in MHA_AC::algo_comm_class_t.

◆ insert_var_float()

virtual void MHA_AC::algo_comm_t::insert_var_float ( const std::string &  name,
float *  ptr 
)
pure virtual

Convenience method for inserting or replacing a scalar float AC variable into AC space.

Creates suitable comm_var_t and forwards to insert_var(), therefore see also the documentation of insert_var(). When the AC space is prepared, only replacing existing variables is permitted, not creating new ones.

Parameters
nameName of the AC variable to create or to replace. May not be empty. Must not contain space character.
ptrPointer to a float variable owned by the calling plugin. The pointer must remain valid until at least the next invocation of the calling plugin's process() or release() method.
Exceptions
MHA_ErrorIf the AC space is already prepared and no AC variable with name name exists yet.
MHA_Errorif name is emtpy or contains space.

Implemented in MHA_AC::algo_comm_class_t.

◆ insert_var_double()

virtual void MHA_AC::algo_comm_t::insert_var_double ( const std::string &  name,
double *  ptr 
)
pure virtual

Convenience method for inserting or replacing a scalar double AC variable into AC space.

Creates suitable comm_var_t and forwards to insert_var(), therefore see also the documentation of insert_var(). When the AC space is prepared, only replacing existing variables is permitted, not creating new ones.

Parameters
nameName of the AC variable to create or to replace. May not be empty. Must not contain space character.
ptrPointer to a double variable owned by the calling plugin. The pointer must remain valid until at least the next invocation of the calling plugin's process() or release() method.
Exceptions
MHA_ErrorIf the AC space is already prepared and no AC variable with name name exists yet.
MHA_Errorif name is emtpy or contains space.

Implemented in MHA_AC::algo_comm_class_t.

◆ remove_var()

virtual void MHA_AC::algo_comm_t::remove_var ( const std::string &  name)
pure virtual

Remove an AC variable from AC space by name.

Only permitted when AC space is not prepared. Trying to remove a non-existing AC variable from AC space is not by itself an error. Calling this method while the AC space is prepared is an error, because it is not permitted to remove AC variables during signal processing, only to update them.

Parameters
nameName of the AC variable to remove.
Exceptions
MHA_Errorif called while prepared, and then regardless of whether an AC variable with name name exists or not.

Implemented in MHA_AC::algo_comm_class_t.

◆ remove_ref()

virtual void MHA_AC::algo_comm_t::remove_ref ( void *  addr)
pure virtual

Remove all AC variables from AC space that point to the given memory address.

Only permitted when AC space is not prepared. While not prepared, it is not an error if no AC variables or if multiple AC variables actually point to addr. All matching variables are removed.

Parameters
addrMemory address where the data of the AC variable(s) to remove is or was stored.
Exceptions
MHA_Errorif called while prepared, regardless whether any AC variables currently point to addr or not.

Implemented in MHA_AC::algo_comm_class_t.

◆ is_var()

virtual bool MHA_AC::algo_comm_t::is_var ( const std::string &  name) const
pure virtual

Interacts with AC space storage to check if an AC variable with the given name exists.

Parameters
nameName of the AC variable to check.

Implemented in MHA_AC::algo_comm_class_t.

◆ get_var()

virtual comm_var_t MHA_AC::algo_comm_t::get_var ( const std::string &  name) const
pure virtual

Interacts with AC space storage to retrieve the metadata for an AC variable with the given name.

Parameters
nameName of the AC variable to retrieve.
Returns
a struct describing the AC variable's data type, memory location and size.
Exceptions
MHA_Errorif no AC variable with the given name exists.

Implemented in MHA_AC::algo_comm_class_t.

◆ get_var_int()

virtual int MHA_AC::algo_comm_t::get_var_int ( const std::string &  name) const
pure virtual

Convenience method for retrieving a scalar integer AC variable from AC space.

Checks data type and size.

Parameters
nameName of the AC variable to read.
Returns
Value of the AC varible.
Exceptions
MHA_Errorif no AC variable with the given name exists.
MHA_Errorif AC variable name is not an integer or not a scalar.

Implemented in MHA_AC::algo_comm_class_t.

◆ get_var_float()

virtual float MHA_AC::algo_comm_t::get_var_float ( const std::string &  name) const
pure virtual

Convenience method for retrieving a scalar float AC variable from AC space.

Checks data type and size.

Parameters
nameName of the AC variable to read.
Returns
Value of the AC varible.
Exceptions
MHA_Errorif no AC variable with the given name exists.
MHA_Errorif AC variable name is not a float or not a scalar.

Implemented in MHA_AC::algo_comm_class_t.

◆ get_var_double()

virtual double MHA_AC::algo_comm_t::get_var_double ( const std::string &  name) const
pure virtual

Convenience method for retrieving a scalar double AC variable from AC space.

Checks data type and size.

Parameters
nameName of the AC variable to read.
Returns
Value of the AC varible.
Exceptions
MHA_Errorif no AC variable with the given name exists.
MHA_Errorif AC variable name is not a double or not a scalar.

Implemented in MHA_AC::algo_comm_class_t.

◆ get_entries()

virtual const std::vector<std::string>& MHA_AC::algo_comm_t::get_entries ( ) const
pure virtual
Returns
a list of the names of all existing AC variables.

Implemented in MHA_AC::algo_comm_class_t.

◆ size()

virtual size_t MHA_AC::algo_comm_t::size ( ) const
pure virtual

Interacts with AC space storage to return the number of AC variables currently stored in the AC space.

Always permitted.

Implemented in MHA_AC::algo_comm_class_t.


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