Optional group of functions to support OCF compliant collections.
More...
|
void | oc_add_collection (oc_resource_t *collection) |
| Adds a collection to the list of collections. More...
|
|
void | oc_collection_add_link (oc_resource_t *collection, oc_link_t *link) |
| Adds the link to the collection. More...
|
|
bool | oc_collection_add_mandatory_rt (oc_resource_t *collection, const char *rt) |
| Add a mandatory Resource Type to a collection. More...
|
|
bool | oc_collection_add_supported_rt (oc_resource_t *collection, const char *rt) |
| Add a supported Resource Type to a collection. More...
|
|
oc_resource_t * | oc_collection_get_collections (void) |
| Gets all known collections. More...
|
|
oc_link_t * | oc_collection_get_links (oc_resource_t *collection) |
| Returns the list of links belonging to this collection. More...
|
|
void | oc_collection_remove_link (oc_resource_t *collection, oc_link_t *link) |
| Removes a link from the collection. More...
|
|
bool | oc_collections_add_rt_factory (const char *rt, oc_resource_get_instance_t get_instance, oc_resource_free_instance_t free_instance) |
| adds the resource type factory More...
|
|
void | oc_delete_collection (oc_resource_t *collection) |
| Deletes the specified collection. More...
|
|
void | oc_delete_link (oc_link_t *link) |
| Deletes the link. More...
|
|
void | oc_link_add_link_param (oc_link_t *link, const char *key, const char *value) |
| Adds a link parameter with specified key and value. More...
|
|
void | oc_link_add_rel (oc_link_t *link, const char *rel) |
| Adds a relation to the link. More...
|
|
oc_resource_t * | oc_new_collection (const char *name, const char *uri, uint8_t num_resource_types, size_t device) |
| Creates a new empty collection. More...
|
|
oc_link_t * | oc_new_link (oc_resource_t *resource) |
| Creates a new link for collections with the specified resource. More...
|
|
Optional group of functions to support OCF compliant collections.
◆ oc_resource_free_instance_t
Callback invoked to delete an resource.
◆ oc_resource_get_instance_t
Callback invoked to retrieve an resource.
◆ oc_add_collection()
Adds a collection to the list of collections.
If the caller makes the collection discoverable, then it will be included in the collection discovery once it has been added with this function.
- Parameters
-
[in] | collection | Collection to add to the list of collections. Must not be NULL. Must not be added twice or a list corruption will occur. The collection is not copied. |
- See also
- oc_resource_set_discoverable
-
oc_new_collection
◆ oc_collection_add_link()
void oc_collection_add_link |
( |
oc_resource_t * |
collection, |
|
|
oc_link_t * |
link |
|
) |
| |
Adds the link to the collection.
- Parameters
-
[in,out] | collection | Collection to add the link to. Must not be NULL |
[in] | link | Link to add to the collection. The link is not copied. Must not be NULL. Must not be added again to this or a different collection or a list corruption will occur. To re-add it, remove the link first. |
- See also
- oc_new_link
-
oc_collection_remove_link
◆ oc_collection_add_mandatory_rt()
bool oc_collection_add_mandatory_rt |
( |
oc_resource_t * |
collection, |
|
|
const char * |
rt |
|
) |
| |
Add a mandatory Resource Type to a collection.
This will be come the "rts-m" property of the collection. The "rts-m" property is an array of Resource Types that are mandatory to be exposed with in an array of Links exposed by the collection.
- Parameters
-
[in] | collection | the collection the the Resource Type will be added to |
[in] | rt | the mandatory Resource Type being added to the collection |
- Returns
- true on success
◆ oc_collection_add_supported_rt()
bool oc_collection_add_supported_rt |
( |
oc_resource_t * |
collection, |
|
|
const char * |
rt |
|
) |
| |
Add a supported Resource Type to a collection.
This will become the "rts" property of the collection. The "rts" property is an array of Resource Types that are supported within an array of Links exposed by the collection.
- Parameters
-
[in] | collection | the collection the the Resource Type will be added to |
[in] | rt | the supported Resource Type being added to the collection |
- Returns
- true on success
◆ oc_collection_get_collections()
Gets all known collections.
- Returns
- All collections that have been added via oc_add_collection(). The collections are not copied. Returns NULL if there are no collections. Collections created only via oc_new_collection() but not added will not be returned by this function.
◆ oc_collection_get_links()
Returns the list of links belonging to this collection.
- Parameters
-
[in] | collection | Collection to get the links from. |
- Returns
- All links of this collection. The links are not copied. Returns NULL if the collection is NULL or contains no links.
- See also
- oc_collection_add_link
◆ oc_collection_remove_link()
void oc_collection_remove_link |
( |
oc_resource_t * |
collection, |
|
|
oc_link_t * |
link |
|
) |
| |
Removes a link from the collection.
- Parameters
-
[in,out] | collection | Collection to remove the link from. Does nothing if this is NULL |
[in] | link | The link to remove. Does nothing if this is NULL or not part of the collection. The link and its resource are not freed. |
◆ oc_collections_add_rt_factory()
adds the resource type factory
- Parameters
-
rt | the resource type |
get_instance | creates the instance of the resource type |
free_instance | sets callback to free the created instance of the resource tupe |
- Returns
- true
-
false
◆ oc_delete_collection()
Deletes the specified collection.
The function removes the collection from the internal list of collections and releases all direct resources and links associated with this collection.
- Note
- The function does not delete the resources set in the links. The caller needs to do this on her/his own in case these are no longer required.
- Parameters
-
[in,out] | collection | The pointer to the collection to delete. If this is NULL, the function does nothing |
- See also
- oc_collection_get_links
-
oc_delete_link
◆ oc_delete_link()
void oc_delete_link |
( |
oc_link_t * |
link | ) |
|
Deletes the link.
- Note
- The function neither removes the resource set on this link nor does it remove it from any collection.
- Parameters
-
[in,out] | link | The link to delete. The function does nothing, if the parameter is NULL |
◆ oc_link_add_link_param()
void oc_link_add_link_param |
( |
oc_link_t * |
link, |
|
|
const char * |
key, |
|
|
const char * |
value |
|
) |
| |
Adds a link parameter with specified key and value.
- Parameters
-
[in,out] | link | Link to which to add a link parameter. Must not be NULL |
[in] | key | Key to identify the link parameter. Must not be NULL |
[in] | value | Link parameter value. Must not be NULL |
◆ oc_link_add_rel()
void oc_link_add_rel |
( |
oc_link_t * |
link, |
|
|
const char * |
rel |
|
) |
| |
Adds a relation to the link.
- Parameters
-
[in,out] | link | Link to add the relation to. Must not be NULL |
[in] | rel | Relation to add. Must not be NULL |
◆ oc_new_collection()
oc_resource_t* oc_new_collection |
( |
const char * |
name, |
|
|
const char * |
uri, |
|
|
uint8_t |
num_resource_types, |
|
|
size_t |
device |
|
) |
| |
Creates a new empty collection.
The collection is created with interfaces OC_IF_BASELINE
, OC_IF_LL
(also default) and OC_IF_B
. Initially it is neither discoverable nor observable.
The function only allocates the collection. Use oc_add_collection() after the setup of the collection is complete.
- Parameters
-
[in] | name | name of the collection |
[in] | uri | Unique URI of this collection. Must not be NULL. |
[in] | num_resource_types | Number of resources the caller will bind with this resource (e.g. by invoking oc_resource_bind_resource_type(col, OIC_WK_COLLECTION) ). Must be 1 or higher. |
[in] | device | The internal device that should carry this collection. This is typically 0. |
- Returns
- A pointer to the new collection (actually
oc_collection_t *
) or NULL if out of memory.
- See also
- oc_add_collection
-
oc_collection_add_link
◆ oc_new_link()
Creates a new link for collections with the specified resource.
- Parameters
-
[in] | resource | Resource to set in the link. The resource is not copied. Must not be NULL |
- Returns
- The created link or NULL if out of memory or resource is NULL.
- See also
- oc_delete_link
-
oc_collection_add_link
-
oc_new_resource