libamxp
1.4.0
Patterns C Implementation
|
Typedefs | |
typedef void(* | amxp_deferred_fn_t) (const amxc_var_t *const data, void *const priv) |
Deferred callback function signature. More... | |
typedef void(* | amxp_slot_fn_t) (const char *const sig_name, const amxc_var_t *const data, void *const priv) |
Slot callback function signature. More... | |
Functions | |
int | amxp_slot_connect (amxp_signal_mngr_t *const sig_mngr, const char *const sig_name, const char *const expression, amxp_slot_fn_t fn, void *const priv) |
Connects a slot (function) to a named signal of a signal manager. More... | |
int | amxp_slot_connect_filtered (amxp_signal_mngr_t *const sig_mngr, const char *const sig_reg_exp, const char *const expression, amxp_slot_fn_t fn, void *const priv) |
Connects a slot (function) to signals using a regular expression. More... | |
int | amxp_slot_connect_all (const char *const sig_reg_exp, const char *const expression, amxp_slot_fn_t fn, void *const priv) |
Connects a slot to all existing and future signals. More... | |
int | amxp_slot_disconnect (amxp_signal_mngr_t *const sig_mngr, const char *const sig_name, amxp_slot_fn_t fn) |
Disconnects a slot from (a) signal(s). More... | |
int | amxp_slot_disconnect_with_priv (amxp_signal_mngr_t *sig_mngr, amxp_slot_fn_t fn, void *priv) |
Disconnects a slot from (a) signal(s). More... | |
int | amxp_slot_disconnect_signal_with_priv (amxp_signal_mngr_t *sig_mngr, const char *sig_name, amxp_slot_fn_t fn, void *priv) |
Disconnects a slot from a signal. More... | |
void | amxp_slot_disconnect_all (amxp_slot_fn_t fn) |
Disconnects a slot from all signals it was connected to. More... | |
Slots are callback functions that are connected to named signals.
When a signal is triggered, all slots (callback functions) connected to the named signal are called.
typedef void(* amxp_deferred_fn_t) (const amxc_var_t *const data, void *const priv) |
Deferred callback function signature.
Deferred functions are called from the eventloop
data | some data |
priv | a pointer to some data |
Definition at line 137 of file amxp_signal.h.
typedef void(* amxp_slot_fn_t) (const char *const sig_name, const amxc_var_t *const data, void *const priv) |
Slot callback function signature.
A slot is a callback function with this signature.
sig_name | the name of the signal |
data | the data of the signal |
priv | a pointer to some data, provided when connecting |
Definition at line 93 of file amxp_slot.h.
int amxp_slot_connect | ( | amxp_signal_mngr_t *const | sig_mngr, |
const char *const | sig_name, | ||
const char *const | expression, | ||
amxp_slot_fn_t | fn, | ||
void *const | priv | ||
) |
Connects a slot (function) to a named signal of a signal manager.
When the function (slot) is connected to the signal, the function is called each time the signal is "triggered".
When "*" is used as signal name, the slots is connected to all know signals of the given signal manager or when sig_mngr is NULL to all know signals from all signal managers.
When sig_mgr is NULL and sig_name is "*", the slot will also be connected to new added signals (signals that were not existing at the time of call to this function).
When a valid expression is added the slot is only called when expression evaluates to true, using the signal data as input. If the signal has not data the slot is also called even when an expression is provided.
Use amxp_slot_disconnect or amxp_slot_disconnect_all to disconnect the slot from signals.
sig_mngr | the signal manager, or null for the global signal manager |
sig_name | the signal you want to connect to |
expression | Null or a string containing a valid expression |
fn | the slot function (callback function) |
priv | a pointer to some data, will be passed to the slot function when the signal is triggered |
Definition at line 300 of file amxp_slot.c.
int amxp_slot_connect_all | ( | const char *const | sig_reg_exp, |
const char *const | expression, | ||
amxp_slot_fn_t | fn, | ||
void *const | priv | ||
) |
Connects a slot to all existing and future signals.
This function does exactly the same as amxp_slot_connect where sig_name is "*" and sig_mngr is NULL, if no signal regular expression is provided (NULL).
If a regular expression is provided the slot is connected to all known and future signals that matches the regular expression.
sig_reg_exp | a regular expression, the slot is connected to all signals matching the regular expression |
expression | Null or a string containing a valid expression |
fn | the slot function (callback function) |
priv | a pointer to some data, will be passed to the slot function when the signal is triggered |
Definition at line 353 of file amxp_slot.c.
int amxp_slot_connect_filtered | ( | amxp_signal_mngr_t *const | sig_mngr, |
const char *const | sig_reg_exp, | ||
const char *const | expression, | ||
amxp_slot_fn_t | fn, | ||
void *const | priv | ||
) |
Connects a slot (function) to signals using a regular expression.
The slot is connected to all signals of which the name is matching the given regular expression. If later signals are added and the name of the new signal is also matching the regular expression the slot will be automatically connected to the new signal as well.
Optionally a expression can be added. The expression works only on signals the provide a data. The slot is only called when the expression evalutes to true or when the signal has no data.
Use amxp_slot_disconnect or amxp_slot_disconnect_all to disconnect the slot from signals.
sig_mngr | the signal manager, or null for the global signal manager |
sig_reg_exp | a regular expression, the slot is connected to all signals matching the regular expression |
expression | Null or a string containing a valid expression |
fn | the slot function (callback function) |
priv | a pointer to some data, will be passed to the slot function when the signal is triggered |
Definition at line 330 of file amxp_slot.c.
int amxp_slot_disconnect | ( | amxp_signal_mngr_t *const | sig_mngr, |
const char *const | sig_name, | ||
amxp_slot_fn_t | fn | ||
) |
Disconnects a slot from (a) signal(s).
Disconnecting a slot using this function will:
A removed slot will not be called anymore when the signal is triggered.
When "*" is given as sign_name, the slot will be disconnected from all signals of the specified signal manager (sig_mngr), when sig_mngr is NULL, the slot is disconnected from all signals it was connected to.
sig_mngr | the signal manager, or null for the global signal manager |
sig_name | the signal you want to disconnect from use "*" for all |
fn | the slot function (callback function). |
Definition at line 380 of file amxp_slot.c.
void amxp_slot_disconnect_all | ( | amxp_slot_fn_t | fn | ) |
Disconnects a slot from all signals it was connected to.
The slot is removed from all signals it was connected to, including regular expression slot (see amxp_slot_connect_filtered)
fn | the slot function (callback function) |
Definition at line 459 of file amxp_slot.c.
int amxp_slot_disconnect_signal_with_priv | ( | amxp_signal_mngr_t * | sig_mngr, |
const char * | sig_name, | ||
amxp_slot_fn_t | fn, | ||
void * | priv | ||
) |
Disconnects a slot from a signal.
Disconnecting a slot using this function will:
A removed slot will not be called anymore when the signal is triggered.
sig_mngr | the signal manager, or null for the global signal manager |
sig_name | the signal name, or NULL for all. |
fn | the slot function (callback function). |
priv | The private data pointer that was provided when connecting |
Definition at line 411 of file amxp_slot.c.
int amxp_slot_disconnect_with_priv | ( | amxp_signal_mngr_t * | sig_mngr, |
amxp_slot_fn_t | fn, | ||
void * | priv | ||
) |
Disconnects a slot from (a) signal(s).
Disconnecting a slot using this function will:
A removed slot will not be called anymore when the signal is triggered.
sig_mngr | the signal manager, or null for the global signal manager |
fn | the slot function (callback function). |
priv | The private data pointer that was provided when connecting |
Definition at line 405 of file amxp_slot.c.