|
libamxb
4.8.2
Bus Agnostic C API
|
Functions | |
| int | amxb_call (amxb_bus_ctx_t *const bus_ctx, const char *object, const char *method, amxc_var_t *args, amxc_var_t *ret, int timeout) |
| Invokes a data model function. More... | |
| amxb_request_t * | amxb_async_call (amxb_bus_ctx_t *const bus_ctx, const char *object, const char *method, amxc_var_t *args, amxb_be_done_cb_fn_t done_fn, void *priv) |
| Invokes a data model function. More... | |
| int | amxb_get (amxb_bus_ctx_t *const bus_ctx, const char *object, int32_t depth, amxc_var_t *ret, int timeout) |
| Fetches one or more objects or a single parameter. More... | |
| int | amxb_get_filtered (amxb_bus_ctx_t *const bus_ctx, const char *object, const char *filter, int32_t depth, amxc_var_t *ret, int timeout) |
| Fetches one or more objects and their parameters that are matching a filter. More... | |
| int | amxb_get_multiple (amxb_bus_ctx_t *const bus_ctx, amxc_var_t *req_paths, int32_t depth, amxc_var_t *ret, int timeout) |
| Fetches one or more (root) objects or multiple parameters. More... | |
| int | amxb_set (amxb_bus_ctx_t *const bus_ctx, const char *object, amxc_var_t *values, amxc_var_t *ret, int timeout) |
| Sets parameter values of one single object or of multiple instance objects. More... | |
| int | amxb_set_multiple (amxb_bus_ctx_t *const bus_ctx, uint32_t flags, amxc_var_t *req_paths, amxc_var_t *ret, int timeout) |
| Sets parameter values for multiple objects (request paths) More... | |
| int | amxb_add (amxb_bus_ctx_t *const bus_ctx, const char *object, uint32_t index, const char *name, amxc_var_t *values, amxc_var_t *ret, int timeout) |
| Adds an instance to a multi-instance object. More... | |
| int | amxb_del (amxb_bus_ctx_t *const bus_ctx, const char *object, uint32_t index, const char *name, amxc_var_t *ret, int timeout) |
| Deletes one or more instances of a multi-instance object. More... | |
| int | amxb_get_supported (amxb_bus_ctx_t *const bus_ctx, const char *object, uint32_t flags, amxc_var_t *ret, int timeout) |
| Gets the supported data model. More... | |
| int | amxb_describe (amxb_bus_ctx_t *const bus_ctx, const char *object, uint32_t flags, amxc_var_t *ret, int timeout) |
| Describes an object. More... | |
| int | amxb_list (amxb_bus_ctx_t *const bus_ctx, const char *object, uint32_t flags, amxb_be_cb_fn_t fn, void *priv) |
| List the service elements/nodes of an object. More... | |
| int | amxb_get_instances (amxb_bus_ctx_t *const bus_ctx, const char *search_path, int32_t depth, amxc_var_t *ret, int timeout) |
| Fetches the instances and the unique keys of a multi-instance object. More... | |
| int amxb_add | ( | amxb_bus_ctx_t *const | bus_ctx, |
| const char * | object, | ||
| uint32_t | index, | ||
| const char * | name, | ||
| amxc_var_t * | values, | ||
| amxc_var_t * | ret, | ||
| int | timeout | ||
| ) |
Adds an instance to a multi-instance object.
Using this method, an instance can be created and the parameters values of that instance can be set.
It is not possible to create an instance for a read-only multi instance object.
It is not possible to set the value of read-only parameters using this function.
This function supports following paths:
The parameter values must be passed as a variant containing a hash-table where each key is a parameter name and the value is the value for that parameter.
It is possible to choose the index (instance identifier) of the new instance using the index argument. The index provided must not be in use, otherwise the creation of the instance fails. When specifying 0 as the index, the next available index will be chosen. The automatic instance numbering never re-uses an already used index, even if the instance that was using the index has been deleted.
Optionally a name can be specified for the instance. When the multi-instance object has an "Alias" parameter that is defined as a "unique key", the name is used as the value for the "Alias" parameter. When no name needs to be set a NULL pointer can be passed.
When the multi-instance object has "key" parameters the values of these parameters must be given using the "values" argument, except for the "Alias" parameter if a name is provided. The values of "key" parameters can only be set when the instance is created, and are immutable.
Values of non key parameters are optional and can be set later with amxb_set function.
The return value of an add is always an Ambiorix variant and will contain the newly created instance and all its key parameters.
Example of a return variant:
| bus_ctx | The bus context (or connection) |
| object | Full multi-instance object path |
| index | the index of the instance set to 0 to assign an index automatically |
| name | the name of the instance, or when an Alias parameter exists, the value for the Alias. The name can be NULL. |
| values | variant hash-table containing the parameter values, can be NULL when key parameters are defined, at least the key parameters must be set and present in the hash-table. |
| ret | will contain the created object, its key parameters and exta information |
| timeout | in seconds |
Definition at line 115 of file amxb_ba_op_add.c.
| amxb_request_t* amxb_async_call | ( | amxb_bus_ctx_t *const | bus_ctx, |
| const char * | object, | ||
| const char * | method, | ||
| amxc_var_t * | args, | ||
| amxb_be_done_cb_fn_t | done_fn, | ||
| void * | priv | ||
| ) |
Invokes a data model function.
Calls a data model method. A data model method is a function that is exposed in the data model in a specific object.
The arguments passed must be in a amxc variant of type AMXC_VAR_ID_HTABLE. The order of the arguments is not important.
This function makes uses of amxb_new_invoke and amxb_async_invoke.
When the method call fails, the done function is called with NULL as amxb_request_t and the status will be the failure status.
The returned amxb_request_t pointer can be used with amxb_wait_for_request to wait until the method call is finished.
The returned pointer must be freed with amxb_close_request. After calling amxb_close_request, the callback function will not be called anymore.
| bus_ctx | The bus context (or connection) |
| object | object path to the object that contains the function, object paths must end with a "." |
| method | name of the function being called |
| args | the function arguments in a amxc variant htable type |
| done_fn | a done callback function |
| priv | private data that will be passed to the callback function (optional, can be NULL) |
Definition at line 98 of file amxb_ba_op_call.c.
| int amxb_call | ( | amxb_bus_ctx_t *const | bus_ctx, |
| const char * | object, | ||
| const char * | method, | ||
| amxc_var_t * | args, | ||
| amxc_var_t * | ret, | ||
| int | timeout | ||
| ) |
Invokes a data model function.
Calls a data model method. A data model method is a function that is exposed in the data model in a specific object.
The arguments passed must be in a amxc variant of type AMXC_VAR_ID_HTABLE. The order of the arguments is not important.
This function makes uses of amxb_new_invoke and Remote Function Invoke.
If no response is received before the timeout expires, this function will return an error, but it is possible that the RPC method is still busy.
| bus_ctx | The bus context (or connection) |
| object | object path to the object that contains the function, object paths must end with a "." |
| method | name of the function being called |
| args | the function arguments in a amxc variant htable type |
| ret | will contain the return value(s) and/or the out arguments |
| timeout | in seconds |
Definition at line 78 of file amxb_ba_op_call.c.
| int amxb_del | ( | amxb_bus_ctx_t *const | bus_ctx, |
| const char * | object, | ||
| uint32_t | index, | ||
| const char * | name, | ||
| amxc_var_t * | ret, | ||
| int | timeout | ||
| ) |
Deletes one or more instances of a multi-instance object.
Using this method, one or more instances can be deleted from a multi-instance object.
It is not possible to delete instances from a read-only multi instance object.
This function supports following paths:
The provided paths must either result or point to:
When the given path is a multi-instance object, an index or name of the instance that will be deleted must be given. If both an index (instance identifier) and a name are given, the index takes precedence.
When the given path is an instance path, index and name arguments are ignored.
When the given path is a search path where multiple-instances match, all of the matching instances will be deleted and the index and name arguments are ignored.
The full list of deleted objects is returned in a variant containing an array of all deleted object paths, this includes the full tree underneath the delete instance(s).
| bus_ctx | The bus context (or connection) |
| object | Full object path or search path |
| index | the index of the instance that will be deleted |
| name | the name of the instance that will be deleted |
| ret | will contain a list of all deleted objects |
| timeout | in seconds |
Definition at line 117 of file amxb_ba_op_del.c.
| int amxb_describe | ( | amxb_bus_ctx_t *const | bus_ctx, |
| const char * | object, | ||
| uint32_t | flags, | ||
| amxc_var_t * | ret, | ||
| int | timeout | ||
| ) |
Describes an object.
This function is mainly used for data model introspection. Besides the values of the parameters, more information can be obtained.
Information included in the returned data structure is:
Use this function for introspection purposes.
Using the flags argument, the requested information can be manipulated:
All other flags will be ignored.
The return value of this function is always an Ambiorix variant and will contain the requested information. The return data is stored in the ret argument.
Example of a return variant:
| bus_ctx | The bus context (or connection) |
| object | The object path |
| flags | bitmap field of or'ed flags |
| ret | will contain the requested information |
| timeout | in seconds |
Definition at line 114 of file amxb_ba_op_describe.c.
| int amxb_get | ( | amxb_bus_ctx_t *const | bus_ctx, |
| const char * | object, | ||
| int32_t | depth, | ||
| amxc_var_t * | ret, | ||
| int | timeout | ||
| ) |
Fetches one or more objects or a single parameter.
Using this method, the parameter values of an object can be retrieved.
It is possible to get the parameters from multiple objects at once or to get one single parameter of one or more objects.
This function supports following paths:
In a search path a wildcard "*" or an expression can be put where an instance identifier (instance index) is in an object path.
Examples of valid search paths:
The return value of a get is always an Ambiorix variant:
| bus_ctx | The bus context (or connection) |
| object | Full object path, search path or parameter path |
| depth | relative depth, if not zero it indicates how many levels of child objects are returned |
| ret | will contain the objects and their parameters |
| timeout | in seconds |
Definition at line 114 of file amxb_ba_op_get.c.
| int amxb_get_filtered | ( | amxb_bus_ctx_t *const | bus_ctx, |
| const char * | object, | ||
| const char * | filter, | ||
| int32_t | depth, | ||
| amxc_var_t * | ret, | ||
| int | timeout | ||
| ) |
Fetches one or more objects and their parameters that are matching a filter.
Using this method, the parameter values of an object can be retrieved. This function works exactly the same as amxb_get, but can filter the parameters of an object on the meta-data.
For more details see amxb_get.
The meta-data of the parameters can be retrieved using amxb_describe. If a filter is provided, the filter will be evaluated on the meta-data of the parameters, only matching parameters will be available in the result data.
Example of parameter meta-data:
Example of a filter:
The above filter example will only return parameters that have the persistent attribute set or have the flag "usersetting", all other parameters will be filtered out.
If no filter (NULL or empty string) is provided, this function will return exactly the same as amxb_get.
| bus_ctx | The bus context (or connection) |
| object | Full object path, search path or parameter path |
| filter | Logical filter expression, only matching parameters are returned. |
| depth | relative depth, if not zero it indicates how many levels of child objects are returned |
| ret | will contain the objects and their parameters |
| timeout | in seconds |
Definition at line 122 of file amxb_ba_op_get.c.
| int amxb_get_instances | ( | amxb_bus_ctx_t *const | bus_ctx, |
| const char * | search_path, | ||
| int32_t | depth, | ||
| amxc_var_t * | ret, | ||
| int | timeout | ||
| ) |
Fetches the instances and the unique keys of a multi-instance object.
Using this method, the instances of a multi-instance object and their unique keys can be retrieved.
It is possible to get the instances and keys from child objects of the provided multi-instance object as well by specifying a depth larger than 0.
This function supports following paths:
In a search path a wildcard "*" or an expression can be put where an instance identifier (instance index) is in an object path.
Examples of valid search paths:
The return value of a get instances is always an Ambiorix variant:
In the above example, the FirstName parameter was a unique key parameter
| bus_ctx | The bus context (or connection) |
| object | Multi-instance object path or search path |
| depth | relative depth, if not zero it indicates for how many levels the child instances are returned |
| ret | will contain the objects and their keys |
| timeout | in seconds |
Definition at line 121 of file amxb_ba_op_get_instances.c.
| int amxb_get_multiple | ( | amxb_bus_ctx_t *const | bus_ctx, |
| amxc_var_t * | req_paths, | ||
| int32_t | depth, | ||
| amxc_var_t * | ret, | ||
| int | timeout | ||
| ) |
Fetches one or more (root) objects or multiple parameters.
It is possible to get the parameters from multiple objects at once or to get one single parameter of one or more objects.
This function supports an amxc linked list with paths, each path must follow these rules:
In a search path a wildcard "*" or an expression can be put where an instance identifier (instance index) is in an object path.
Examples of valid use case:
The return value of a get_multiple is always an Ambiorix htable variant containing the individual responses from amxb_get for each path:
| bus_ctx | The bus context (or connection) |
| req_paths | Amxc variant containing a list of all paths to search for. |
| depth | relative depth, if not zero it indicates how many levels of child objects are returned. This depth is the same for all paths. |
| ret | will contain an amxc variant containing a htable with the objects and their parameters |
| timeout | in seconds (for every individual amxb_get lookup) |
Definition at line 78 of file amxb_ba_op_get_multiple.c.
| int amxb_get_supported | ( | amxb_bus_ctx_t *const | bus_ctx, |
| const char * | object, | ||
| uint32_t | flags, | ||
| amxc_var_t * | ret, | ||
| int | timeout | ||
| ) |
Gets the supported data model.
This function is mainly used to have support for the USP "get supported dm" message.
Use this function for introspection purposes.
This function does not return any instance, it only indicates which objects are multi-instance objects. The place in the object path where normally an instance identifier (index) is set, the place holder "{i}" is used.
The object argument must be in this supported data model notation.
Example:
Using the flags argument, the requested information can be manipulated:
All other flags will be ignored.
The return value of this function is always an Ambiorix variant and will contain the requested information. The return data is stored in the ret argument.
Example of a return variant:
| bus_ctx | The bus context (or connection) |
| object | The object path (in supported path notation) |
| flags | bitmap field of or'ed flags |
| ret | will contain the requested information |
| timeout | in seconds |
Definition at line 113 of file amxb_ba_op_get_sup.c.
| int amxb_list | ( | amxb_bus_ctx_t *const | bus_ctx, |
| const char * | object, | ||
| uint32_t | flags, | ||
| amxb_be_cb_fn_t | fn, | ||
| void * | priv | ||
| ) |
List the service elements/nodes of an object.
This function is mainly used for data model introspection and provides list of the service elements/nodes that are part of the object
Use this function for introspection purposes.
Using the flags argument, the requested information can be manipulated:
All other flags will be ignored.
| bus_ctx | The bus context (or connection) |
| object | The object path (in supported path notation) |
| flags | bitmap field of ored flags |
| fn | callback function |
| priv | private data that will be passed as is to the callback function |
Definition at line 177 of file amxb_ba_op_list.c.
| int amxb_set | ( | amxb_bus_ctx_t *const | bus_ctx, |
| const char * | object, | ||
| amxc_var_t * | values, | ||
| amxc_var_t * | ret, | ||
| int | timeout | ||
| ) |
Sets parameter values of one single object or of multiple instance objects.
Using this method, the parameter values of an object can be changed.
It is not possible to change read-only parameter values using this function.
This function supports following paths:
In a search path a wildcard "*" or an expression can be put where an instance identifier (instance index) is in an object path.
Examples of valid search paths:
The parameter values must be passed as a variant containing a hash-table where each key is a parameter name and the value is the new value for that parameter.
When using a search path and multiple instances match the search path, all the mentioned parameters are modified for all matching instances.
The return value of a set is always an Ambiorix variant and will contain all changed objects, and the changed parameters. Unchanged parameters are not provided in the return value.
Example: When changing all "LastNames" to "Ambiorix" of all contacts using search path "Phonebook.Contact.*" the return value could be
| bus_ctx | The bus context (or connection) |
| object | Full object path, search path or parameter path |
| values | variant hash-table containing the new values |
| ret | will contain the objects and their changed parameters |
| timeout | in seconds |
Definition at line 172 of file amxb_ba_op_set.c.
| int amxb_set_multiple | ( | amxb_bus_ctx_t *const | bus_ctx, |
| uint32_t | flags, | ||
| amxc_var_t * | req_paths, | ||
| amxc_var_t * | ret, | ||
| int | timeout | ||
| ) |
Sets parameter values for multiple objects (request paths)
Using this method, the parameter values of an object can be changed.
It is not possible to change read-only parameter values using this function.
This function supports following paths:
In a search path a wildcard "*" or an expression can be put where an instance identifier (instance index) is in an object path.
Examples of valid search paths:
The parameter values must be passed as a variant containing a hash-table where each key is a parameter name and the value is the new value for that parameter.
When using a search path and multiple instances match the search path, all the mentioned parameters are modified for all matching instances.
The return value of a set is always an Ambiorix variant and will contain all changed objects, and the changed parameters. Unchanged parameters are not provided in the return value. For each request path a status is added as well.
When the status code is 0, the set for that request path was successful. All other status codes indicate an error and is always referring to one of the amxd_status_t enum.
When the flag AMXB_FLAG_PARTIAL is set, an error code is returned for each parameter that could not be set. The error code is one of the amxd_status_t codes.
When failed to set an optional parameter, an error code is returned for that parameter.
Example of a valid req_paths variant:
The above req_paths variant will return in case AMXB_FLAG_PARTIAL is provided:
In case the AMXB_FLAG_PARTIAL is not provided only the first failing request path is returned and all others are not applied.
| bus_ctx | The bus context (or connection) |
| flags | Supported flags are AMXB_FLAG_PARTIAL. |
| req_paths | hash-table variant containing the request paths and parameters to be set |
| ret | will contain for each request path the result and status |
| timeout | in seconds |
Definition at line 141 of file amxb_ba_op_set_multiple.c.