The Open Master Hearing Aid (openMHA)  openMHA
Open community platform for hearing aid algorithm research
mha_os.h File Reference

Classes

class  mha_stash_environment_variable_t
 This class changes the value of an environment variable when constructed and restores the original state of the environment variable when destroyed. More...
 
class  dynamiclib_t
 Wrapper class around a shared library. More...
 
class  pluginlib_t
 Specialisation of dynamiclib_t for mha plugin libraries. More...
 

Macros

#define mha_loadlib(x)   dlopen(x,RTLD_NOW)
 
#define mha_freelib(x)   dlclose(x)
 
#define mha_freelib_success(x)   (x == 0)
 
#define mha_getlibfun(h, x)   x ## _cb = (x ## _t)dlsym(h,#x)
 
#define mha_getlibfun_checked(h, x)   x ## _cb = (x ## _t)dlsym(h,#x);if(! x ## _cb) throw MHA_Error(__FILE__,__LINE__,"Function " #x " is undefined.")
 
#define mha_loadlib_error(x)   dlerror()
 
#define mha_lib_extension   ".so"
 
#define mha_msleep(milliseconds)   usleep((milliseconds)*1000)
 
#define FMTsz   "%zu"
 printf modifier to print integers of type size_t More...
 
#define MHA_RESOLVE(h, t)   t ## _cb = (t ## _t)(h->resolve(#t))
 
#define MHA_RESOLVE_CHECKED(h, t)   t ## _cb = (t ## _t)(h->resolve_checked(#t))
 

Typedefs

typedef void * mha_libhandle_t
 

Functions

std::string mha_getenv (const std::string &envvar)
 Get value of environment variable. More...
 
bool mha_hasenv (const std::string &envvar)
 Checks if environment variable exists. More...
 
int mha_setenv (const std::string &envvar, const std::string &value)
 Set value of environment variable. More...
 
void mha_delenv (const std::string &envvar)
 Deletes environment variable from process environment if it exists. More...
 
std::list< std::string > mha_library_paths ()
 
std::list< std::string > list_dir (const std::string &path, const std::string &pattern)
 
void mha_hton (float *data, unsigned int len)
 
void mha_ntoh (float *data, unsigned int len)
 
void mha_hton (uint32_t *data, unsigned int len)
 
void mha_ntoh (uint32_t *data, unsigned int len)
 
void mha_hton (int32_t *data, unsigned int len)
 
void mha_ntoh (int32_t *data, unsigned int len)
 

Macro Definition Documentation

◆ mha_loadlib

#define mha_loadlib (   x)    dlopen(x,RTLD_NOW)

◆ mha_freelib

#define mha_freelib (   x)    dlclose(x)

◆ mha_freelib_success

#define mha_freelib_success (   x)    (x == 0)

◆ mha_getlibfun

#define mha_getlibfun (   h,
 
)    x ## _cb = (x ## _t)dlsym(h,#x)

◆ mha_getlibfun_checked

#define mha_getlibfun_checked (   h,
 
)    x ## _cb = (x ## _t)dlsym(h,#x);if(! x ## _cb) throw MHA_Error(__FILE__,__LINE__,"Function " #x " is undefined.")

◆ mha_loadlib_error

#define mha_loadlib_error (   x)    dlerror()

◆ mha_lib_extension

#define mha_lib_extension   ".so"

◆ mha_msleep

#define mha_msleep (   milliseconds)    usleep((milliseconds)*1000)

◆ FMTsz

#define FMTsz   "%zu"

printf modifier to print integers of type size_t

◆ MHA_RESOLVE

#define MHA_RESOLVE (   h,
 
)    t ## _cb = (t ## _t)(h->resolve(#t))

◆ MHA_RESOLVE_CHECKED

#define MHA_RESOLVE_CHECKED (   h,
 
)    t ## _cb = (t ## _t)(h->resolve_checked(#t))

Typedef Documentation

◆ mha_libhandle_t

typedef void* mha_libhandle_t

Function Documentation

◆ mha_getenv()

std::string mha_getenv ( const std::string &  envvar)

Get value of environment variable.

Parameters
envvarName of environment variable to retrieve
Returns
content of environment variable if it exists, empty string if the environment variable does not exist

◆ mha_hasenv()

bool mha_hasenv ( const std::string &  envvar)

Checks if environment variable exists.

Parameters
envvarName of environment variable to check
Returns
true if the environment has a variable of this name

◆ mha_setenv()

int mha_setenv ( const std::string &  envvar,
const std::string &  value 
)

Set value of environment variable.

Parameters
envvarName of environment variable to set
valueNew content for environment variable
Returns
error code: 0 on success, OS dependent error code on failure

◆ mha_delenv()

void mha_delenv ( const std::string &  envvar)

Deletes environment variable from process environment if it exists.

Parameters
envvarName of environment variable to delete

◆ mha_library_paths()

std::list<std::string> mha_library_paths ( )

◆ list_dir()

std::list<std::string> list_dir ( const std::string &  path,
const std::string &  pattern 
)

◆ mha_hton() [1/3]

void mha_hton ( float *  data,
unsigned int  len 
)
inline

◆ mha_ntoh() [1/3]

void mha_ntoh ( float *  data,
unsigned int  len 
)
inline

◆ mha_hton() [2/3]

void mha_hton ( uint32_t *  data,
unsigned int  len 
)
inline

◆ mha_ntoh() [2/3]

void mha_ntoh ( uint32_t *  data,
unsigned int  len 
)
inline

◆ mha_hton() [3/3]

void mha_hton ( int32_t *  data,
unsigned int  len 
)
inline

◆ mha_ntoh() [3/3]

void mha_ntoh ( int32_t *  data,
unsigned int  len 
)
inline