libamxs
0.6.0
Data Model Synchronization C API
|
Modules | |
Object synchronization API | |
Parameter synchronization API | |
synchronization API types | |
synchronization API Utility functions | |
Functions | |
amxs_status_t | amxs_sync_ctx_new (amxs_sync_ctx_t **ctx, const char *object_a, const char *object_b, int attributes) |
Synchronization context constructor function. More... | |
void | amxs_sync_ctx_delete (amxs_sync_ctx_t **ctx) |
Synchronization context destructor function. More... | |
amxs_status_t | amxs_sync_ctx_init (amxs_sync_ctx_t *ctx, const char *object_a, const char *object_b, int attributes) |
Synchronization context initialization function. More... | |
void | amxs_sync_ctx_clean (amxs_sync_ctx_t *ctx) |
Synchronization context cleanup function. More... | |
amxs_status_t | amxs_sync_ctx_copy (amxs_sync_ctx_t **dest, amxs_sync_ctx_t *src, void *priv) |
Copies an existing synchronization context to a new synchronization context. More... | |
amxs_status_t | amxs_sync_ctx_start_sync (amxs_sync_ctx_t *ctx) |
Starts the object synchronization. More... | |
void | amxs_sync_ctx_stop_sync (amxs_sync_ctx_t *ctx) |
Stops the object synchronization. More... | |
static bool | amxs_sync_ctx_is_started (const amxs_sync_ctx_t *const ctx) |
Checks is the synchronization context is running. More... | |
amxs_status_t | amxs_sync_ctx_set_paths (amxs_sync_ctx_t *const ctx, const char *object_a, const char *object_b) |
Updates the object paths of the synchronization context. More... | |
amxs_status_t | amxs_sync_ctx_add_param (amxs_sync_ctx_t *ctx, amxs_sync_param_t *param) |
Adds a synchronization parameter to a synchronization context. More... | |
amxs_status_t | amxs_sync_ctx_add_new_param (amxs_sync_ctx_t *ctx, const char *param_a, const char *param_b, int attributes, amxs_translation_cb_t translation_cb, amxs_action_cb_t action_cb, void *priv) |
Creates and adds a synchronization parameter to a synchronization context. More... | |
amxs_status_t | amxs_sync_ctx_add_new_copy_param (amxs_sync_ctx_t *ctx, const char *param_a, const char *param_b, int attributes) |
Creates and adds a synchronization parameter to a synchronization context. More... | |
amxs_status_t | amxs_sync_ctx_add_object (amxs_sync_ctx_t *ctx, amxs_sync_object_t *object) |
Adds a synchronization object to a synchronization context. More... | |
amxs_status_t | amxs_sync_ctx_add_new_object (amxs_sync_ctx_t *ctx, const char *object_a, const char *object_b, int attributes, amxs_translation_cb_t translation_cb, amxs_action_cb_t action_cb, void *priv) |
Creates and adds a synchronization object to a synchronization context. More... | |
amxs_status_t amxs_sync_ctx_add_new_copy_param | ( | amxs_sync_ctx_t * | ctx, |
const char * | param_a, | ||
const char * | param_b, | ||
int | attributes | ||
) |
Creates and adds a synchronization parameter to a synchronization context.
Allocates memory for a new synchronization parameter and initializes this parameter. Then adds it to the synchronization context.
Adding the synchronization parameter fails when:
If the context attributes are more strict than those of the parameter, the parameter attributes will be updated to match those of the context.
Uses default translation amxs_sync_batch_param_copy_trans_cb and action amxs_sync_param_copy_action_cb callbacks.
ctx | Pointer to a synchronization context. |
param_a | Name of the parameter in object A |
param_b | Name of the parameter in object B |
attributes | Bitwise OR of zero or more of the following attributes: |
Definition at line 903 of file amxs_sync_ctx.c.
amxs_status_t amxs_sync_ctx_add_new_object | ( | amxs_sync_ctx_t * | ctx, |
const char * | object_a, | ||
const char * | object_b, | ||
int | attributes, | ||
amxs_translation_cb_t | translation_cb, | ||
amxs_action_cb_t | action_cb, | ||
void * | priv | ||
) |
Creates and adds a synchronization object to a synchronization context.
Allocates memory for a new synchronization object and initializes this object. Then adds it to the synchronization context.
Adding the synchronization object fails when:
If the context attributes are more strict than those of the object, the object attributes will be updated to match those of the context.
ctx | Pointer to a synchronization context. |
object_a | Name of the object in object A |
object_b | Name of the object in object B |
attributes | Bitwise OR of zero or more of the following attributes: |
translation_cb | Callback function to translate data coming from an object event. The output data of this function will be passed to the action callback function if this function executes succesfully. If this argument is NULL, the data from the event will be passed directly to the action callback function. |
action_cb | Callback function to act on an object event. |
priv | Pointer to user data which will be passed to the translation and action callbacks. |
Definition at line 929 of file amxs_sync_ctx.c.
amxs_status_t amxs_sync_ctx_add_new_param | ( | amxs_sync_ctx_t * | ctx, |
const char * | param_a, | ||
const char * | param_b, | ||
int | attributes, | ||
amxs_translation_cb_t | translation_cb, | ||
amxs_action_cb_t | action_cb, | ||
void * | priv | ||
) |
Creates and adds a synchronization parameter to a synchronization context.
Allocates memory for a new synchronization parameter and initializes this parameter. Then adds it to the synchronization context.
Adding the synchronization parameter fails when:
If the context attributes are more strict than those of the parameter, the parameter attributes will be updated to match those of the context.
ctx | Pointer to a synchronization context. |
param_a | Name of the parameter in object A |
param_b | Name of the parameter in object B |
attributes | Bitwise OR of zero or more of the following attributes: |
translation_cb | Callback function to translate data coming from a parameter changed event. The output data of this function will be passed to the action callback function if this function executes succesfully. If this argument is NULL, the data from the event will be passed directly to the action callback function. |
action_cb | Callback function to act on a parameter changed event. |
priv | Pointer to user data which will be passed to the translation and action callbacks. |
Definition at line 881 of file amxs_sync_ctx.c.
amxs_status_t amxs_sync_ctx_add_object | ( | amxs_sync_ctx_t * | ctx, |
amxs_sync_object_t * | object | ||
) |
Adds a synchronization object to a synchronization context.
The synchronization object can be be created using amxs_sync_object_new.
Adding the synchronization object fails when:
If the context attributes are more strict than those of the object, the object attributes will be updated to match those of the context.
ctx | Pointer to a synchronization context. |
object | Pointer to a synchronization object. |
Definition at line 916 of file amxs_sync_ctx.c.
amxs_status_t amxs_sync_ctx_add_param | ( | amxs_sync_ctx_t * | ctx, |
amxs_sync_param_t * | param | ||
) |
Adds a synchronization parameter to a synchronization context.
The synchronization parameter can be be created using amxs_sync_param_new.
Adding the synchronization parameter fails when:
If the context attributes are more strict than those of the parameter, the parameter attributes will be updated to match those of the context.
ctx | Pointer to a synchronization context. |
param | Pointer to a synchronization parameter. |
Definition at line 868 of file amxs_sync_ctx.c.
void amxs_sync_ctx_clean | ( | amxs_sync_ctx_t * | ctx | ) |
Synchronization context cleanup function.
Frees any memory that was allocated to store data in this synchronization context.
If the synchronization context has any synchronization objects or parameters attached to it, these will be removed and freed.
ctx | Pointer to a synchronization context. |
Definition at line 752 of file amxs_sync_ctx.c.
amxs_status_t amxs_sync_ctx_copy | ( | amxs_sync_ctx_t ** | dest, |
amxs_sync_ctx_t * | src, | ||
void * | priv | ||
) |
Copies an existing synchronization context to a new synchronization context.
When the copy is successful the synchronization object paths must be updated using amxs_sync_ctx_set_paths before starting the synchronization context
dest | Pointer to a synchronization context pointer, will contain the copy. |
src | The synchronization context that will be copied. |
priv | Private data. |
Definition at line 762 of file amxs_sync_ctx.c.
void amxs_sync_ctx_delete | ( | amxs_sync_ctx_t ** | ctx | ) |
Synchronization context destructor function.
Frees all memory allocated for a synchronization context.
If the synchronization context has any synchronization objects or parameters attached to it, these will be removed and freed as well.
ctx | Pointer to a synchronization context pointer. |
Definition at line 727 of file amxs_sync_ctx.c.
amxs_status_t amxs_sync_ctx_init | ( | amxs_sync_ctx_t * | ctx, |
const char * | object_a, | ||
const char * | object_b, | ||
int | attributes | ||
) |
Synchronization context initialization function.
Initializes a synchronization context that was allocated on the stack.
Allocates memory for a new synchronization context and initializes this context.
Use amxs_sync_ctx_clean to make sure that all allocated memory to store the data is freed.
Please note that the attributes that are set on the synchronization context will always override those that are set on syncronization objects or parameters. E.g. when setting the AMXS_SYNC_ONLY_B_TO_A attribute on the context, and setting AMXS_SYNC_DEFAULT on a parameter, the syncronyzation will only be executed from object B to object A.
ctx | Pointer to a synchronization context. |
object_a | Path to the first object to be synchronized, hereafter referenced as object A. |
object_b | Path to the second object to be synchronized, hereafter referenced as object B. |
attributes | Bitwise OR of zero or more of the following attributes: |
Definition at line 738 of file amxs_sync_ctx.c.
|
inlinestatic |
Checks is the synchronization context is running.
Checks if the synchronization context was already startued
ctx | Pointer to a synchronization context. |
Definition at line 231 of file amxs_sync_ctx.h.
amxs_status_t amxs_sync_ctx_new | ( | amxs_sync_ctx_t ** | ctx, |
const char * | object_a, | ||
const char * | object_b, | ||
int | attributes | ||
) |
Synchronization context constructor function.
Allocates memory for a new synchronization context and initializes the context.
Use amxs_sync_ctx_delete to remove the synchronizaion context and free all allocated memory.
The object paths that can be used in a synchronization context must be an absolute path to:
Search paths (key addressing) can be used but must resolve to exatly one object. Key paths can be used as well, but are not recomended.
Creating a synchronization context using template objects paths (ending with a multi-instance object) are not allowed, in this case creation will fail.
ctx | Pointer to a synchronization context pointer. The address of the new allocated synchronization context is stored in this pointer. |
object_a | Path to the first object to be synchronized, hereafter referenced as object A. |
object_b | Path to the second object to be synchronized, hereafter referenced as object B. |
attributes | Bitwise OR of zero or more of the following attributes: |
Definition at line 713 of file amxs_sync_ctx.c.
amxs_status_t amxs_sync_ctx_set_paths | ( | amxs_sync_ctx_t *const | ctx, |
const char * | object_a, | ||
const char * | object_b | ||
) |
Updates the object paths of the synchronization context.
When a copy is made of a synchronization context using amxs_sync_ctx_copy, the object paths of the new synchronization context can be set using this function.
The new set object paths must match the original object paths at supported data model level.
ctx | Pointer to a synchronization context. |
object_a | The new path to object a. |
object_b | The new path to object b. |
Definition at line 828 of file amxs_sync_ctx.c.
amxs_status_t amxs_sync_ctx_start_sync | ( | amxs_sync_ctx_t * | ctx | ) |
Starts the object synchronization.
Starts the synchronization by looking up the initial values and then subscribing for changes on the configured objects and parameters. Synchronization will fail if no objects or parameters are attached to the context.
ctx | Pointer to a synchronization context. |
Definition at line 766 of file amxs_sync_ctx.c.
void amxs_sync_ctx_stop_sync | ( | amxs_sync_ctx_t * | ctx | ) |
Stops the object synchronization.
Stops the synchronization by unsubscribing for changes on the configured objects and parameters.
ctx | Pointer to a synchronization context. |
Definition at line 818 of file amxs_sync_ctx.c.