libamxb
4.8.2
Bus Agnostic C API
|
Functions | |
int | amxb_subscribe (amxb_bus_ctx_t *const ctx, const char *object, const char *expression, amxp_slot_fn_t slot_cb, void *priv) |
Subscribes for events of a object tree. More... | |
int | amxb_unsubscribe (amxb_bus_ctx_t *const ctx, const char *object, amxp_slot_fn_t slot_cb, void *priv) |
Removes an event subscription. More... | |
int | amxb_publish (amxb_bus_ctx_t *const ctx, const char *object, const char *name, amxc_var_t *data) |
Publish an event for a specific object. More... | |
int | amxb_subscription_new (amxb_subscription_t **subscription, amxb_bus_ctx_t *bus_ctx, const char *object, const char *expression, amxp_slot_fn_t slot_cb, void *priv) |
Creates a subscription object and subscribes for events of a object tree. More... | |
int | amxb_subscription_delete (amxb_subscription_t **subscription) |
Deletes a subscription object and unsubscribe for events of a object tree. More... | |
amxb_subscription_t * | amxb_subscription_find (amxb_bus_ctx_t *bus_ctx, const char *object, amxp_slot_fn_t slot_cb, void *priv) |
Find an exact subscription. More... | |
amxb_subscription_t * | amxb_subscription_find_parent (amxb_bus_ctx_t *bus_ctx, const char *object) |
Find a parent subscription. More... | |
amxb_subscription_t * | amxb_subscription_find_child (amxb_bus_ctx_t *bus_ctx, const char *object) |
Find a child subscription. More... | |
int | amxb_wait_for_object (const char *object) |
Checks if an object is available, if not waits for it. More... | |
int amxb_publish | ( | amxb_bus_ctx_t *const | ctx, |
const char * | object, | ||
const char * | name, | ||
amxc_var_t * | data | ||
) |
Publish an event for a specific object.
This function can only be used when a data model was registered to the provided bus context using amxb_register.
Any event can be published for any object on the condition that the event was added to the data model signal manager.
ctx | The bus context (or connection) |
object | object path to the object object paths must end with a "." |
name | event name |
data | event data |
Definition at line 347 of file amxb_ba_subscribe.c.
int amxb_subscribe | ( | amxb_bus_ctx_t *const | ctx, |
const char * | object, | ||
const char * | expression, | ||
amxp_slot_fn_t | slot_cb, | ||
void * | priv | ||
) |
Subscribes for events of a object tree.
Subscribes for all events matching the given filter on an object (sub)tree.
Using the provided object path, all events matching the given expression, of that object or any of the child objects (instances included) are passed to the callback function.
The subscription can be removed using amxb_unsubscribe.
ctx | The bus context (or connection) |
object | object path to the object object paths must end with a "." |
expression | an expression used to filter the events |
slot_cb | callback function, called for each matching event |
priv | private data, passed to the callback function |
Definition at line 205 of file amxb_ba_subscribe.c.
int amxb_subscription_delete | ( | amxb_subscription_t ** | subscription | ) |
Deletes a subscription object and unsubscribe for events of a object tree.
Unsubscribes for events of an object (sub)tree.
The passes subscription object must be created with amxb_subscription_new
subscription | The subscription object |
Definition at line 250 of file amxb_subscription.c.
amxb_subscription_t* amxb_subscription_find | ( | amxb_bus_ctx_t * | bus_ctx, |
const char * | object, | ||
amxp_slot_fn_t | slot_cb, | ||
void * | priv | ||
) |
Find an exact subscription.
Searches in the given bus context for the first matching subscription. A subscription is matching when the object path, the slot_cb and private data is exactly matching .
bus_ctx | The bus context (or connection) |
object | object or search path, object paths must end with a "." |
slot_cb | callback function, called for each matching event |
priv | private data, passed to the callback function |
Definition at line 216 of file amxb_subscription.c.
amxb_subscription_t* amxb_subscription_find_child | ( | amxb_bus_ctx_t * | bus_ctx, |
const char * | object | ||
) |
Find a child subscription.
A child subscription is a subscription taken on a child object path.
If a search path is given only the fixed part of the path is taken into account.
bus_ctx | The bus context (or connection) |
object | object or search path, object paths must end with a "." |
Definition at line 245 of file amxb_subscription.c.
amxb_subscription_t* amxb_subscription_find_parent | ( | amxb_bus_ctx_t * | bus_ctx, |
const char * | object | ||
) |
Find a parent subscription.
A parent subscription is a subscription taken on a parent object path.
If a search path is given only the fixed part of the path is taken into account.
bus_ctx | The bus context (or connection) |
object | object or search path, object paths must end with a "." |
Definition at line 240 of file amxb_subscription.c.
int amxb_subscription_new | ( | amxb_subscription_t ** | subscription, |
amxb_bus_ctx_t * | bus_ctx, | ||
const char * | object, | ||
const char * | expression, | ||
amxp_slot_fn_t | slot_cb, | ||
void * | priv | ||
) |
Creates a subscription object and subscribes for events of a object tree.
Subscribes for all events matching the given filter on an object (sub)tree.
Using the provided object path, all events matching the given expression, of that object or any of the child objects (instances included) are passed to the callback function.
A subscription object amxb_subscription_t is allocated and must be freed using using amxb_subscription_delete.
The allocated subscription object can be stored in a amxc linked list.
subscription | The new allocated subscription object |
bus_ctx | The bus context (or connection) |
object | object or search path, object paths must end with a "." |
expression | an expression used to filter the events |
slot_cb | callback function, called for each matching event |
priv | private data, passed to the callback function |
Definition at line 187 of file amxb_subscription.c.
int amxb_unsubscribe | ( | amxb_bus_ctx_t *const | ctx, |
const char * | object, | ||
amxp_slot_fn_t | slot_cb, | ||
void * | priv | ||
) |
Removes an event subscription.
When not interested any more in events of a certain object (sub)tree, the subscription can be removed using this function.
To remove a subscription the given object path, callback function and private data pointer must match the one used when the subscription was taken with amxb_subscribe.
ctx | The bus context (or connection) |
object | object path to the object object paths must end with a "." |
slot_cb | callback function, called for each matching event |
priv | private data, passed to the callback function |
Definition at line 274 of file amxb_ba_subscribe.c.
int amxb_wait_for_object | ( | const char * | object | ) |
Checks if an object is available, if not waits for it.
When all objects are available, the signal "wait:done" is emitted on the global signal manager.
The signal is not defined by default, and must be added to the global signal manager before calling this method. It is also recommended to connect the callback functions (slots) to the signal prior to calling this method.
This function can be called multiple times. If the function is called multiple times before giving back control to the eventloop, the signal "wait:done" is emitted as soon as all objects are available.
Each time the function is called to wait for a new object, a new signal "wait:<OBJECT-PATH>" is created. This signal will be emitted when this object becomes available. However, as this signal does not exist until the moment the function is called, you cannot connect a slot to it beforehand. You can however use amxp_slot_connect_filtered to filter for the specific signal.
It is possible to add new objects to the waiting list. If "wait:done" signal was already emitted a new wait cycle is started.
The wait for object work asynchronously, so it is possible to start other tasks.
object | object path |
Definition at line 105 of file amxb_ba_wait_for.c.