User Tools

Site Tools


collection_resource

Collection Resource

Collections are containers that hold references to resources. An OIC Collection is an OIC resource that contains one or more references (specified as OIC Links) to other OIC Resources. An OIC Link embraces and extends typed “web links” as specified in RFC 5988.

A collection is a response of the structure returned by the server. Collections include multiple links that are combined together to respond to a query. Resources that form together for collection may or may not be related to each other.

In Iotivity, the server creates collection resources. First, a resource must be created using createResource. Then, the bindResource API is used to combine resources to form a collection.

C API

OCBindResource - adds a resource to a collection resource:

OCStackResult OCBindResource(OCResourceHandle collectionHandle, OCResourceHandle resourceHandle);

OCUnBindResource - unbinds a resource from the collection:

OCStackResult OCUnBindResource(OCResourceHandle collectionHandle, OCResourceHandle resourceHandle); 

Example

The following code examples demonstrates how to create resources and assigned them to a collection resource with the OCbindResource API.

C++ API

OCPlatform::bindResource - Add a resource to a collection resource:

OCStackResult bindResource(const OCResourceHandle collectionHandle, const OCResourceHandle resourceHandle);

OCPlatform::bindResources - Add multiple resources to a collection resource:

OCStackResult bindResources(const OCResourceHandle collectionHandle, const std::vector<OCResourceHandle>& addedResourceHandleList);

OCPlatform::unbindResource - Unbind a resource from a collection resource:

OCStackResult unbindResource(const OCResourceHandle collectionHandle, const OCResourceHandle resourceHandle);

OCPlatform::unbindResources - Unbind multiple resources from a collection resource:

OCStackResult unbindResources(const OCResourceHandle collectionHandle, const std::vector<OCResourceHandle>& resourceHandleList);

Example

The following code examples demonstrates how to create resources and assigned them to a collection resource with OCPlatform::bindResource.

collection_resource.txt · Last modified: 2017/04/04 22:05 by Ben Lloyd Pearson