Added the possible APIs for binding a resource to another resource. This is for resou...
authorSudarshan Prasad <sudarshan.prasad@intel.com>
Fri, 8 Aug 2014 09:34:56 +0000 (02:34 -0700)
committerSudarshan Prasad <sudarshan.prasad@intel.com>
Fri, 8 Aug 2014 09:34:56 +0000 (02:34 -0700)
OCLib/OCPlatform.cpp
include/OCPlatform.h

index dae4a2b2fa7d6443703f12c7457fee9127fe6ae0..0251b9dded2212441df2b88a270b3604246544bd 100644 (file)
@@ -125,4 +125,31 @@ namespace OC
         return result;
     }
 
+    // TODO: Implement
+    OCStackResult OCPlatform::bindResourceToContainer(OCResourceHandle containerHandle, OCResourceHandle addedResourceHandle)
+    {
+        OCStackResult result = OC_STACK_OK;
+        return result;
+    }
+
+    // TODO: Implement
+    OCStackResult OCPlatform::bindResourcesToContainer(OCResourceHandle containerHandle, std::vector<OCResourceHandle>& addedResourceHandleList)
+    {
+        OCStackResult result = OC_STACK_OK;
+        return result;
+    }
+
+    // TODO: Implement
+    OCStackResult OCPlatform::unbindResource(OCResourceHandle containerHandle, OCResourceHandle resourceHandle)
+    {
+        OCStackResult result = OC_STACK_OK;
+        return result;
+    }
+
+    // TODO: Implement
+    OCStackResult OCPlatform::unbindResources(OCResourceHandle containerHandle, std::vector<OCResourceHandle>& resourceHandleList)
+    {
+        OCStackResult result = OC_STACK_OK;
+        return result;
+    }
 } //namespace OC
index 39d8a203e728e7208f96d99e2a861111516d3fac..481890de7b79c10011a1291543a1c1092be2e0af 100644 (file)
@@ -127,6 +127,85 @@ namespace OC
                         std::function<void(const OCResourceRequest::Ptr, const OCResourceResponse::Ptr)> entityHandler, 
                         uint8_t resourceProperty);
 
+        /**
+        * Add a resource to a container resource.
+        *
+        * @param containerHandle - handle to the container resource
+        * @param addedResourceHandle - handle to resource to be added to the container resource
+        *
+        * @return OCStackResult return value of this API. Returns OC_STACK_OK if success.<br>
+        * NOTE: OCStackResult is defined in ocstack.h. <br>
+        * NOTE: bindResourceToContainer must be used only after the both container resource and 
+        * resource to add under a container are created and respective handles obtained<br>
+        * <b>Example:</b> <br>
+        * Step 1: registerResource(homeResourceHandle, "a/home", "home", Link_Interface, entityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);<br>
+        * Step 2: registerResource(kitchenResourceHandle, "a/kitchen", "kitchen", Link_Interface, entityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);<br>
+        * Step 3: bindResourceToContainer(homeResourceHandle, kitchenResourceHandle);<br>
+        * At the end of Step 3, resource "a/home" will contain a reference to "a/kitchen".<br> 
+        */
+        OCStackResult bindResourceToContainer(OCResourceHandle containerHandle, OCResourceHandle addedResourceHandle);
+
+        /**
+        * Add multiple resources to a container resource.
+        *
+        * @param containerHandle - handle to the container resource
+        * @param addedResourceHandleList reference to list of resource handles to be added to the container resource
+        *
+        * @return OCStackResult return value of this API. Returns OC_STACK_OK if success. <br>
+        * NOTE: OCStackResult is defined in ocstack.h. <br>
+        * NOTE: bindResourcesToContainer must be used only after the both container resource and 
+        * list of resources to add under a container are created and respective handles obtained <br>
+        * <b> Example: </b> <br>
+        * Step 1: registerResource(homeResourceHandle, "a/home", "home", Link_Interface, homeEntityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);<br>
+        * Step 2: registerResource(kitchenResourceHandle, "a/kitchen", "kitchen", Link_Interface, kitchenEntityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);<br>
+        * Step 3: registerResource(roomResourceHandle, "a/room", "room", Link_Interface, roomEntityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);<br>
+        * Step 4: std::vector<OCResourceHandle> rList; rList.push_back(kitchenResourceHandle); rList.push_back(roomResourceHandle);<br>
+        * Step 5: bindResourceToContainer(homeResourceHandle, rList);<br>
+        * At the end of Step 5, resource "a/home" will contain a references to "a/kitchen" and "a/room" <br>
+        */
+        OCStackResult bindResourcesToContainer(OCResourceHandle containerHandle, std::vector<OCResourceHandle>& addedResourceHandleList);
+
+        /**
+        * Unbind a resource from a container resource.
+        *
+        * @param containerHandle - handle to the container resource
+        * @param resourceHandle resource handle to be unbound from the container resource
+        *
+        * @return OCStackResult return value of this API. Returns OC_STACK_OK if success. <br>
+        * NOTE: OCStackResult is defined in ocstack.h.<br>
+        * NOTE: unbindResource must be used only after the both container resource and 
+        * resource to unbind from a container are created and respective handles obtained<br>
+        * <b> Example </b> <br>
+        * Step 1: registerResource(homeResourceHandle, "a/home", "home", Link_Interface, entityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);<br>
+        * Step 2: registerResource(kitchenResourceHandle, "a/kitchen", "kitchen", Link_Interface, entityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);<br>
+        * Step 3: bindResourceToContainer(homeResourceHandle, kitchenResourceHandle);<br>
+        * Step 4: unbindResource(homeResourceHandle, kitchenResourceHandle);<br>
+        * At the end of Step 4, resource "a/home" will no longer reference "a/kitchen". <br>
+        */
+        OCStackResult unbindResource(OCResourceHandle containerHandle, OCResourceHandle resourceHandle);
+     
+        /**
+        * Unbind resources from a container resource.
+        *
+        * @param containerHandle - handle to the container resource
+        * @param resourceHandleList List of resource handles to be unbound from the container resource
+        *
+        * @return OCStackResult return value of this API. Returns OC_STACK_OK if success. <br>
+        * 
+        * NOTE: OCStackResult is defined in ocstack.h.<br>
+        * NOTE: unbindResources must be used only after the both container resource and 
+        * list of resources resource to unbind from a container are created and respective handles obtained. <br>
+        * <b>Example</b> <br>
+        * Step 1: registerResource(homeResourceHandle, "a/home", "home", Link_Interface, homeEntityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);<br>
+        * Step 2: registerResource(kitchenResourceHandle, "a/kitchen", "kitchen", Link_Interface, kitchenEntityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);<br>
+        * Step 3: registerResource(roomResourceHandle, "a/room", "room", Link_Interface, roomEntityHandler, OC_DISCOVERABLE | OC_OBSERVABLE);<br>
+        * Step 4: std::vector<OCResourceHandle> rList; rList.push_back(kitchenResourceHandle); rList.push_back(roomResourceHandle);<br>
+        * Step 5: bindResourceToContainer(homeResourceHandle, rList);<br>
+        * Step 6: unbindResources(homeResourceHandle, rList);<br>
+        * At the end of Step 6, resource "a/home" will no longer reference to "a/kitchen" and "a/room"<br>
+        */
+        OCStackResult unbindResources(OCResourceHandle containerHandle, std::vector<OCResourceHandle>& resourceHandleList);
+
     private:
         std::unique_ptr<WrapperFactory> m_WrapperInstance;
         IServerWrapper::Ptr m_server;