Tizen Native API
|
IoTCon Resource Types provides API to manage resource types.
#include <iotcon.h>
The IoTCon Resource Types API provides methods for managing handle and add, remove resource types. A resource type indicates a class or category of resources. Example :
#include <iotcon.h> static void _request_handler(iotcon_resource_h resource, iotcon_request_h request, void *user_data) { // handle request ... } static void _create_light_resource() { int ret; iotcon_resource_h resource = NULL; iotcon_resource_interfaces_h resource_ifaces = NULL; iotcon_resource_types_h resource_types = NULL; ret = iotcon_resource_types_create(&resource_types); if (IOTCON_ERROR_NONE != ret) return; ret = iotcon_resource_types_add(resource_types, "org.tizen.light"); if (IOTCON_ERROR_NONE != ret) { iotcon_resource_types_destroy(resource_types); return; } ret = iotcon_resource_interfaces_create(&resource_ifaces); if (IOTCON_ERROR_NONE != ret) iotcon_resource_types_destroy(resource_types); return; ret = iotcon_resource_interfaces_add(resource_ifaces, IOTCON_INTERFACE_DEFAULT); if (IOTCON_ERROR_NONE != ret) { iotcon_resource_interfaces_destroy(resource_ifaces); iotcon_resource_types_destroy(resource_types); return; } ret = iotcon_resource_create("/light/1", resource_types, resource_ifaces, IOTCON_RESOURCE_DISCOVERABLE | IOTCON_RESOURCE_OBSERVABLE, _request_handler, NULL, &resource); if (IOTCON_ERROR_NONE != ret) { iotcon_resource_interfaces_destroy(resource_ifaces); iotcon_resource_types_destroy(resource_types); return; } iotcon_resource_interfaces_destroy(resource_ifaces); iotcon_resource_types_destroy(resource_types); }
This API is related with the following features:
Functions | |
int | iotcon_resource_types_create (iotcon_resource_types_h *types) |
Creates a new resource types handle. | |
int | iotcon_resource_types_destroy (iotcon_resource_types_h types) |
Destroys a resource types handle. | |
int | iotcon_resource_types_add (iotcon_resource_types_h types, const char *type) |
Inserts a resource types into the list. | |
int | iotcon_resource_types_remove (iotcon_resource_types_h types, const char *type) |
Deletes a resource types from the list. | |
int | iotcon_resource_types_foreach (iotcon_resource_types_h types, iotcon_resource_types_foreach_cb cb, void *user_data) |
Gets all of the resource types of the list by invoking the callback function. | |
int | iotcon_resource_types_clone (iotcon_resource_types_h src, iotcon_resource_types_h *dest) |
Clones the resource types handle. | |
Typedefs | |
typedef bool(* | iotcon_resource_types_foreach_cb )(const char *type, void *user_data) |
Specifies the type of function passed to iotcon_resource_types_foreach(). |
typedef bool(* iotcon_resource_types_foreach_cb)(const char *type, void *user_data) |
Specifies the type of function passed to iotcon_resource_types_foreach().
[in] | type | The value of the resource types |
[in] | user_data | The user data to pass to the function |
true
to continue with the next iteration of the loop, otherwise false
to break out of the loop IOTCON_FUNC_CONTINUE and IOTCON_FUNC_STOP are more friendly values for the return int iotcon_resource_types_add | ( | iotcon_resource_types_h | types, |
const char * | type | ||
) |
Inserts a resource types into the list.
[in] | types | The handle of the resource types |
[in] | type | The string data to insert into the resource types (e.g. "org.tizen.light") |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
IOTCON_ERROR_ALREADY | Already done |
int iotcon_resource_types_clone | ( | iotcon_resource_types_h | src, |
iotcon_resource_types_h * | dest | ||
) |
Clones the resource types handle.
Makes a deep copy of a source list of resource types.
[in] | src | The origin handle of the resource types |
[out] | dest | Clone of a source list of resource types |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
int iotcon_resource_types_create | ( | iotcon_resource_types_h * | types | ) |
Creates a new resource types handle.
[out] | types | A newly allocated list of resource types handle |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_OUT_OF_MEMORY | Out of memory |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
int iotcon_resource_types_destroy | ( | iotcon_resource_types_h | types | ) |
Destroys a resource types handle.
[in] | types | The handle of the resource types |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
int iotcon_resource_types_foreach | ( | iotcon_resource_types_h | types, |
iotcon_resource_types_foreach_cb | cb, | ||
void * | user_data | ||
) |
Gets all of the resource types of the list by invoking the callback function.
iotcon_resource_types_foreach_cb() will be called for each type.
If iotcon_resource_types_foreach_cb() returns false, iteration will be stopped.
[in] | types | The handle of resource types |
[in] | cb | The callback function to get data |
[in] | user_data | The user data to pass to the function |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
int iotcon_resource_types_remove | ( | iotcon_resource_types_h | types, |
const char * | type | ||
) |
Deletes a resource types from the list.
[in] | types | The handle of the resource types |
[in] | type | The string data to delete from the resource types |
0
on success, otherwise a negative error value IOTCON_ERROR_NONE | Successful |
IOTCON_ERROR_NOT_SUPPORTED | Not supported |
IOTCON_ERROR_INVALID_PARAMETER | Invalid parameter |
IOTCON_ERROR_NO_DATA | No data available |