Add method of Things-Manager.
authorHyunJun Kim <hyunjun2.kim@samsung.com>
Wed, 14 Jan 2015 08:52:28 +0000 (17:52 +0900)
committerSudarshan Prasad <sudarshan.prasad@intel.com>
Thu, 22 Jan 2015 16:04:37 +0000 (16:04 +0000)
It was not included implementation.
So We implement about bindResourceToGroup for Group Formation feature.

Change-Id: Iade53004d8b3d974846a3b9056c6c3b6649104fa
Signed-off-by: HyunJun Kim <hyunjun2.kim@samsung.com>
(cherry picked from commit dab7666e8db685c0a4dc16a1f1ed38e79e9ce219)
Reviewed-on: https://gerrit.iotivity.org/gerrit/218
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Sudarshan Prasad <sudarshan.prasad@intel.com>
service/things-manager/sdk/src/GroupManager.cpp
service/things-manager/sdk/src/GroupManager.h
service/things-manager/sdk/src/ThingsManager.cpp

index 216ac0b..ca8c190 100644 (file)
@@ -238,6 +238,28 @@ OCStackResult GroupManager::findCandidateResources(std::vector< std::string > re
     return OC_STACK_OK;
 }
 
+
+OCStackResult GroupManager::bindResourceToGroup(OCResourceHandle& childHandle, std::shared_ptr< OCResource > resource, OCResourceHandle& collectionHandle)
+{
+
+    OCStackResult result = OCPlatform::registerResource(childHandle, resource);
+
+    cout << "\tresource registed!" << endl;
+
+    if(result == OC_STACK_OK)
+    {
+        OCPlatform::bindResource(collectionHandle, childHandle);
+    }
+    else
+    {
+        cout << "\tresource Error!" << endl;
+    }
+
+    return result;
+ }
+
+
+
 /*
  Presence Check
  */
index d0dad45..5a2d6cc 100644 (file)
@@ -117,6 +117,8 @@ public:
     OCStackResult subscribeCollectionPresence(std::shared_ptr< OCResource > resource,
             CollectionPresenceCallback);
 
+    OCStackResult bindResourceToGroup(OCResourceHandle& childHandle, std::shared_ptr< OCResource > resource, OCResourceHandle& collectionHandle);
+
 private:
 
     void onFoundResource(std::shared_ptr< OCResource > resource, int waitsec);
index a65b987..9009612 100644 (file)
@@ -76,6 +76,13 @@ namespace OIC
         return result;
     }
 
+    OCStackResult ThingsManager::bindResourceToGroup(OCResourceHandle& childHandle, std::shared_ptr< OCResource > resource, OCResourceHandle& collectionHandle)
+    {
+        OCStackResult result = g_groupManager->bindResourceToGroup(childHandle,resource,collectionHandle);
+
+        return result;
+    }
+
     OCStackResult ThingsManager::findGroup(std::vector< std::string > collectionResourceTypes,
             FindCallback callback)
     {