BrlAPI 0.8
|
How to manage BrlAPI parameters. More...
Macros | |
#define | BRLAPI_PARAMF_LOCAL 0X00 |
#define | BRLAPI_PARAMF_GLOBAL 0X01 |
#define | BRLAPI_PARAMF_SELF 0X02 |
Typedefs | |
typedef uint32_t | brlapi_param_flags_t |
typedef void(* | brlapi_paramCallback_t) (brlapi_param_t parameter, brlapi_param_subparam_t subparam, brlapi_param_flags_t flags, void *priv, const void *data, size_t len) |
typedef void * | brlapi_paramCallbackDescriptor_t |
There are several kinds of parameters:
Some of them are subdivided in subparameters. Others have only subparameter 0.
Some of them are read-only, others are read/write.
A client can either request the immediate content of a parameter by using brlapi_getParameter(); set the content of a parameter by using brlapi_setParameter(); or register a callback that may be called immediately and on each change of a given parameter, by using brlapi_watchParameter().
#define BRLAPI_PARAMF_GLOBAL 0X01 |
Refer to the global value instead of the value local to the connection
#define BRLAPI_PARAMF_LOCAL 0X00 |
Refer to the value local to the connection instead of the global value
#define BRLAPI_PARAMF_SELF 0X02 |
Specify whether to receive notifications of value self-changes
typedef uint32_t brlapi_param_flags_t |
Flags for parameter requests
typedef void(* brlapi_paramCallback_t) (brlapi_param_t parameter, brlapi_param_subparam_t subparam, brlapi_param_flags_t flags, void *priv, const void *data, size_t len) |
Callback for parameter changes
When a parameter gets changed, application-defined callbacks set by the brlapi_watchParameter() function are called.
parameter | is the parameter that changed; |
subparam | is a specific instance of the parameter; |
flags | specify which value and how it was changed; |
priv | is the void pointer that was passed to the brlapi_watchParameter call which registered the callback; |
data | is a buffer containing the new value of the parameter; |
len | is the size of the data. |
This callback only gets called when the application calls some brlapi_ function (i.e. BrlAPI gets direct control of the execution), BrlAPI itself does not start a separate thread or such.
If an application wants to see such event trigger a callback getting called e.g. in another thread, it can use brlapi_pause() to give BrlAPI an opportunity to receive messages and call the callbacks.
typedef void* brlapi_paramCallbackDescriptor_t |
Type for callback descriptors This is returned by brlapi_watchParameter, to be passed to brlapi_unwatchParameter.
enum brlapi_param_t |
ssize_t BRLAPI_STDCALL brlapi__getParameter | ( | brlapi_handle_t * | handle, |
brlapi_param_t | parameter, | ||
brlapi_param_subparam_t | subparam, | ||
brlapi_param_flags_t | flags, | ||
void * | data, | ||
size_t | len ) |
void *BRLAPI_STDCALL brlapi__getParameterAlloc | ( | brlapi_handle_t * | handle, |
brlapi_param_t | parameter, | ||
brlapi_param_subparam_t | subparam, | ||
brlapi_param_flags_t | flags, | ||
size_t * | len ) |
int BRLAPI_STDCALL brlapi__setParameter | ( | brlapi_handle_t * | handle, |
brlapi_param_t | parameter, | ||
brlapi_param_subparam_t | subparam, | ||
brlapi_param_flags_t | flags, | ||
const void * | data, | ||
size_t | len ) |
int BRLAPI_STDCALL brlapi__unwatchParameter | ( | brlapi_handle_t * | handle, |
brlapi_paramCallbackDescriptor_t | descriptor ) |
brlapi_paramCallbackDescriptor_t BRLAPI_STDCALL brlapi__watchParameter | ( | brlapi_handle_t * | handle, |
brlapi_param_t | parameter, | ||
brlapi_param_subparam_t | subparam, | ||
brlapi_param_flags_t | flags, | ||
brlapi_paramCallback_t | func, | ||
void * | priv, | ||
void * | data, | ||
size_t | len ) |
ssize_t BRLAPI_STDCALL brlapi_getParameter | ( | brlapi_param_t | parameter, |
brlapi_param_subparam_t | subparam, | ||
brlapi_param_flags_t | flags, | ||
void * | data, | ||
size_t | len ) |
Get the content of a parameter
brlapi_getParameter gets the current content of a parameter
parameter | is the parameter whose content shall be gotten; |
subparam | is a specific instance of the parameter; |
flags | specify which value and how it should be returned; |
data | is a buffer where content of the parameter shall be stored; |
len | is the size of the buffer. |
void *BRLAPI_STDCALL brlapi_getParameterAlloc | ( | brlapi_param_t | parameter, |
brlapi_param_subparam_t | subparam, | ||
brlapi_param_flags_t | flags, | ||
size_t * | len ) |
Return the content of a parameter
brlapi_getParameterAlloc gets the current content of a parameter, by returning it as a newly-allocated buffer. The buffer is allocated to one byte more than the parameter value. This byte is set to zero. This allows, for string parameters, to be able to immediately use it as a C string.
parameter | is the parameter whose content shall be gotten; |
subparam | is a specific instance of the parameter; |
flags | specify which value and how it should be returned; |
len | is the address where to store the size of the parameter value. |
int BRLAPI_STDCALL brlapi_setParameter | ( | brlapi_param_t | parameter, |
brlapi_param_subparam_t | subparam, | ||
brlapi_param_flags_t | flags, | ||
const void * | data, | ||
size_t | len ) |
Set the content of a parameter
brlapi_setParameter sets the content of a parameter
parameter | is the parameter to set; |
subparam | is a specific instance of the parameter; |
flags | specify which value and how it should be set; |
data | is a buffer containing the data to store in the parameter; |
len | is the size of the data. |
int BRLAPI_STDCALL brlapi_unwatchParameter | ( | brlapi_paramCallbackDescriptor_t | descriptor | ) |
Clear a parameter change callback
brlapi_unwatchParameter unregisters a parameter change callback: the callback function previously registered with brlapi_watchParameter will not be called any longer.
descriptor | refers to the callback to be removed. |
brlapi_paramCallbackDescriptor_t BRLAPI_STDCALL brlapi_watchParameter | ( | brlapi_param_t | parameter, |
brlapi_param_subparam_t | subparam, | ||
brlapi_param_flags_t | flags, | ||
brlapi_paramCallback_t | func, | ||
void * | priv, | ||
void * | data, | ||
size_t | len ) |
Set a parameter change callback
brlapi_watchParameter registers a parameter change callback: whenever the given parameter changes, the given function is called.
parameter | is the parameter to watch; |
subparam | is a specific instance of the parameter; |
flags | specify which value and how it should be monitored; |
func | is the function to call on parameter change; |
priv | is a void pointer which will be passed as such to the function; |
data | is a buffer where the current content of the parameter shall be stored; |
len | is the size of the buffer. |