libamxd
6.4.1
Data Model Manager
|
Functions | |
void | amxd_object_send_signal (amxd_object_t *const object, const char *name, amxc_var_t *const data, bool trigger) |
Send an object signal/event. More... | |
AMXD_INLINE void | amxd_object_emit_signal (amxd_object_t *const object, const char *name, amxc_var_t *const data) |
Emit an object signal/event. More... | |
AMXD_INLINE void | amxd_object_trigger_signal (amxd_object_t *const object, const char *name, amxc_var_t *const data) |
Emit an object signal/event. More... | |
void | amxd_object_send_add_inst (amxd_object_t *instance, bool trigger) |
Send an add instance object event. More... | |
AMXD_INLINE void | amxd_object_emit_add_inst (amxd_object_t *instance) |
Emit an add instance object event. More... | |
AMXD_INLINE void | amxd_object_trigger_add_inst (amxd_object_t *instance) |
Trigger an add instance object event. More... | |
void | amxd_object_send_del_inst (amxd_object_t *instance, bool trigger) |
Send a delete instance object event. More... | |
AMXD_INLINE void | amxd_object_emit_del_inst (amxd_object_t *instance) |
Emit a delete instance object event. More... | |
AMXD_INLINE void | amxd_object_trigger_del_inst (amxd_object_t *instance) |
Trigger a delete instance object event. More... | |
void | amxd_object_send_changed (amxd_object_t *object, amxc_var_t *params, bool trigger) |
Send an object changed event. More... | |
AMXD_INLINE void | amxd_object_emit_changed (amxd_object_t *object, amxc_var_t *params) |
Emit an object changed event. More... | |
AMXD_INLINE void | amxd_object_trigger_changed (amxd_object_t *object, amxc_var_t *params) |
Trigger an object changed event. More... | |
amxd_status_t | amxd_object_new_pi (amxd_object_t *object, uint32_t sec) |
Creates and starts a periodic inform event timer. More... | |
amxd_status_t | amxd_object_delete_pi (amxd_object_t *object) |
Stops and deletes a periodic inform event timer. More... | |
amxd_status_t | amxd_object_add_event_ext (amxd_object_t *const object, const char *event_name, amxc_var_t *event_data) |
Adds an event definition to the object. More... | |
amxd_status_t | amxd_object_add_event (amxd_object_t *const object, const char *event_name) |
Adds an event definition to the object. More... | |
void | amxd_object_remove_event (amxd_object_t *const object, const char *event_name) |
Removes an event definition to the object. More... | |
amxc_var_t * | amxd_object_new_event_data (const amxd_object_t *object, const char *event_name) |
Allocates a variant that contains the predefined event data. More... | |
amxd_status_t amxd_object_add_event | ( | amxd_object_t *const | object, |
const char * | event_name | ||
) |
Adds an event definition to the object.
Events can be defined and stored in the data model definition.
If an event data template must be added use function amxd_object_add_event_ext.
This function wil call amxd_object_add_event_ext and set the event data pointer to NULL.
object | The object in which an event must be defined. |
event_name | The name of the event. |
Definition at line 411 of file amxd_object_event.c.
amxd_status_t amxd_object_add_event_ext | ( | amxd_object_t *const | object, |
const char * | event_name, | ||
amxc_var_t * | event_data | ||
) |
Adds an event definition to the object.
Events and the data they can contain can be defined and stored in the data model definition.
To allocate a variant containing the event data the function amxd_object_new_event_data can be used.
object | The object in which an event must be defined. |
event_name | The name of the event. |
event_data | (optional) The event data definition template. |
Definition at line 376 of file amxd_object_event.c.
amxd_status_t amxd_object_delete_pi | ( | amxd_object_t * | object | ) |
Stops and deletes a periodic inform event timer.
A periodic inform timer can be created and started using amxd_object_new_pi.
This function will stop and deletes the periodic inform timer for the object.
object | The object for which a periodic inform event must be stopped. |
Definition at line 355 of file amxd_object_event.c.
AMXD_INLINE void amxd_object_emit_add_inst | ( | amxd_object_t * | instance | ) |
Emit an add instance object event.
This function will call amxd_object_send_add_inst with trigger set to false.
instance | The newly added instance. |
Definition at line 230 of file amxd_object_event.h.
AMXD_INLINE void amxd_object_emit_changed | ( | amxd_object_t * | object, |
amxc_var_t * | params | ||
) |
Emit an object changed event.
This function will call amxd_object_send_changed with trigger set to false.
object | The object for which the changed event must be sent. |
params | A hash table of the parameters with their original values (before the change) |
Definition at line 399 of file amxd_object_event.h.
AMXD_INLINE void amxd_object_emit_del_inst | ( | amxd_object_t * | instance | ) |
Emit a delete instance object event.
This function will call amxd_object_send_del_inst with trigger set to false.
instance | The instance that will be deleted. |
Definition at line 317 of file amxd_object_event.h.
AMXD_INLINE void amxd_object_emit_signal | ( | amxd_object_t *const | object, |
const char * | name, | ||
amxc_var_t *const | data | ||
) |
Emit an object signal/event.
This function will call amxd_object_send_signal with trigger set to false.
object | the object for which the event must be send. |
name | the event name. |
data | (optional, can be NULL) the event data. |
Definition at line 142 of file amxd_object_event.h.
amxc_var_t* amxd_object_new_event_data | ( | const amxd_object_t * | object, |
const char * | event_name | ||
) |
Allocates a variant that contains the predefined event data.
This function allocates a variant on the heap. The returned variant pointer can be used to set the correct event values for the event data.
The returned pointer must be freed using amxc_var_delete.
object | The object from which an event must be removed. |
event_name | The name of the event. |
Definition at line 424 of file amxd_object_event.c.
amxd_status_t amxd_object_new_pi | ( | amxd_object_t * | object, |
uint32_t | sec | ||
) |
Creates and starts a periodic inform event timer.
A periodic inform timer will send an event at a regular interval. The event will contain all parameters of the object and their values at that moment.
A periodic inform timer can be used to send the values of volatile parameters (typically statistics).
Only one periodic inform timer can be created for an object.
Use amxd_object_delete_pi to stop and delete the periodic inform timer.
When the object is deleted the timer will be stopped and deleted as well.
Example of a periodic inform event:
The event data:
object | The object for which a periodic inform event must be created. |
sec | Interval in seconds at which the event must be sent. |
Definition at line 329 of file amxd_object_event.c.
void amxd_object_remove_event | ( | amxd_object_t *const | object, |
const char * | event_name | ||
) |
Removes an event definition to the object.
This function will remove an event definition from the data model definition.
Events definitions can be added using amxd_object_add_event or amxd_object_add_event_ext.
object | The object from which an event must be removed. |
event_name | The name of the event. |
Definition at line 416 of file amxd_object_event.c.
void amxd_object_send_add_inst | ( | amxd_object_t * | instance, |
bool | trigger | ||
) |
Send an add instance object event.
Creates a data model add instance event and calls all connected functions. When the trigger argument is set to true the connected functions (callback functions) are called immediately, when set to false the functions will be called from the eventloop implementation.
Besides the base event data an add instance event contains the index and name of the newly added instance, a hash table containing the key parameters and a hash table containing all parameters.
Example of an add instance event:
The event data:
instance | The newly added instance. |
trigger | when set to true, call callback functions immediately. |
Definition at line 243 of file amxd_object_event.c.
void amxd_object_send_changed | ( | amxd_object_t * | object, |
amxc_var_t * | params, | ||
bool | trigger | ||
) |
Send an object changed event.
Creates a data model object changed event and calls all connected functions. When the trigger argument is set to true the connected functions (callback functions) are called immediately, when set to false the functions will be called from the eventloop implementation.
Besides the base event data an object changed event contains all changed parameters. For each changed parameter the event will contain the value of the parameter before the change and the changed value
Example of an add instance event:
The event data:
object | The object for which the changed event must be sent. |
params | A hash table of the parameters with their original values (before the change) |
trigger | when set to true, call callback functions immediately. |
Definition at line 280 of file amxd_object_event.c.
void amxd_object_send_del_inst | ( | amxd_object_t * | instance, |
bool | trigger | ||
) |
Send a delete instance object event.
Creates a data model delete instance event and calls all connected functions. When the trigger argument is set to true the connected functions (callback functions) are called immediately, when set to false the functions will be called from the eventloop implementation.
Besides the base event data a delete instance event contains the index and name of the newly deleted instance, a hash table containing the key parameters and their values and a hash table containing all parameters and their last known values.
Example of a delete instance event:
The event data:
instance | The instance that is going to be deleted. |
trigger | when set to true, call callback functions immediately. |
Definition at line 276 of file amxd_object_event.c.
void amxd_object_send_signal | ( | amxd_object_t *const | object, |
const char * | name, | ||
amxc_var_t *const | data, | ||
bool | trigger | ||
) |
Send an object signal/event.
Creates a data model event and calls all connected functions. When the trigger argument is set to true the connected functions (callback functions) are called immediately, when set to false the functions will be called from the eventloop implementation.
A data model event always contains the name of the event and the object path in different formats.
Example of a base event:
The base event data:
Other data can be provided in an event. Which extra data is added, depends on the event type itself.
object | the object for which the event must be sent. |
name | the event name. |
data | (optional, can be NULL) the event data. |
trigger | when set to true, call callback functions immediately. |
Definition at line 230 of file amxd_object_event.c.
AMXD_INLINE void amxd_object_trigger_add_inst | ( | amxd_object_t * | instance | ) |
Trigger an add instance object event.
This function will call amxd_object_send_add_inst with trigger set to true.
instance | The newly added instance. |
Definition at line 246 of file amxd_object_event.h.
AMXD_INLINE void amxd_object_trigger_changed | ( | amxd_object_t * | object, |
amxc_var_t * | params | ||
) |
Trigger an object changed event.
This function will call amxd_object_send_changed with trigger set to true.
object | The object for which the changed event must be sent. |
params | A hash table of the parameters with their original values (before the change) |
Definition at line 417 of file amxd_object_event.h.
AMXD_INLINE void amxd_object_trigger_del_inst | ( | amxd_object_t * | instance | ) |
Trigger a delete instance object event.
This function will call amxd_object_send_del_inst with trigger set to true.
instance | The instance that will be deleted. |
Definition at line 333 of file amxd_object_event.h.
AMXD_INLINE void amxd_object_trigger_signal | ( | amxd_object_t *const | object, |
const char * | name, | ||
amxc_var_t *const | data | ||
) |
Emit an object signal/event.
This function will call amxd_object_send_signal with trigger set to true.
object | the object for which the event must be send. |
name | the event name. |
data | (optional, can be NULL) the event data. |
Definition at line 162 of file amxd_object_event.h.