Remove a Things Manager class and expose its component classes for SDK
authorJihun Ha <jihun.ha@samsung.com>
Fri, 4 Sep 2015 07:20:39 +0000 (16:20 +0900)
committerMadan Lanka <lanka.madan@samsung.com>
Sat, 5 Sep 2015 00:27:03 +0000 (00:27 +0000)
Previously, there was a single Thing Manager class for SDK which comprises
ThingsConfiguration, ThingsDiagnostics, GroupManager, and GroupSynchronization
classes. Now, we've decided to keep the components seperately for more
efficient maintenance for each component.

Additionally, to be aligned with OIC spec, a class name of "DiagnosticsCollection" has
been changed into "MaintenanceCollection".

Change-Id: I2b5cbf832abca3ac3ecfcab88e2153cca91a67f6
Signed-off-by: Jihun Ha <jihun.ha@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/2377
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
22 files changed:
service/things-manager/SConscript
service/things-manager/sampleapp/linux/configuration/ConfigurationCollection.cpp [changed mode: 0644->0755]
service/things-manager/sampleapp/linux/configuration/ConfigurationCollection.h [changed mode: 0644->0755]
service/things-manager/sampleapp/linux/configuration/DiagnosticsCollection.cpp [changed mode: 0644->0755]
service/things-manager/sampleapp/linux/configuration/DiagnosticsCollection.h [changed mode: 0644->0755]
service/things-manager/sampleapp/linux/configuration/FactorySetCollection.cpp [changed mode: 0644->0755]
service/things-manager/sampleapp/linux/configuration/FactorySetCollection.h [changed mode: 0644->0755]
service/things-manager/sampleapp/linux/configuration/con-client.cpp [changed mode: 0644->0755]
service/things-manager/sampleapp/linux/configuration/con-server.cpp [changed mode: 0644->0755]
service/things-manager/sampleapp/linux/groupaction/groupserver.cpp [changed mode: 0644->0755]
service/things-manager/sampleapp/linux/groupsyncaction/group.cpp [changed mode: 0644->0755]
service/things-manager/sampleapp/linux/groupsyncaction/musicplayer.cpp [changed mode: 0644->0755]
service/things-manager/sampleapp/linux/groupsyncaction/phone.cpp [changed mode: 0644->0755]
service/things-manager/sampleapp/linux/groupsyncaction/speaker.cpp [changed mode: 0644->0755]
service/things-manager/sdk/inc/GroupManager.h [moved from service/things-manager/sdk/src/GroupManager.h with 57% similarity, mode: 0755]
service/things-manager/sdk/inc/GroupSynchronization.h [new file with mode: 0755]
service/things-manager/sdk/inc/ThingsConfiguration.h [moved from service/things-manager/sdk/src/ThingsConfiguration.h with 99% similarity, mode: 0755]
service/things-manager/sdk/inc/ThingsDiagnostics.h [moved from service/things-manager/sdk/src/ThingsDiagnostics.h with 74% similarity, mode: 0755]
service/things-manager/sdk/inc/ThingsManager.h [deleted file]
service/things-manager/sdk/src/GroupSynchronization.h [deleted file]
service/things-manager/sdk/src/ThingsDiagnostics.cpp [changed mode: 0644->0755]
service/things-manager/sdk/src/ThingsManager.cpp [deleted file]

index 1649324..bb602b6 100644 (file)
@@ -53,20 +53,22 @@ if target_os == 'android':
 ######################################################################
 # Source files and Targets
 ######################################################################
-tgm_src = env.Glob('sdk/src/*.cpp', '../../extlibs/timer/timer.c')
-tgmsdk_static = things_manager_env.StaticLibrary('TGMSDKLibrary', tgm_src)
-tgmsdk_shared = things_manager_env.SharedLibrary('TGMSDKLibrary', tgm_src)
 
-things_manager_env.InstallTarget([tgmsdk_static,tgmsdk_shared], 'libTGMSDK')
-things_manager_env.UserInstallTargetLib([tgmsdk_static,tgmsdk_shared], 'libTGMSDK')
-things_manager_env.UserInstallTargetHeader('sdk/inc/ActionSet.h', 'service/things-manager', 'ActionSet.h')
-things_manager_env.UserInstallTargetHeader('sdk/inc/ThingsManager.h', 'service/things-manager', 'ThingsManager.h')
 
-# Build JNI layer
-#if target_os == 'android':
-#    SConscript(os.path.join('sdk', 'java', 'jni', 'SConscript'))
+# Remove it if the conversion for Android and Tizen platform is done
+if target_os == 'linux':
+   tgm_src = env.Glob('sdk/src/*.cpp', '../../extlibs/timer/timer.c')
+   tgmsdk_static = things_manager_env.StaticLibrary('TGMSDKLibrary', tgm_src)
+   tgmsdk_shared = things_manager_env.SharedLibrary('TGMSDKLibrary', tgm_src)
 
-#Go to build sample apps
-SConscript('sampleapp/SConscript')
+   things_manager_env.InstallTarget([tgmsdk_static,tgmsdk_shared], 'libTGMSDK')
+   things_manager_env.UserInstallTargetLib([tgmsdk_static,tgmsdk_shared], 'libTGMSDK')
+
+   # Build JNI layer
+   #if target_os == 'android':
+   #    SConscript(os.path.join('sdk', 'java', 'jni', 'SConscript'))
+
+    #Go to build sample apps
+   SConscript('sampleapp/SConscript')
 
 
old mode 100644 (file)
new mode 100755 (executable)
index 1096799..4f3f2b9
 
 #include <functional>
 #include <thread>
+#include <string.h>
 
 #include "OCPlatform.h"
 #include "OCApi.h"
-#include "ThingsManager.h"
 #include "ConfigurationCollection.h"
 
 using namespace OC;
+using namespace std;
 
 /// This function internally calls registerResource API.
 void ConfigurationResource::createResources(ResourceEntityHandler callback)
old mode 100644 (file)
new mode 100755 (executable)
index 2dc3bbf..9b3e864
@@ -27,7 +27,6 @@
 
 #include "OCPlatform.h"
 #include "OCApi.h"
-#include "ThingsManager.h"
 
 #pragma once
 
@@ -36,8 +35,8 @@ using namespace OC;
 typedef std::function<
     OCEntityHandlerResult(std::shared_ptr< OCResourceRequest > request) > ResourceEntityHandler;
 
-static std::string defaultURIPrefix = "/oic/con";
-static std::string defaultResourceTypePrefix = "oic.con";
+static std::string defaultConURI = "/oic/con";
+static std::string defaultConResourceType = "oic.wk.con";
 
 extern std::string defaultLocation;
 extern std::string defaultSystemTime;
@@ -64,11 +63,9 @@ public:
             m_location(defaultLocation), m_systemTime(defaultSystemTime), m_currency(
                     defaultCurrency), m_region(defaultRegion)
     {
-        m_configurationUri = "/oic/con"; // URI of the resource
-        m_configurationTypes.push_back("oic.con"); // resource type name.
+        m_configurationUri = defaultConURI; // URI of the resource
+        m_configurationTypes.push_back(defaultConResourceType); // resource type name.
         m_configurationInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.
-        //m_configurationInterfaces.push_back(BATCH_INTERFACE); // resource interface.
-        //m_configurationInterfaces.push_back(LINK_INTERFACE); // resource interface.
         m_configurationRep.setValue("loc", m_location);
         m_configurationRep.setValue("st", m_systemTime);
         m_configurationRep.setValue("c", m_currency);
old mode 100644 (file)
new mode 100755 (executable)
index 7809396..d1dcb29
 
 #include <functional>
 #include <thread>
+#include <string.h>
 
 #include "OCPlatform.h"
 #include "OCApi.h"
-#include "ThingsManager.h"
 #include "DiagnosticsCollection.h"
 
 using namespace OC;
+using namespace std;
 
 /// This function internally calls registerResource API.
-void DiagnosticsResource::createResources(ResourceEntityHandler callback)
+void MaintenanceResource::createResources(ResourceEntityHandler callback)
 {
     using namespace OC::OCPlatform;
 
@@ -44,25 +45,25 @@ void DiagnosticsResource::createResources(ResourceEntityHandler callback)
     }
 
     // This will internally create and register the resource.
-    OCStackResult result = registerResource(m_diagnosticsHandle, m_diagnosticsUri,
-            m_diagnosticsTypes[0], m_diagnosticsInterfaces[0], callback,
+    OCStackResult result = registerResource(m_maintenanceHandle, m_maintenanceUri,
+            m_maintenanceTypes[0], m_maintenanceInterfaces[0], callback,
             OC_DISCOVERABLE | OC_OBSERVABLE);
 
     if (OC_STACK_OK != result)
     {
-        std::cout << "Resource creation (diagnostics) was unsuccessful\n";
+        std::cout << "Resource creation (maintenance) was unsuccessful\n";
     }
 
     thread exec(
             std::function< void(int second) >(
-                    std::bind(&DiagnosticsResource::diagnosticsMonitor, this,
+                    std::bind(&MaintenanceResource::maintenanceMonitor, this,
                             std::placeholders::_1)), 10); // every 10 seconds
     exec.detach();
 
-    std::cout << "Diagnostics Resource is Created!\n";
+    std::cout << "maintenance Resource is Created!\n";
 }
 
-void DiagnosticsResource::setDiagnosticsRepresentation(OCRepresentation& rep)
+void MaintenanceResource::setMaintenanceRepresentation(OCRepresentation& rep)
 {
     string value;
 
@@ -85,21 +86,21 @@ void DiagnosticsResource::setDiagnosticsRepresentation(OCRepresentation& rep)
     }
 }
 
-OCRepresentation DiagnosticsResource::getDiagnosticsRepresentation()
+OCRepresentation MaintenanceResource::getMaintenanceRepresentation()
 {
-    m_diagnosticsRep.setValue("fr", m_factoryReset);
-    m_diagnosticsRep.setValue("rb", m_reboot);
-    m_diagnosticsRep.setValue("ssc", m_startStatCollection);
+    m_maintenanceRep.setValue("fr", m_factoryReset);
+    m_maintenanceRep.setValue("rb", m_reboot);
+    m_maintenanceRep.setValue("ssc", m_startStatCollection);
 
-    return m_diagnosticsRep;
+    return m_maintenanceRep;
 }
 
-std::string DiagnosticsResource::getUri()
+std::string MaintenanceResource::getUri()
 {
-    return m_diagnosticsUri;
+    return m_maintenanceUri;
 }
 
-void DiagnosticsResource::diagnosticsMonitor(int second)
+void MaintenanceResource::maintenanceMonitor(int second)
 {
     while (1)
     {
old mode 100644 (file)
new mode 100755 (executable)
index 27f91a4..1a182b5
@@ -27,7 +27,6 @@
 
 #include "OCPlatform.h"
 #include "OCApi.h"
-#include "ThingsManager.h"
 
 #pragma once
 
@@ -36,53 +35,56 @@ using namespace OC;
 typedef std::function<
     OCEntityHandlerResult(std::shared_ptr< OCResourceRequest > request) > ResourceEntityHandler;
 
+static std::string defaultMntURI = "/oic/mnt";
+static std::string defaultMntResourceType = "oic.wk.mnt";
+
 static std::string defaultFactoryReset = "false";
 static std::string defaultReboot = "false";
 static std::string defaultStartStatCollection = "false";
 
-class DiagnosticsResource
+class MaintenanceResource
 {
 public:
 
     // diagnostics members
-    std::string m_diagnosticsUri;
+    std::string m_maintenanceUri;
     std::string m_factoryReset;
     std::string m_reboot;
     std::string m_startStatCollection;
-    std::vector< std::string > m_diagnosticsTypes;
-    std::vector< std::string > m_diagnosticsInterfaces;
-    OCResourceHandle m_diagnosticsHandle;
-    OCRepresentation m_diagnosticsRep;
+    std::vector< std::string > m_maintenanceTypes;
+    std::vector< std::string > m_maintenanceInterfaces;
+    OCResourceHandle m_maintenanceHandle;
+    OCRepresentation m_maintenanceRep;
 
 public:
     /// Constructor
-    DiagnosticsResource() :
+    MaintenanceResource() :
            m_factoryReset(defaultFactoryReset), m_reboot(defaultReboot),
             m_startStatCollection(defaultStartStatCollection)
     {
-        m_diagnosticsUri = "/oic/diag"; // URI of the resource
-        m_diagnosticsTypes.push_back("oic.diag"); // resource type name.
-        m_diagnosticsInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.
-        m_diagnosticsRep.setValue("fr", m_factoryReset);
-        m_diagnosticsRep.setValue("rb", m_reboot);
-        m_diagnosticsRep.setValue("ssc", m_startStatCollection);
-        m_diagnosticsRep.setUri(m_diagnosticsUri);
-        m_diagnosticsRep.setResourceTypes(m_diagnosticsTypes);
-        m_diagnosticsRep.setResourceInterfaces(m_diagnosticsInterfaces);
-        m_diagnosticsHandle = NULL;
+        m_maintenanceUri = defaultMntURI; // URI of the resource
+        m_maintenanceTypes.push_back(defaultMntResourceType); // resource type name.
+        m_maintenanceInterfaces.push_back(DEFAULT_INTERFACE); // resource interface.
+        m_maintenanceRep.setValue("fr", m_factoryReset);
+        m_maintenanceRep.setValue("rb", m_reboot);
+        m_maintenanceRep.setValue("ssc", m_startStatCollection);
+        m_maintenanceRep.setUri(m_maintenanceUri);
+        m_maintenanceRep.setResourceTypes(m_maintenanceTypes);
+        m_maintenanceRep.setResourceInterfaces(m_maintenanceInterfaces);
+        m_maintenanceHandle = NULL;
     }
     ;
 
     /// This function internally calls registerResource API.
     void createResources(ResourceEntityHandler callback);
 
-    void setDiagnosticsRepresentation(OCRepresentation& rep);
+    void setMaintenanceRepresentation(OCRepresentation& rep);
 
-    OCRepresentation getDiagnosticsRepresentation();
+    OCRepresentation getMaintenanceRepresentation();
 
     std::string getUri();
 
-    void diagnosticsMonitor(int second);
+    void maintenanceMonitor(int second);
 
     std::function< void() > factoryReset;
 };
old mode 100644 (file)
new mode 100755 (executable)
index 36c4d93..aa8689e
 
 #include <functional>
 #include <thread>
+#include <string.h>
 
 #include "OCPlatform.h"
 #include "OCApi.h"
-#include "ThingsManager.h"
 #include "FactorySetCollection.h"
 
 using namespace OC;
+using namespace std;
 
 FactorySetResource::FactorySetResource()
 {
old mode 100644 (file)
new mode 100755 (executable)
index 15b5f3f..1b48991
@@ -27,7 +27,7 @@
 
 #include "OCPlatform.h"
 #include "OCApi.h"
-#include "ThingsManager.h"
+//#include "ThingsManager.h"
 #include "ConfigurationCollection.h"
 
 #pragma once
old mode 100644 (file)
new mode 100755 (executable)
index 08c2fe8..9786ca6
 #include <vector>
 #include "OCPlatform.h"
 #include "OCApi.h"
-#include "ThingsManager.h"
+//#include "ThingsManager.h"
+#include "ThingsConfiguration.h"
+#include "ThingsDiagnostics.h"
+#include "GroupManager.h"
 
 using namespace OC;
 using namespace OIC;
@@ -38,15 +41,18 @@ pthread_mutex_t mutex_lock = PTHREAD_MUTEX_INITIALIZER;
 
 const int SUCCESS_RESPONSE = 0;
 
-static ThingsManager* g_thingsmanager;
+//static ThingsManager* g_thingsmanager;
+static GroupManager* g_groupmanager;
+static ThingsConfiguration* g_thingsConf;
+static ThingsMaintenance* g_thingsMnt;
 
 OCResourceHandle configurationCollectionHandle;
 std::shared_ptr< OCResource > g_configurationCollection; // for a group of multiple resources
 std::shared_ptr< OCResource > g_configurationResource; // For a single resource
 
-OCResourceHandle diagnosticsCollectionHandle;
-std::shared_ptr< OCResource > g_diagnosticsCollection; // for a group of multiple resources
-std::shared_ptr< OCResource > g_diagnosticsResource; // For a single resource
+OCResourceHandle maintenanceCollectionHandle;
+std::shared_ptr< OCResource > g_maintenanceCollection; // for a group of multiple resources
+std::shared_ptr< OCResource > g_maintenanceResource; // For a single resource
 
 OCResourceHandle setCollectionHandle;
 std::shared_ptr< OCResource > g_setCollection; // for a group of multiple resources
@@ -55,13 +61,6 @@ std::shared_ptr< OCResource > g_setResource; // For a single resource
 std::map< std::string, std::shared_ptr< OCResource > > resourceTable;
 std::vector< OCResourceHandle > resourceHandleVector;
 
-typedef std::function<
-        void(const HeaderOptions& headerOptions,
-                const OCRepresentation& rep, const int eCode) > ConfigurationCallback;
-typedef std::function<
-        void(const HeaderOptions& headerOptions,
-                const OCRepresentation& rep, const int eCode) > DiagnosticsCallback;
-
 typedef std::string ConfigurationName;
 typedef std::string ConfigurationValue;
 
@@ -166,8 +165,8 @@ void onFoundCollectionResource(std::vector< std::shared_ptr< OCResource > > reso
             {
                 if (resource->uri() == "/core/a/configuration/resourceset")
                     g_configurationCollection = resource;
-                else if (resource->uri() == "/core/a/diagnostics/resourceset")
-                    g_diagnosticsCollection = resource;
+                else if (resource->uri() == "/core/a/maintenance/resourceset")
+                    g_maintenanceCollection = resource;
                 else if (resource->uri() == "/core/a/factoryset/resourceset")
                     g_setCollection = resource;
                 else
@@ -232,12 +231,12 @@ void onFoundCandidateResource(std::vector< std::shared_ptr< OCResource > > resou
                             if (g_configurationResource == NULL)
                                 g_configurationResource = resource;
                         }
-                        else if (resource->uri() == "/oic/diag")
+                        else if (resource->uri() == "/oic/mnt")
                         {
-                            OCPlatform::bindResource(diagnosticsCollectionHandle,
+                            OCPlatform::bindResource(maintenanceCollectionHandle,
                                     foundResourceHandle);
-                            if (g_diagnosticsResource == NULL)
-                                g_diagnosticsResource = resource;
+                            if (g_maintenanceResource == NULL)
+                                g_maintenanceResource = resource;
                         }
                         else if (resource->uri() == "/factorySet")
                         {
@@ -286,7 +285,10 @@ int main(int argc, char* argv[])
         { OC::ServiceType::InProc, OC::ModeType::Both, "0.0.0.0", 0, OC::QualityOfService::LowQos };
 
         OCPlatform::Configure(cfg);
-        g_thingsmanager = new ThingsManager();
+        //g_thingsmanager = new ThingsManager();
+        g_thingsConf = new ThingsConfiguration();
+        g_thingsMnt = new ThingsMaintenance();
+        g_groupmanager = new GroupManager();
 
         //**************************************************************
 
@@ -303,7 +305,7 @@ int main(int argc, char* argv[])
             pthread_mutex_unlock(&mutex_lock);
 
             cout << endl << endl << "(0) Quit" << std::endl;
-            cout << "(1) Find all resources(URI: /oic/con, /oic/diag, /factoryset)" << std::endl;
+            cout << "(1) Find all resources(URI: /oic/con, /oic/mnt, /factoryset)" << std::endl;
             cout << "(2) Find all groups" << std::endl;
             cout << "(3) Get a Configuration resource" << std::endl;
             cout << "(4) Update a region attribute value" << std::endl;
@@ -355,20 +357,20 @@ int main(int argc, char* argv[])
                         DEFAULT_INTERFACE);
                 }
 
-                // For Registering a collection resource for diagnostics resources
-                if (diagnosticsCollectionHandle == NULL)
+                // For Registering a collection resource for maintenance resources
+                if (maintenanceCollectionHandle == NULL)
                 {
-                    string resourceURI = "/core/a/diagnostics/resourceset";
-                    string resourceTypeName = "core.diagnostics.resourceset";
+                    string resourceURI = "/core/a/maintenance/resourceset";
+                    string resourceTypeName = "core.maintenance.resourceset";
                     string resourceInterface = BATCH_INTERFACE;
 
-                    OCPlatform::registerResource(diagnosticsCollectionHandle, resourceURI,
+                    OCPlatform::registerResource(maintenanceCollectionHandle, resourceURI,
                         resourceTypeName, resourceInterface, NULL,
                         //&entityHandler, // entityHandler
                         OC_DISCOVERABLE);
 
-                    OCPlatform::bindInterfaceToResource(diagnosticsCollectionHandle, GROUP_INTERFACE);
-                    OCPlatform::bindInterfaceToResource(diagnosticsCollectionHandle, DEFAULT_INTERFACE);
+                    OCPlatform::bindInterfaceToResource(maintenanceCollectionHandle, GROUP_INTERFACE);
+                    OCPlatform::bindInterfaceToResource(maintenanceCollectionHandle, DEFAULT_INTERFACE);
                 }
 
                 // For Registering a collection resource for set resources
@@ -387,15 +389,15 @@ int main(int argc, char* argv[])
                     OCPlatform::bindInterfaceToResource(setCollectionHandle, DEFAULT_INTERFACE);
                 }
 
-                types.push_back("oic.con");
-                types.push_back("oic.diag");
+                types.push_back("oic.wk.con");
+                types.push_back("oic.wk.mnt");
                 types.push_back("factorySet");
 
                 std::cout << "Finding Configuration Resource... " << std::endl;
-                std::cout << "Finding Diagnostics Resource... " << std::endl;
+                std::cout << "Finding Maintenance Resource... " << std::endl;
                 std::cout << "Finding Set Resource... " << std::endl;
 
-                g_thingsmanager->findCandidateResources(types, &onFoundCandidateResource, 5);
+                g_groupmanager->findCandidateResources(types, &onFoundCandidateResource, 5);
 
                 pthread_mutex_lock(&mutex_lock);
                 isWaiting = 1;
@@ -408,10 +410,10 @@ int main(int argc, char* argv[])
             {
                 std::vector< std::string > types;
                 types.push_back("core.configuration.resourceset");
-                types.push_back("core.diagnostics.resourceset");
+                types.push_back("core.maintenance.resourceset");
                 types.push_back("core.factoryset.resourceset");
 
-                g_thingsmanager->findCandidateResources(types, &onFoundCollectionResource, 5);
+                g_groupmanager->findCandidateResources(types, &onFoundCollectionResource, 5);
 
                 std::cout << "Finding Collection resource... " << std::endl;
 
@@ -434,7 +436,7 @@ int main(int argc, char* argv[])
 
                 configurations.push_back(name);
 
-                if (g_thingsmanager->getConfigurations(g_configurationCollection, configurations, &onGet)
+                if (g_thingsConf->getConfigurations(g_configurationCollection, configurations, &onGet)
                         != OC_STACK_ERROR)
                 {
                     pthread_mutex_lock(&mutex_lock);
@@ -460,7 +462,7 @@ int main(int argc, char* argv[])
 
                 configurations.insert(std::make_pair(name, value));
 
-                if (g_thingsmanager->updateConfigurations(g_configurationCollection, configurations,
+                if (g_thingsConf->updateConfigurations(g_configurationCollection, configurations,
                         &onUpdate) != OC_STACK_ERROR)
                 {
                     pthread_mutex_lock(&mutex_lock);
@@ -471,13 +473,13 @@ int main(int argc, char* argv[])
             else if (g_Steps == 5)
             {
                 // factory reset
-                if(g_diagnosticsCollection == NULL)
+                if(g_maintenanceCollection == NULL)
                 {
                     std::cout<<"Note that you first create a group to use this command." << std::endl;
                     continue;
                 }
 
-                if (g_thingsmanager->factoryReset(g_diagnosticsCollection, &onFactoryReset)
+                if (g_thingsMnt->factoryReset(g_maintenanceCollection, &onFactoryReset)
                         != OC_STACK_ERROR)
                 {
                     pthread_mutex_lock(&mutex_lock);
@@ -488,13 +490,13 @@ int main(int argc, char* argv[])
             else if (g_Steps == 6)
             {
                 // reboot
-                if(g_diagnosticsCollection == NULL)
+                if(g_maintenanceCollection == NULL)
                 {
                     std::cout<<"Note that you first create a group to use this command." << std::endl;
                     continue;
                 }
 
-                if (g_thingsmanager->reboot(g_diagnosticsCollection, &onReboot) != OC_STACK_ERROR)
+                if (g_thingsMnt->reboot(g_maintenanceCollection, &onReboot) != OC_STACK_ERROR)
                 {
                     pthread_mutex_lock(&mutex_lock);
                     isWaiting = 0;
@@ -503,7 +505,7 @@ int main(int argc, char* argv[])
             }
             else if (g_Steps == 10)
             {
-                std::cout << g_thingsmanager->getListOfSupportedConfigurationUnits() << std::endl;
+                std::cout << g_thingsConf->getListOfSupportedConfigurationUnits() << std::endl;
 
             }
         }
old mode 100644 (file)
new mode 100755 (executable)
index f609adb..4d1ee17
@@ -27,7 +27,8 @@
 
 #include "OCPlatform.h"
 #include "OCApi.h"
-#include "ThingsManager.h"
+#include "ThingsConfiguration.h"
+#include "ThingsDiagnostics.h"
 #include "ConfigurationCollection.h"
 #include "DiagnosticsCollection.h"
 #include "FactorySetCollection.h"
@@ -48,7 +49,8 @@ std::string defaultRegion;
 std::string defaultSystemTime;
 std::string defaultCurrency;
 
-static ThingsManager* g_thingsmanager;
+//static ThingsManager* g_thingsmanager;
+static ThingsConfiguration* g_thingsConf;
 
 // Forward declaring the entityHandler (Configuration)
 bool prepareResponseForResource(std::shared_ptr< OCResourceRequest > request);
@@ -56,7 +58,7 @@ OCStackResult sendResponseForResource(std::shared_ptr< OCResourceRequest > pRequ
 OCEntityHandlerResult entityHandlerForResource(std::shared_ptr< OCResourceRequest > request);
 
 ConfigurationResource *myConfigurationResource;
-DiagnosticsResource *myDiagnosticsResource;
+MaintenanceResource *myMaintenanceResource;
 FactorySetResource *myFactorySetResource;
 
 typedef std::function< void(OCRepresentation&) > putFunc;
@@ -71,10 +73,10 @@ getFunc getGetFunction(std::string uri)
         res = std::bind(&ConfigurationResource::getConfigurationRepresentation,
                 myConfigurationResource);
     }
-    else if (uri == myDiagnosticsResource->getUri())
+    else if (uri == myMaintenanceResource->getUri())
     {
-        res = std::bind(&DiagnosticsResource::getDiagnosticsRepresentation,
-                myDiagnosticsResource);
+        res = std::bind(&MaintenanceResource::getMaintenanceRepresentation,
+                myMaintenanceResource);
     }
 
     return res;
@@ -89,10 +91,10 @@ putFunc getPutFunction(std::string uri)
         res = std::bind(&ConfigurationResource::setConfigurationRepresentation,
                 myConfigurationResource, std::placeholders::_1);
     }
-    else if (uri == myDiagnosticsResource->getUri())
+    else if (uri == myMaintenanceResource->getUri())
     {
-        res = std::bind(&DiagnosticsResource::setDiagnosticsRepresentation,
-                myDiagnosticsResource, std::placeholders::_1);
+        res = std::bind(&MaintenanceResource::setMaintenanceRepresentation,
+                myMaintenanceResource, std::placeholders::_1);
     }
 
     return res;
@@ -250,7 +252,8 @@ int main()
     { OC::ServiceType::InProc, OC::ModeType::Both, "0.0.0.0", 0, OC::QualityOfService::LowQos };
 
     OCPlatform::Configure(cfg);
-    g_thingsmanager = new ThingsManager();
+    g_thingsConf = new ThingsConfiguration();
+    //g_thingsDiag = new ThingsDiagnostics();
     //**************************************************************
 
     if (getuid() != 0)
@@ -286,7 +289,7 @@ int main()
             }
             else if (g_Steps == 1)
             {
-                if( g_thingsmanager->doBootstrap(&onBootstrap) == OC_STACK_OK)
+                if( g_thingsConf->doBootstrap(&onBootstrap) == OC_STACK_OK)
                 {
                     pthread_mutex_lock(&mutex_lock);
                     isWaiting = 1;
@@ -302,13 +305,12 @@ int main()
                 myConfigurationResource = new ConfigurationResource();
                 myConfigurationResource->createResources(&entityHandlerForResource);
 
-                myDiagnosticsResource = new DiagnosticsResource();
-                myDiagnosticsResource->createResources(&entityHandlerForResource);
-
+                myMaintenanceResource = new MaintenanceResource();
+                myMaintenanceResource->createResources(&entityHandlerForResource);
 
                 myFactorySetResource = new FactorySetResource();
                 myFactorySetResource->createResources(&entityHandlerForResource);
-                myDiagnosticsResource->factoryReset = std::function < void()
+                myMaintenanceResource->factoryReset = std::function < void()
                         > (std::bind(&ConfigurationResource::factoryReset,
                                 myConfigurationResource));
 
old mode 100644 (file)
new mode 100755 (executable)
index 8959a01..ae57bc8
@@ -27,7 +27,7 @@
 
 #include "timer.h"
 
-#include <ThingsManager.h>
+#include <GroupManager.h>
 
 using namespace std;
 using namespace OC;
@@ -42,7 +42,7 @@ std::vector<OCResourceHandle> resourceHandleVector;
 shared_ptr<OCResource> g_resource;
 vector<string> lights;
 
-ThingsManager *thingsMgr = new ThingsManager();
+GroupManager *groupMgr = new GroupManager();
 
 void onGet(const HeaderOptions& opt, const OCRepresentation &rep,
         const int eCode);
@@ -165,7 +165,7 @@ void onPost(const HeaderOptions& headerOptions, const OCRepresentation& rep,
 
         if (rep.getValue("ActionSet", plainText))
         {
-            ActionSet *actionset = thingsMgr->getActionSetfromString(plainText);
+            ActionSet *actionset = groupMgr->getActionSetfromString(plainText);
             if (actionset != NULL)
             {
                 cout << endl << "\tACTIONSET NAME :: "
@@ -234,29 +234,29 @@ void allBulbOn()
 
 void Scheduled_AllbulbOff()
 {
-    thingsMgr->executeActionSet(g_resource, "AllBulbOffScheduledCall", &onPost);
+    groupMgr->executeActionSet(g_resource, "AllBulbOffScheduledCall", &onPost);
 }
 void Scheduled_AllbulbOffEx()
 {
-    thingsMgr->executeActionSet(g_resource, "AllBulbOffScheduledCall", 10, &onPost);
+    groupMgr->executeActionSet(g_resource, "AllBulbOffScheduledCall", 10, &onPost);
 }
 void CancelScheduled_AllBulbOff()
 {
-    thingsMgr->cancelActionSet(g_resource, "AllBulbOffScheduledCall", &onPost);
+    groupMgr->cancelActionSet(g_resource, "AllBulbOffScheduledCall", &onPost);
 }
 void Recursive_allBulbOn()
 {
-    thingsMgr->executeActionSet(g_resource, "AllBulbOnRecursiveCall", &onPost);
+    groupMgr->executeActionSet(g_resource, "AllBulbOnRecursiveCall", &onPost);
 }
 void Recursive_allBulbOnEx()
 {
-    thingsMgr->executeActionSet(g_resource, "AllBulbOnRecursiveCall", 10, &onPost);
+    groupMgr->executeActionSet(g_resource, "AllBulbOnRecursiveCall", 10, &onPost);
 }
 
 void CancelRecursive_allBulbOn()
 {
 
-    thingsMgr->cancelActionSet(g_resource, "AllBulbOnRecursiveCall", &onPost);
+    groupMgr->cancelActionSet(g_resource, "AllBulbOnRecursiveCall", &onPost);
 }
 
 void onObserve(const HeaderOptions headerOptions, const OCRepresentation& rep,
@@ -309,7 +309,7 @@ void createActionSet_AllBulbOff()
     }
     if (g_resource)
     {
-        thingsMgr->addActionSet(g_resource, allBulbOff, onPut);
+        groupMgr->addActionSet(g_resource, allBulbOff, onPut);
     }
 
     delete allBulbOff;
@@ -335,7 +335,7 @@ void createActionSet_AllBulbOn()
     }
     if (g_resource)
     {
-        thingsMgr->addActionSet(g_resource, allBulbOff, onPut);
+        groupMgr->addActionSet(g_resource, allBulbOff, onPut);
     }
 
     delete allBulbOff;
@@ -377,7 +377,7 @@ void createScheduledActionSet_AllBulbOff()
     }
     if (g_resource)
     {
-        thingsMgr->addActionSet(g_resource, allBulbOff, onPut);
+        groupMgr->addActionSet(g_resource, allBulbOff, onPut);
     }
 
     delete allBulbOff;
@@ -413,7 +413,7 @@ void createRecursiveActionSet_AllBulbOn()
     }
     if (g_resource)
     {
-        thingsMgr->addActionSet(g_resource, allBulbOn, onPut);
+        groupMgr->addActionSet(g_resource, allBulbOn, onPut);
     }
 
     delete allBulbOn;
@@ -435,7 +435,7 @@ int main()
         // Find lights for group creation.
         vector<string> types;
         types.push_back("core.light");
-        thingsMgr->findCandidateResources(types, &foundResources, 5);
+        groupMgr->findCandidateResources(types, &foundResources, 5);
 
         OCStackResult res = OCPlatform::registerResource(resourceHandle, resourceURI,
                 resourceTypeName, resourceInterface, NULL, OC_DISCOVERABLE);
@@ -556,11 +556,11 @@ int main()
                 }
                 else if (n == 6)
                 {
-                    thingsMgr->getActionSet(g_resource, "AllBulbOff", onPost);
+                    groupMgr->getActionSet(g_resource, "AllBulbOff", onPost);
                 }
                 else if (n == 7)
                 {
-                    thingsMgr->deleteActionSet(g_resource, "AllBulbOff", onPut);
+                    groupMgr->deleteActionSet(g_resource, "AllBulbOff", onPut);
                 }
                 else if (n == 8)
                 {
old mode 100644 (file)
new mode 100755 (executable)
index fd90e82..b7f4eff
 #include <string>
 #include <cstdlib>
 #include <pthread.h>
+#include <string.h>
 #include "OCPlatform.h"
 #include "OCApi.h"
-#include "ThingsManager.h"
+#include "GroupSynchronization.h"
 
 using namespace OC;
 using namespace OIC;
+using namespace std;
 
-static ThingsManager* gThingManager = NULL;
+static GroupSynchronization* gGroupSynchronization = NULL;
 
 static std::vector< OCResourceHandle > gResourceHandleList;
 
@@ -54,7 +56,7 @@ void onFindResource(std::shared_ptr< OCResource > resource)
                 return;
             }
 
-            result = gThingManager->joinGroup(collectionResourceType, resourceHandle);
+            result = gGroupSynchronization->joinGroup(collectionResourceType, resourceHandle);
             if (OC_STACK_OK == result)
             {
                 cout << "onFindResource : Joining group was successful\n";
@@ -87,7 +89,7 @@ int main(int argc, char* argv[])
             OC::QualityOfService::LowQos };
 
     OCPlatform::Configure(cfg);
-    gThingManager = new ThingsManager();
+    gGroupSynchronization = new GroupSynchronization();
 
     int selectedMenu;
     OCStackResult result;
@@ -106,7 +108,7 @@ int main(int argc, char* argv[])
 
             if (selectedMenu == 1)
             {
-                result = gThingManager->createGroup(collectionResourceType);
+                result = gGroupSynchronization->createGroup(collectionResourceType);
                 if (OC_STACK_OK == result)
                 {
                     cout << "Group creation was successful\n";
@@ -165,7 +167,7 @@ int main(int argc, char* argv[])
                     std::string type = OCGetResourceTypeName(resourceHandle, 0);
                     if (0 == mpType.compare(type))
                     {
-                        result = gThingManager->leaveGroup(collectionResourceType, resourceHandle);
+                        result = gGroupSynchronization->leaveGroup(collectionResourceType, resourceHandle);
                         if (OC_STACK_OK == result)
                         {
                             cout << "Leaving group of music player was successful\n";
@@ -203,7 +205,7 @@ int main(int argc, char* argv[])
                     std::string type = OCGetResourceTypeName(resourceHandle, 0);
                     if (0 == mpType.compare(type))
                     {
-                        result = gThingManager->leaveGroup(collectionResourceType, resourceHandle);
+                        result = gGroupSynchronization->leaveGroup(collectionResourceType, resourceHandle);
                         if (OC_STACK_OK == result)
                         {
                             cout << "Leaving group of speaker was successful\n";
@@ -232,7 +234,7 @@ int main(int argc, char* argv[])
             }
             else if (selectedMenu == 31)
             {
-                gThingManager->deleteGroup(collectionResourceType);
+                gGroupSynchronization->deleteGroup(collectionResourceType);
             }
         }
     }
old mode 100644 (file)
new mode 100755 (executable)
index 64fa656..6e8dc79
 #include <string>
 #include <cstdlib>
 #include <pthread.h>
+#include <string.h>
 #include "OCPlatform.h"
 #include "OCApi.h"
-#include "ThingsManager.h"
 
 using namespace OC;
+using namespace std;
 
 OCEntityHandlerResult mpEntityHandler(const std::shared_ptr< OCResourceRequest > request)
 {
old mode 100644 (file)
new mode 100755 (executable)
index 4693637..17c4796
 #include <pthread.h>
 #include "OCPlatform.h"
 #include "OCApi.h"
-#include "ThingsManager.h"
+#include "GroupManager.h"
+#include "GroupSynchronization.h"
 
 using namespace OC;
 using namespace OIC;
+using namespace std;
 
-static ThingsManager* gThingManager = NULL;
+static GroupManager* gGroupManager = NULL;
+static GroupSynchronization* gGroupSynchronization = NULL;
 
 static OCResourceHandle gPhoneResourceHandle = NULL;
 
@@ -67,13 +70,13 @@ void onFindGroup(std::shared_ptr< OCResource > resource)
             gFindGroup = resource;
             {
                 OCStackResult res;
-                res = gThingManager->subscribeCollectionPresence( resource, &presenceCallback);
+                res = gGroupManager->subscribeCollectionPresence( resource, &presenceCallback);
 
                 std::cout << "Return Value: " << res << std::endl;
             }
         }
 
-        gThingManager->joinGroup(gFindGroup, gPhoneResourceHandle);
+        gGroupSynchronization->joinGroup(gFindGroup, gPhoneResourceHandle);
     }
     else
     {
@@ -190,7 +193,7 @@ void onGetChild(const HeaderOptions& headerOptions, const OCRepresentation& rep,
 
         if (0 == gPlayStart->listOfAction.empty())
         {
-            result = gThingManager->addActionSet(gFindGroup, gPlayStart, onAction);
+            result = gGroupManager->addActionSet(gFindGroup, gPlayStart, onAction);
             if (OC_STACK_OK == result)
             {
                 cout << "addActionSet(gPlayStart) was successful\n";
@@ -203,7 +206,7 @@ void onGetChild(const HeaderOptions& headerOptions, const OCRepresentation& rep,
 
         if (0 == gPlayStop->listOfAction.empty())
         {
-            result = gThingManager->addActionSet(gFindGroup, gPlayStop, onAction);
+            result = gGroupManager->addActionSet(gFindGroup, gPlayStop, onAction);
             if (OC_STACK_OK == result)
             {
                 cout << "addActionSet(gPlayStop) was successful\n";
@@ -227,7 +230,8 @@ int main(int argc, char* argv[])
     { OC::ServiceType::InProc, OC::ModeType::Both, "0.0.0.0", 0, OC::QualityOfService::LowQos };
 
     OCPlatform::Configure(cfg);
-    gThingManager = new ThingsManager();
+    gGroupManager = new GroupManager();
+    gGroupSynchronization = new GroupSynchronization();
 
     int selectedMenu;
     OCStackResult result;
@@ -278,7 +282,7 @@ int main(int argc, char* argv[])
                 types.clear();
                 types.push_back(collectionResourceType);
 
-                result = gThingManager->findGroup(types, &onFindGroup);
+                result = gGroupSynchronization->findGroup(types, &onFindGroup);
                 if (OC_STACK_OK == result)
                 {
                     cout << "Finding group was successful\n";
@@ -321,7 +325,7 @@ int main(int argc, char* argv[])
                     continue;
                 }
 
-                result = gThingManager->executeActionSet(gFindGroup, "playstart", onAction);
+                result = gGroupManager->executeActionSet(gFindGroup, "playstart", onAction);
                 if (OC_STACK_OK == result)
                 {
                     cout << "DoAction(playstart) was successful\n";
@@ -345,7 +349,7 @@ int main(int argc, char* argv[])
                     continue;
                 }
 
-                result = gThingManager->executeActionSet(gFindGroup, "playstop", onAction);
+                result = gGroupManager->executeActionSet(gFindGroup, "playstop", onAction);
                 if (OC_STACK_OK == result)
                 {
                     cout << "DoAction(playstop) was successful\n";
@@ -375,7 +379,7 @@ int main(int argc, char* argv[])
                     continue;
                 }
 
-                result = gThingManager->deleteActionSet(gFindGroup, "playstart", onAction);
+                result = gGroupManager->deleteActionSet(gFindGroup, "playstart", onAction);
                 if (OC_STACK_OK == result)
                 {
                     cout << "Delete Action(playstart) was successful\n";
@@ -386,7 +390,7 @@ int main(int argc, char* argv[])
                             << endl;
                 }
 
-                result = gThingManager->deleteActionSet(gFindGroup, "playstop", onAction);
+                result = gGroupManager->deleteActionSet(gFindGroup, "playstop", onAction);
                 if (OC_STACK_OK == result)
                 {
                     cout << "Delete Action(playstop) was successful\n";
@@ -445,7 +449,7 @@ int main(int argc, char* argv[])
                     continue;
                 }
 
-                result = gThingManager->leaveGroup(gFindGroup, collectionResourceType,  gPhoneResourceHandle);
+                result = gGroupSynchronization->leaveGroup(gFindGroup, collectionResourceType,  gPhoneResourceHandle);
                 if (OC_STACK_OK == result)
                 {
                     cout << "Leaving group was successful\n";
old mode 100644 (file)
new mode 100755 (executable)
index 9f6d5a2..cc7bbcf
 #include <string>
 #include <cstdlib>
 #include <pthread.h>
+#include <string.h>
 #include "OCPlatform.h"
 #include "OCApi.h"
-#include "ThingsManager.h"
 
 using namespace OC;
+using namespace std;
 
 OCEntityHandlerResult speakerEntityHandler(const std::shared_ptr< OCResourceRequest > request)
 {
old mode 100644 (file)
new mode 100755 (executable)
similarity index 57%
rename from service/things-manager/sdk/src/GroupManager.h
rename to service/things-manager/sdk/inc/GroupManager.h
index c8a8f9d..b6c33c7
@@ -103,19 +103,110 @@ private:
      */
 
 public:
+    /**
+     * API for extracting an action set string from the ActionSet class instance
+     *
+     * @param newActionSet pointer of ActionSet class instance
+     *
+     * @return std::string return value of this API.
+     *                                      It returns an action set String.
+     * @note OCStackResult is defined in ocstack.h.
+     */
     std::string getStringFromActionSet(const ActionSet *newActionSet);
+
+    /**
+     * API for extrracting ActionSet class instance from an action set string.
+     *
+     * @param desc description of an action set string
+     *
+     * @return ActionSet* return value of this API.
+     *                      It returns pointer of ActionSet.
+     */
     ActionSet* getActionSetfromString(std::string desc);
 
+    /**
+     * API for adding an action set.
+     * Callback is called when the response of PUT operation arrives.
+     *
+     * @param resource resource pointer of the group resource
+     * @param newActionSet pointer of ActionSet class instance
+     * @param callback callback for PUT operation.
+     *
+     * @return Returns ::OC_STACK_OK if success.
+     *
+     * @note OCStackResult is defined in ocstack.h.
+     */
     OCStackResult addActionSet(std::shared_ptr< OCResource > resource,
             const ActionSet* newActionSet, PutCallback cb);
+
+    /**
+     * API for executing an existing action set.
+     * Callback is called when the response of  POST operation arrives.
+     *
+     * @param resource resource pointer of the group resource
+     * @param actionsetName the action set name for executing the action set
+     * @param callback callback for POST operation.
+     *
+     * @return Returns ::OC_STACK_OK if success.
+     * @note OCStackResult is defined in ocstack.h.
+     */
     OCStackResult executeActionSet(std::shared_ptr< OCResource > resource,
             std::string actionsetName, PostCallback cb);
+
+    /**
+     * API for executing an existing action set.
+     * Callback is called when the response of  POST operation arrives.
+     *
+     * @param resource resource pointer of the group resource
+     * @param actionsetName the action set name for executing the action set
+     * @param delay waiting time for until the action set run.
+     * @param callback callback for POST operation.
+     *
+     * @return Returns ::OC_STACK_OK if success.
+     * @note OCStackResult is defined in ocstack.h.
+     */
     OCStackResult executeActionSet(std::shared_ptr< OCResource > resource,
             std::string actionsetName, long int delay, PostCallback cb);
+
+    /**
+     * API for canceling an existing action set.
+     * Callback is called when the response of POST operation arrives.
+     *
+     * @param resource resource pointer of the group resource
+     * @param actionsetName the action set name for executing the action set
+     * @param callback callback for POST operation.
+     *
+     * @return Returns ::OC_STACK_OK if success.
+     * @note OCStackResult is defined in ocstack.h.
+     */
     OCStackResult cancelActionSet(std::shared_ptr< OCResource > resource,
             std::string actionsetName, PostCallback cb);
+
+    /**
+     * API for reading an existing action set.
+     * Callback is called when the response of GET operation arrives.
+     *
+     * @param resource resource pointer of the group resource
+     * @param actionsetName the action set name for reading the action set
+     * @param callback callback for GET operation.
+     *
+     * @return Returns ::OC_STACK_OK if success.
+     * @note OCStackResult is defined in ocstack.h.
+     */
     OCStackResult getActionSet(std::shared_ptr< OCResource > resource, std::string actionsetName,
             PostCallback cb);
+
+    /**
+     * API for removing an existing action set.
+     * Callback is called when the response of  POST operation arrives.
+     *
+     * @param resource resource pointer of the group resource
+     * @param actionsetName the action set name for removing the action set
+     * @param callback callback for POST operation.
+     *
+     * @return Returns ::OC_STACK_OK if success.
+     * @note OCStackResult is defined in ocstack.h.
+     */
     OCStackResult deleteActionSet(std::shared_ptr< OCResource > resource, std::string actionsetName,
             PostCallback);
 };
diff --git a/service/things-manager/sdk/inc/GroupSynchronization.h b/service/things-manager/sdk/inc/GroupSynchronization.h
new file mode 100755 (executable)
index 0000000..d18f814
--- /dev/null
@@ -0,0 +1,233 @@
+//******************************************************************
+//
+// Copyright 2014 Samsung Electronics All Rights Reserved.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+/**
+ * @file
+ *
+ * This file contains the declaration of classes and its members related to
+ * GroupSynchronization.
+ */
+
+#ifndef __OC_GROUPSYNCHRONIZATION__
+#define __OC_GROUPSYNCHRONIZATION__
+
+#include <string>
+#include <vector>
+#include <map>
+#include <cstdlib>
+#include "OCPlatform.h"
+#include "OCApi.h"
+
+using namespace OC;
+
+namespace OIC
+{
+    class GroupSynchronization
+    {
+    private:
+
+        std::map< std::string, OCResourceHandle > collectionResourceHandleList;
+        // collection resource handle list
+        std::map< OCResourceHandle, std::vector< OCResourceHandle > > childResourceHandleList;
+
+        std::map< std::string, OCResourceHandle > groupSyncResourceHandleList;
+        // group sync resource handle list
+        std::map< std::string, std::shared_ptr< OCResource > > groupSyncResourceList;
+        // remote group sync resource list
+
+        std::vector< OCResourceHandle > deviceResourceHandleList; // these cannot be removed.
+        OCResourceHandle deviceResourceHandle;
+
+        OCResourceHandle collectionResourceHandle; // collection handle
+        std::shared_ptr< OCResource > remoteCollectionResource;
+
+        FindCallback findCallback;
+
+        std::vector< std::shared_ptr< OCResource > > foundGroupResourceList;
+
+        std::mutex foundGroupMutex;
+    //    std::mutex groupSyncMutex;
+
+        std::shared_ptr< OCResourceRequest > resourceRequest; // this is used for slow response
+
+        static GroupSynchronization* groupSyncnstance;
+        static bool bIsFinding;
+
+    public:
+
+        GroupSynchronization()
+        {
+            collectionResourceHandleList.clear();
+            childResourceHandleList.clear();
+            groupSyncResourceHandleList.clear();
+            groupSyncResourceList.clear();
+            deviceResourceHandleList.clear();
+
+            deviceResourceHandle = NULL;
+            collectionResourceHandle = NULL;
+            remoteCollectionResource = NULL;
+            findCallback = NULL;
+        }
+        ;
+
+        ~GroupSynchronization()
+        {
+            std::map< std::string, OCResourceHandle >::iterator handleIt;
+            for (handleIt = collectionResourceHandleList.begin();
+                    handleIt != collectionResourceHandleList.end(); ++handleIt)
+            {
+                deleteGroup(handleIt->first);
+            }
+        }
+        ;
+
+        // TODO: deprecated
+        static GroupSynchronization* getInstance();
+        void deleteInstance();
+
+        /**
+         * API for finding a specific remote group when a resource tries to join a group.
+         * Callback is called when a group is found or not.
+         *
+         * @param collectionResourceTypes resource types of a group to find and join
+         * @param callback callback. It has OCResource param.
+         *                    If a group is found, OCResource has the group resource.
+         *                    Otherwise, OCResource is NULL.
+         *
+         * @return Returns ::OC_STACK_OK if success.
+         * @note It returns OC_STACK ERROR when it is already finding a group.
+         *       You should call this api after the group finding process has stopped.
+         *       OCStackResult is defined in ocstack.h.
+         */
+        OCStackResult findGroup(std::vector< std::string > collectionResourceTypes,
+                FindCallback callback);
+
+        /**
+         * API for creating a new group.
+         *
+         * @param collectionResourceType resource type of a group to create
+         *
+         * @return Returns ::OC_STACK_OK if success.
+         * @note OCStackResult is defined in ocstack.h.
+         */
+        OCStackResult createGroup(std::string collectionResourceType);
+
+        /**
+         * API for joining a group. This API is used when a resource that has a group tries
+         * to find a specific remote resource and makes it join a group
+         *
+         * @param collectionResourceType resource type of a group to join.
+         * @param resourceHandle resource handle to join a group.
+         *
+         * @return Returns ::OC_STACK_OK if success.
+         *
+         * @note If you want to join the resource in the remote(other) process,
+         *       use joinGroup(const std::shared_ptr< OCResource >, OCResourceHandle)
+         *       instead of this.
+         *       OCStackResult is defined in ocstack.h.
+         */
+        OCStackResult joinGroup(std::string collectionResourceTyps,
+                OCResourceHandle resourceHandle);
+
+        /**
+         * API for joining a group. This API is used when a resource that
+         * doesn't have a group tries to find and join a specific remote group.
+         *
+         * @param resource group resource pointer to join.
+         *                   It can be the callback result of findGroup().
+         * @param resourceHandle resource handle to join a group.
+         *
+         * @return Returns ::OC_STACK_OK if success.
+         * @note If you want to join the resource in the same process,
+         *       use joinGroup(std::string, OCResourceHandle)
+         *       instead of this.
+         *       OCStackResult is defined in ocstack.h.
+         */
+        OCStackResult joinGroup(const std::shared_ptr< OCResource > resource,
+                OCResourceHandle resourceHandle);
+
+        /**
+         * API for leaving a joined group.
+         *
+         * @param collectionResourceType resource type of a group to leave.
+         * @param resourceHandle resource handle to leave a group.
+         *
+         * @return Returns ::OC_STACK_OK if success.
+         * @note OCStackResult is defined in ocstack.h.
+         */
+        OCStackResult leaveGroup(std::string collectionResourceType,
+                OCResourceHandle resourceHandle);
+
+        /**
+         * API for leaving a joined group.
+         *
+         * @param resource group resource pointer to join.
+         *                   It can be the callback result of findGroup().
+         *
+         * @param collectionResourceType resource type of a group to leave.
+         * @param resourceHandle resource handle to leave a group.
+         *
+         * @return Returns ::OC_STACK_OK if success.
+         *
+         * @note OCStackResult is defined in ocstack.h.
+         */
+        OCStackResult leaveGroup(const std::shared_ptr< OCResource > resource,
+                    std::string collectionResourceType,
+                    OCResourceHandle resourceHandle);
+
+        /**
+         * API for deleting a group.
+         *
+         * @param collectionResourceType resource type of a group to delete.
+         *
+         * @return void
+         */
+        void deleteGroup(std::string collectionResourceType);
+
+        /**
+         * API for getting a list of joined groups.
+         *
+         * @return std::map return value of this API.
+         *                  It returns group resource type and group resource handle as a map type.
+         */
+        std::map< std::string, OCResourceHandle > getGroupList();
+
+    private:
+
+        OCEntityHandlerResult groupEntityHandler(
+                const std::shared_ptr< OCResourceRequest > request);
+
+        void onFindGroup(std::shared_ptr< OCResource > resource);
+        void onJoinGroup(const HeaderOptions& headerOptions, const OCRepresentation& rep,
+                const int eCode);
+        void onFindResource(std::shared_ptr< OCResource > resource);
+        void onGetJoinedRemoteChild(const HeaderOptions& headerOptions, const OCRepresentation& rep,
+                const int eCode);
+        void onLeaveGroup(const HeaderOptions& headerOptions, const OCRepresentation& rep,
+                const int eCode);
+        void checkFindGroup(void);
+        bool IsSameGroup(std::shared_ptr< OCResource > resource);
+        void saveGroup(std::shared_ptr< OCResource > resource);
+
+        void debugGroupSync(void);
+
+    };
+}
+#endif    // __OC_GROUPSYNCHRONIZATION__
old mode 100644 (file)
new mode 100755 (executable)
similarity index 99%
rename from service/things-manager/sdk/src/ThingsConfiguration.h
rename to service/things-manager/sdk/inc/ThingsConfiguration.h
index ccf90d4..a45326d
@@ -116,8 +116,9 @@ namespace OIC
 
         static ThingsConfiguration *thingsConfigurationInstance;
         static ThingsConfiguration* getInstance();
-        void deleteInstance();
 
+        // TODO: deprecated
+        void deleteInstance();
         void setGroupManager(GroupManager *groupmanager);
 
         /**
old mode 100644 (file)
new mode 100755 (executable)
similarity index 74%
rename from service/things-manager/sdk/src/ThingsDiagnostics.h
rename to service/things-manager/sdk/inc/ThingsDiagnostics.h
index a144470..0763ec8
  * @file
  *
  * This file contains the declaration of classes and its members related to
- * ThingsDiagnostics.
+ * ThingsMaintenance.
  */
 
-#ifndef __OC_THINGSDIAGNOSTICS__
-#define __OC_THINGSDIAGNOSTICS__
+#ifndef __OC_THINGSMAINTENANCE__
+#define __OC_THINGSMAINTENANCE__
 
 #include <string>
 #include <vector>
 using namespace OC;
 namespace OIC
 {
-    /// Declearation of Diagnostics Callback funtion type
+    /// Declearation of Maintenance Callback funtion type
     typedef std::function<
             void(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode)
-            > DiagnosticsCallback;
+            > MaintenanceCallback;
 
     /**
      *  @brief
      *  The following class is used as a item stacking in request queue. The class stores a request
-     *  and referential information (e.g., a diagnostics name, a target resource object, a callback
+     *  and referential information (e.g., a maintenance name, a target resource object, a callback
      *  function passed from the applications, and a update value). When the function for updating/
-     *  getting diagnostics value is called from applications, this class instance is created and
+     *  getting maintenance value is called from applications, this class instance is created and
      *  stored in the request queue. The queue is maintained in a std::map structure so if desiring
-     *  to find a specific request, you can find it by querying a diagnostics name.
+     *  to find a specific request, you can find it by querying a maintenance name.
      */
-    class DiagnosticsRequestEntry
+    class MaintenanceRequestEntry
     {
     public:
-        DiagnosticsRequestEntry(std::string ID, DiagnosticsCallback callback,
+        MaintenanceRequestEntry(std::string ID, MaintenanceCallback callback,
                 std::shared_ptr< OCResource > resource, std::string updateVal);
 
-        // Diagnostics Name (used in key value in std::map structure)
+        // Maintenance Name (used in key value in std::map structure)
         // e.g., reboot and factoryset
         std::string m_ID;
 
         // Reference callback pointer
-        DiagnosticsCallback m_callback;
+        MaintenanceCallback m_callback;
 
         // Reference resource object
         std::shared_ptr< OCResource > m_resource;
 
-        // Update value only used for diagnostics update (always "true")
+        // Update value only used for maintenance update (always "true")
         std::string m_updateVal;
     };
 
     /**
      *  @brief
-     *  The following class is used to store providing diagnostics name and its relevant information
+     *  The following class is used to store providing maintenance name and its relevant information
      *  The relevant information includes a brief description, uri, and attribute key.
-     *  Note that a developer only specifies a diagnostics name, not URI nor attribute key, to
-     *  update a value to a remote. Thus, using diagnostics name, we convert it to more specific
+     *  Note that a developer only specifies a maintenance name, not URI nor attribute key, to
+     *  update a value to a remote. Thus, using maintenance name, we convert it to more specific
      *  information (i.e. uri and attribute key) to send a request. This class is reponsible to
      *  storing these information.
      */
-    class DiagnosticsUnitInfo
+    class MaintenanceUnitInfo
     {
     public:
         std::string m_name;
         std::string m_attribute;
         std::string m_uri;
 
-        DiagnosticsUnitInfo(std::string name, std::string attribute, std::string uri);
+        MaintenanceUnitInfo(std::string name, std::string attribute, std::string uri);
 
         // If a developer wants to know a list of configuration names, gives it in JSON format.
         std::string getJSON();
     };
 
 #define NUMDIAGUNIT 3
-    typedef std::string DiagnosticsName;
-    typedef std::string DiagnosticsValue;
+    typedef std::string MaintenanceName;
+    typedef std::string MaintenanceValue;
 
-    class ThingsDiagnostics
+    class ThingsMaintenance
     {
     public:
         /**
-         * Constructor for ThingsDiagnostics. Constructs a new ThingsDiagnostics
+         * Constructor for ThingsMaintenance. Constructs a new ThingsMaintenance
          */
-        ThingsDiagnostics(void);
+        ThingsMaintenance(void);
 
         /**
          * Virtual destructor
          */
-        ~ThingsDiagnostics(void);
+        ~ThingsMaintenance(void);
 
-        static ThingsDiagnostics *thingsDiagnosticsInstance;
-        static ThingsDiagnostics* getInstance();
-        void deleteInstance();
+        static ThingsMaintenance *thingsMaintenanceInstance;
+        static ThingsMaintenance* getInstance();
 
+        // TODO: deprecated
+        void deleteInstance();
         void setGroupManager(GroupManager *groupmanager);
 
         /**
@@ -129,7 +130,7 @@ namespace OIC
          *
          * NOTE: OCStackResult is defined in ocstack.h.
          */
-        OCStackResult reboot(std::shared_ptr< OCResource > resource, DiagnosticsCallback callback);
+        OCStackResult reboot(std::shared_ptr< OCResource > resource, MaintenanceCallback callback);
 
         /**
          * API for factory reset on device
@@ -144,21 +145,21 @@ namespace OIC
          */
 
         OCStackResult factoryReset(std::shared_ptr< OCResource > resource,
-                DiagnosticsCallback callback);
+                MaintenanceCallback callback);
 
         /**
-         * API to show a list of supported diagnostics units
+         * API to show a list of supported maintenance units
          * Callback call when a response arrives.
          *
          * @return the list in JSON format
          */
-        std::string getListOfSupportedDiagnosticsUnits();
+        std::string getListOfSupportedMaintenanceUnits();
 
     private:
 
         GroupManager *g_groupmanager;
 
-        std::vector< DiagnosticsUnitInfo > DiagnosticsUnitTable;
+        std::vector< MaintenanceUnitInfo > MaintenanceUnitTable;
 
         void onExecuteForGroupAction(const HeaderOptions& headerOptions,
                 const OCRepresentation& rep, const int eCode, std::string conf);
@@ -174,10 +175,10 @@ namespace OIC
                 std::string conf);
 
         std::shared_ptr< OCResource > getResource(std::string conf);
-        DiagnosticsCallback getCallback(std::string conf);
+        MaintenanceCallback getCallback(std::string conf);
         std::string getUpdateVal(std::string conf);
-        std::string getAttributeByDiagnosticsName(DiagnosticsName name);
-        std::string getUriByDiagnosticsName(DiagnosticsName name);
+        std::string getAttributeByMaintenanceName(MaintenanceName name);
+        std::string getUriByMaintenanceName(MaintenanceName name);
 
         std::string getHostFromURI(std::string oldUri);
 
diff --git a/service/things-manager/sdk/inc/ThingsManager.h b/service/things-manager/sdk/inc/ThingsManager.h
deleted file mode 100644 (file)
index 2b3ca94..0000000
+++ /dev/null
@@ -1,428 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-/**
- * @file
- *
- * This file contains the declaration of  ThingsManager class and its
- * members related to ThingsManager.
- */
-
-#ifndef __OC_THINGSMANAGER__
-#define __OC_THINGSMANAGER__
-
-#include <string>
-#include <vector>
-#include <map>
-#include <cstdlib>
-#include <ActionSet.h>
-#include "OCPlatform.h"
-#include "OCApi.h"
-
-using namespace OC;
-
-namespace OIC
-{
-    /**
-     * @class  ThingsManager
-     * @brief  This class provides a set of functions regarding group management,
-     *          synchronization of group, configuration of things, and diagnostics about things.
-     *
-     */
-    class ThingsManager
-    {
-    public:
-        /**
-         * Constructor for ThingsManager
-         */
-        ThingsManager(void);
-
-        /**
-         * Virtual destructor for ThingsManager
-         */
-        ~ThingsManager(void);
-
-        /**
-         * API for discoverying candidate resources.
-         * Callback is called  when all resource types are found.
-         *
-         * @param resourceTypes required resource types(called "candidate")
-         * @param candidateCallback callback. Returns OCResource vector.
-         *
-         * @return Returns ::OC_STACK_OK if success.
-         * @note OCStackResult is defined in ocstack.h.
-         */
-        OCStackResult findCandidateResources(std::vector< std::string > resourceTypes,
-                std::function< void(std::vector< std::shared_ptr< OCResource > >) > callback,
-                int waitsec);
-
-        /**
-         * API for subscribing child's state.
-         *
-         * @param resource collection resource for subscribing presence of all child resources.
-         * @param callback callback funcion for result of child's presence.
-         *
-         * @return Returns ::OC_STACK_OK if success.
-         * @note OCStackResult is defined in ocstack.h.
-         */
-        OCStackResult subscribeCollectionPresence(std::shared_ptr< OCResource > resource,
-                std::function< void(std::string, OCStackResult) > callback);
-
-        /**
-         * API for registering and binding resource to group.
-         *
-         * @param childHandle child resource handle. It will be filled from resource param.
-         * @param resource resource for registering and binding to group. It has all data.
-         * @param collectionHandle collection resource handle. It will be added child resource.
-         *
-         * @return Returns ::OC_STACK_OK if success.
-         * @note OCStackResult is defined in ocstack.h.
-         */
-        OCStackResult bindResourceToGroup(OCResourceHandle& childHandle,
-                std::shared_ptr< OCResource > resource, OCResourceHandle& collectionHandle);
-
-        // Group Synchronization
-
-        /**
-         * API for finding a specific remote group when a resource tries to join a group.
-         * Callback is called when a group is found or not.
-         *
-         * @param collectionResourceTypes resource types of a group to find and join
-         * @param callback callback. It has OCResource param.
-         *                    If a group is found, OCResource has the group resource.
-         *                    Otherwise, OCResource is NULL.
-         *
-         * @return Returns ::OC_STACK_OK if success.
-         * @note It returns OC_STACK ERROR when it is already finding a group.
-         *       You should call this api after the group finding process has stopped.
-         *       OCStackResult is defined in ocstack.h.
-         */
-        OCStackResult findGroup(std::vector< std::string > collectionResourceTypes,
-                FindCallback callback);
-
-        /**
-         * API for creating a new group.
-         *
-         * @param collectionResourceType resource type of a group to create
-         *
-         * @return Returns ::OC_STACK_OK if success.
-         * @note OCStackResult is defined in ocstack.h.
-         */
-        OCStackResult createGroup(std::string collectionResourceType);
-
-        /**
-         * API for joining a group. This API is used when a resource that has a group tries
-         * to find a specific remote resource and makes it join a group
-         *
-         * @param collectionResourceType resource type of a group to join.
-         * @param resourceHandle resource handle to join a group.
-         *
-         * @return Returns ::OC_STACK_OK if success.
-         *
-         * @note If you want to join the resource in the remote(other) process,
-         *       use joinGroup(const std::shared_ptr< OCResource >, OCResourceHandle)
-         *       instead of this.
-         *       OCStackResult is defined in ocstack.h.
-         */
-        OCStackResult joinGroup(std::string collectionResourceType,
-                OCResourceHandle resourceHandle);
-
-        /**
-         * API for joining a group. This API is used when a resource that
-         * doesn't have a group tries to find and join a specific remote group.
-         *
-         * @param resource group resource pointer to join.
-         *                   It can be the callback result of findGroup().
-         * @param resourceHandle resource handle to join a group.
-         *
-         * @return Returns ::OC_STACK_OK if success.
-         * @note If you want to join the resource in the same process,
-         *       use joinGroup(std::string, OCResourceHandle)
-         *       instead of this.
-         *       OCStackResult is defined in ocstack.h.
-         */
-        OCStackResult joinGroup(const std::shared_ptr< OCResource > resource,
-                OCResourceHandle resourceHandle);
-
-        /**
-         * API for leaving a joined group.
-         *
-         * @param collectionResourceType resource type of a group to leave.
-         * @param resourceHandle resource handle to leave a group.
-         *
-         * @return Returns ::OC_STACK_OK if success.
-         * @note OCStackResult is defined in ocstack.h.
-         */
-        OCStackResult leaveGroup(std::string collectionResourceType,
-                OCResourceHandle resourceHandle);
-
-        /**
-         * API for leaving a joined group.
-         *
-         * @param resource group resource pointer to join.
-         *                   It can be the callback result of findGroup().
-         *
-         * @param collectionResourceType resource type of a group to leave.
-         * @param resourceHandle resource handle to leave a group.
-         *
-         * @return Returns ::OC_STACK_OK if success.
-         *
-         * @note OCStackResult is defined in ocstack.h.
-         */
-        OCStackResult leaveGroup(const std::shared_ptr< OCResource > resource,
-                        std::string collectionResourceType,
-                        OCResourceHandle resourceHandle);
-
-        /**
-         * API for deleting a group.
-         *
-         * @param collectionResourceType resource type of a group to delete.
-         *
-         * @return void
-         */
-        void deleteGroup(std::string collectionResourceType);
-
-        /**
-         * API for getting a list of joined groups.
-         *
-         * @return std::map return value of this API.
-         *                  It returns group resource type and group resource handle as a map type.
-         */
-        std::map< std::string, OCResourceHandle > getGroupList();
-
-        // Things Configuration
-
-        /**
-         * API for updating configuration value of multiple things of a target group
-         * or a single thing.
-         * Callback is called when a response arrives.
-         * Before using the below function, a developer should acquire a resource pointer of
-         * (collection) resource that he wants to send a request by calling findResource() function
-         * provided in OCPlatform. And he should also notice a "Configuration Name" term which
-         * represents a nickname of a target attribute of a resource that he wants to update.
-         * The base motivation to introduce the term is to avoid a usage of URI to access a resource
-         * from a developer. Thus, a developer should know which configuration names are supported
-         * by Things Configuration class and what the configuration name means.
-         * To get a list of supported configuration names,
-         * use getListOfSupportedConfigurationUnits()
-         * function, which provides the list in JSON format.
-         *
-         * @param resource resource pointer representing the target group or the single thing.
-         * @param configurations ConfigurationUnit: an attribute key of target resource.
-         *                         (e.g., loc, st, c, r)
-         *                         Value : a value to be updated
-         * @param callback callback for updateConfigurations.
-         *
-         * @return Returns ::OC_STACK_OK if success.
-         * @note OCStackResult is defined in ocstack.h.
-         */
-        OCStackResult updateConfigurations(std::shared_ptr< OCResource > resource,
-                std::map< std::string, std::string > configurations,
-                std::function<
-                        void(const HeaderOptions& headerOptions, const OCRepresentation& rep,
-                                const int eCode) > callback);
-
-        /**
-         * API for getting configuration value of multiple things of a target group
-         * or a single thing.
-         * Callback is called when a response arrives.
-         *
-         * @param resource resource pointer representing the target group or the single thing.
-         * @param configurations ConfigurationUnit: an attribute key of target resource.
-         * @param callback callback for getConfigurations.
-         *
-         * @return Returns ::OC_STACK_OK if success.
-         * @note OCStackResult is defined in ocstack.h.
-         */
-        OCStackResult getConfigurations(std::shared_ptr< OCResource > resource,
-                std::vector< std::string > configurations,
-                std::function<
-                        void(const HeaderOptions& headerOptions, const OCRepresentation& rep,
-                                const int eCode) > callback);
-
-        /**
-         * API for showing the list of supported configuration units (attribute keys)
-         * Callback is called when a response arrives.
-         *
-         * @param void
-         * @return std::string return value of this API.
-         *                       It returns the list in JSON format
-         */
-        std::string getListOfSupportedConfigurationUnits();
-
-        /**
-         * API for boostrapping system configuration parameters from a bootstrap server.
-         * Callback is called when a response from the bootstrap server arrives.
-         *
-         * @param callback callback for doBootstrap.
-         *
-         * @return Returns ::OC_STACK_OK if success.
-         * @note OCStackResult is defined in ocstack.h.
-         */
-        OCStackResult doBootstrap(
-                std::function<
-                        void(const HeaderOptions& headerOptions, const OCRepresentation& rep,
-                                const int eCode) > callback);
-
-        // Things Diagnostics
-
-        /**
-         * API to let thing(device) reboot.
-         * The target thing could be a group of multiple things or a single thing.
-         * Callback is called when a response arrives.
-         *
-         * @param resource resource pointer representing the target group
-         * @param callback callback for reboot.
-         *
-         * @return Returns ::OC_STACK_OK if success.
-         * @note OCStackResult is defined in ocstack.h.
-         */
-        OCStackResult reboot(std::shared_ptr< OCResource > resource,
-                std::function<
-                        void(const HeaderOptions& headerOptions, const OCRepresentation& rep,
-                                const int eCode) > callback);
-
-        /**
-         * API for factory reset on thing(device).
-         * The target thing could be a group of multiple things or a single thing.
-         * Callback is called when a response arrives.
-         *
-         * @param resource resource pointer representing the target group
-         * @param callback callback for factoryReset.
-         *
-         * @return Returns ::OC_STACK_OK if success.
-         * @note OCStackResult is defined in ocstack.h.
-         */
-        OCStackResult factoryReset(std::shared_ptr< OCResource > resource,
-                std::function<
-                        void(const HeaderOptions& headerOptions, const OCRepresentation& rep,
-                                const int eCode) > callback);
-
-        // Group Action.
-
-        /**
-         * API for extracting an action set string from the ActionSet class instance
-         *
-         * @param newActionSet pointer of ActionSet class instance
-         *
-         * @return std::string return value of this API.
-         *                                          It returns an action set String.
-         * @note OCStackResult is defined in ocstack.h.
-         */
-        std::string getStringFromActionSet(const ActionSet *newActionSet);
-
-        /**
-         * API for extrracting ActionSet class instance from an action set string.
-         *
-         * @param desc description of an action set string
-         *
-         * @return ActionSet* return value of this API.
-         *                      It returns pointer of ActionSet.
-         */
-        ActionSet* getActionSetfromString(std::string desc);
-
-        /**
-         * API for adding an action set.
-         * Callback is called when the response of PUT operation arrives.
-         *
-         * @param resource resource pointer of the group resource
-         * @param newActionSet pointer of ActionSet class instance
-         * @param callback callback for PUT operation.
-         *
-         * @return Returns ::OC_STACK_OK if success.
-         *
-         * @note OCStackResult is defined in ocstack.h.
-         */
-        OCStackResult addActionSet(std::shared_ptr< OCResource > resource,
-                const ActionSet* newActionSet, PutCallback cb);
-
-        /**
-         * API for executing an existing action set.
-         * Callback is called when the response of  POST operation arrives.
-         *
-         * @param resource resource pointer of the group resource
-         * @param actionsetName the action set name for executing the action set
-         * @param callback callback for POST operation.
-         *
-         * @return Returns ::OC_STACK_OK if success.
-         * @note OCStackResult is defined in ocstack.h.
-         */
-        OCStackResult executeActionSet(std::shared_ptr< OCResource > resource,
-                std::string actionsetName, PostCallback cb);
-
-        /**
-         * API for executing an existing action set.
-         * Callback is called when the response of  POST operation arrives.
-         *
-         * @param resource resource pointer of the group resource
-         * @param actionsetName the action set name for executing the action set
-         * @param delay waiting time for until the action set run.
-         * @param callback callback for POST operation.
-         *
-         * @return Returns ::OC_STACK_OK if success.
-         * @note OCStackResult is defined in ocstack.h.
-         */
-        OCStackResult executeActionSet(std::shared_ptr< OCResource > resource,
-                std::string actionsetName, long int delay, PostCallback cb);
-
-        /**
-         * API for canceling an existing action set.
-         * Callback is called when the response of POST operation arrives.
-         *
-         * @param resource resource pointer of the group resource
-         * @param actionsetName the action set name for executing the action set
-         * @param callback callback for POST operation.
-         *
-         * @return Returns ::OC_STACK_OK if success.
-         * @note OCStackResult is defined in ocstack.h.
-         */
-        OCStackResult cancelActionSet(std::shared_ptr< OCResource > resource,
-                std::string actionsetName, PostCallback cb);
-        /**
-         * API for reading an existing action set.
-         * Callback is called when the response of GET operation arrives.
-         *
-         * @param resource resource pointer of the group resource
-         * @param actionsetName the action set name for reading the action set
-         * @param callback callback for GET operation.
-         *
-         * @return Returns ::OC_STACK_OK if success.
-         * @note OCStackResult is defined in ocstack.h.
-         */
-        OCStackResult getActionSet(std::shared_ptr< OCResource > resource,
-                std::string actionsetName, GetCallback cb);
-
-        /**
-         * API for removing an existing action set.
-         * Callback is called when the response of  POST operation arrives.
-         *
-         * @param resource resource pointer of the group resource
-         * @param actionsetName the action set name for removing the action set
-         * @param callback callback for POST operation.
-         *
-         * @return Returns ::OC_STACK_OK if success.
-         * @note OCStackResult is defined in ocstack.h.
-         */
-        OCStackResult deleteActionSet(std::shared_ptr< OCResource > resource,
-                std::string actionsetName, PostCallback);
-
-    };
-}
-#endif  /* __OC_THINGSMANAGER__*/
diff --git a/service/things-manager/sdk/src/GroupSynchronization.h b/service/things-manager/sdk/src/GroupSynchronization.h
deleted file mode 100644 (file)
index 6c0252b..0000000
+++ /dev/null
@@ -1,144 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-/**
- * @file
- *
- * This file contains the declaration of classes and its members related to
- * GroupSynchronization.
- */
-
-#ifndef __OC_GROUPSYNCHRONIZATION__
-#define __OC_GROUPSYNCHRONIZATION__
-
-#include <string>
-#include <vector>
-#include <map>
-#include <cstdlib>
-#include "OCPlatform.h"
-#include "OCApi.h"
-
-using namespace OC;
-
-namespace OIC
-{
-class GroupSynchronization
-{
-private:
-
-    std::map< std::string, OCResourceHandle > collectionResourceHandleList;
-    // collection resource handle list
-    std::map< OCResourceHandle, std::vector< OCResourceHandle > > childResourceHandleList;
-
-    std::map< std::string, OCResourceHandle > groupSyncResourceHandleList;
-    // group sync resource handle list
-    std::map< std::string, std::shared_ptr< OCResource > > groupSyncResourceList;
-    // remote group sync resource list
-
-    std::vector< OCResourceHandle > deviceResourceHandleList; // these cannot be removed.
-    OCResourceHandle deviceResourceHandle;
-
-    OCResourceHandle collectionResourceHandle; // collection handle
-    std::shared_ptr< OCResource > remoteCollectionResource;
-
-    FindCallback findCallback;
-
-    std::vector< std::shared_ptr< OCResource > > foundGroupResourceList;
-
-    std::mutex foundGroupMutex;
-//    std::mutex groupSyncMutex;
-
-    std::shared_ptr< OCResourceRequest > resourceRequest; // this is used for slow response
-
-    static GroupSynchronization* groupSyncnstance;
-    static bool bIsFinding;
-
-    GroupSynchronization()
-    {
-        collectionResourceHandleList.clear();
-        childResourceHandleList.clear();
-        groupSyncResourceHandleList.clear();
-        groupSyncResourceList.clear();
-        deviceResourceHandleList.clear();
-
-        deviceResourceHandle = NULL;
-        collectionResourceHandle = NULL;
-        remoteCollectionResource = NULL;
-        findCallback = NULL;
-    }
-    ;
-
-    ~GroupSynchronization()
-    {
-        std::map< std::string, OCResourceHandle >::iterator handleIt;
-        for (handleIt = collectionResourceHandleList.begin();
-                handleIt != collectionResourceHandleList.end(); ++handleIt)
-        {
-            deleteGroup(handleIt->first);
-        }
-    }
-    ;
-
-public:
-
-    static GroupSynchronization* getInstance();
-    void deleteInstance();
-
-    OCStackResult findGroup(std::vector< std::string > collectionResourceTypes,
-            FindCallback callback);
-    OCStackResult createGroup(std::string collectionResourceType);
-    OCStackResult joinGroup(std::string collectionResourceTyps,
-            OCResourceHandle resourceHandle);
-    OCStackResult joinGroup(const std::shared_ptr< OCResource > resource,
-            OCResourceHandle resourceHandle);
-    OCStackResult leaveGroup(std::string collectionResourceType,
-            OCResourceHandle resourceHandle);
-    OCStackResult leaveGroup(const std::shared_ptr< OCResource > resource,
-                std::string collectionResourceType,
-                OCResourceHandle resourceHandle);
-    void deleteGroup(std::string collectionResourceType);
-
-    std::map< std::string, OCResourceHandle > getGroupList();
-
-private:
-
-    OCEntityHandlerResult groupEntityHandler(
-            const std::shared_ptr< OCResourceRequest > request);
-
-    void onFindGroup(std::shared_ptr< OCResource > resource);
-    void onJoinGroup(const HeaderOptions& headerOptions, const OCRepresentation& rep,
-            const int eCode);
-    void onFindResource(std::shared_ptr< OCResource > resource);
-    void onGetJoinedRemoteChild(const HeaderOptions& headerOptions, const OCRepresentation& rep,
-            const int eCode);
-    void onLeaveGroup(const HeaderOptions& headerOptions, const OCRepresentation& rep,
-            const int eCode);
-//    void onSubscribePresence (OCStackResult result,
-//        const unsigned int nonce/*, std::string resourceType, std::string host*/);
-
-    void checkFindGroup(void);
-    bool IsSameGroup(std::shared_ptr< OCResource > resource);
-    void saveGroup(std::shared_ptr< OCResource > resource);
-
-    void debugGroupSync(void);
-
-};
-}
-#endif    // __OC_GROUPSYNCHRONIZATION__
old mode 100644 (file)
new mode 100755 (executable)
index 5c65f21..b9cf49b
@@ -33,10 +33,10 @@ using namespace OC;
 
 namespace OIC
 {
-    std::map< std::string, DiagnosticsRequestEntry > diagnosticsRequestTable;
-    ThingsDiagnostics* ThingsDiagnostics::thingsDiagnosticsInstance = NULL;
+    std::map< std::string, MaintenanceRequestEntry > maintenanceRequestTable;
+    ThingsMaintenance* ThingsMaintenance::thingsMaintenanceInstance = NULL;
 
-    DiagnosticsRequestEntry::DiagnosticsRequestEntry(std::string ID, DiagnosticsCallback callback,
+    MaintenanceRequestEntry::MaintenanceRequestEntry(std::string ID, MaintenanceCallback callback,
                 std::shared_ptr< OCResource > resource, std::string updateVal)
     {
         m_ID = ID;
@@ -45,7 +45,7 @@ namespace OIC
         m_updateVal = updateVal;
     }
 
-    DiagnosticsUnitInfo::DiagnosticsUnitInfo(std::string name,
+    MaintenanceUnitInfo::MaintenanceUnitInfo(std::string name,
                                             std::string attribute,
                                             std::string uri)
     {
@@ -54,7 +54,7 @@ namespace OIC
         m_uri = uri;
     }
 
-    std::string DiagnosticsUnitInfo::getJSON()
+    std::string MaintenanceUnitInfo::getJSON()
     {
         std::string res;
 
@@ -63,48 +63,48 @@ namespace OIC
         return res;
     }
 
-    ThingsDiagnostics::ThingsDiagnostics()
+    ThingsMaintenance::ThingsMaintenance()
     {
-        DiagnosticsUnitInfo unit[] =
+        MaintenanceUnitInfo unit[] =
                 {
-                { "rb", "Reboot", "/oic/diag"},
-                { "ssc", "StartStatCollection", "/oic/diag"},
-                { "fr", "Factory Reset", "/oic/diag" } };
+                { "rb", "Reboot", "/oic/mnt"},
+                { "ssc", "StartStatCollection", "/oic/mnt"},
+                { "fr", "Factory Reset", "/oic/mnt" } };
 
         for (int i = 0; i < NUMDIAGUNIT; i++)
-            DiagnosticsUnitTable.push_back(unit[i]);
+            MaintenanceUnitTable.push_back(unit[i]);
     }
 
-    ThingsDiagnostics::~ThingsDiagnostics()
+    ThingsMaintenance::~ThingsMaintenance()
     {
     }
 
-    void ThingsDiagnostics::setGroupManager(GroupManager *groupmanager)
+    void ThingsMaintenance::setGroupManager(GroupManager *groupmanager)
     {
         g_groupmanager = groupmanager;
     }
 
-    ThingsDiagnostics* ThingsDiagnostics::getInstance()
+    ThingsMaintenance* ThingsMaintenance::getInstance()
     {
-        if (thingsDiagnosticsInstance == NULL)
+        if (thingsMaintenanceInstance == NULL)
         {
-            thingsDiagnosticsInstance = new ThingsDiagnostics();
+            thingsMaintenanceInstance = new ThingsMaintenance();
         }
-        return thingsDiagnosticsInstance;
+        return thingsMaintenanceInstance;
     }
 
-    void ThingsDiagnostics::deleteInstance()
+    void ThingsMaintenance::deleteInstance()
     {
-        if (thingsDiagnosticsInstance)
+        if (thingsMaintenanceInstance)
         {
-            delete thingsDiagnosticsInstance;
-            thingsDiagnosticsInstance = NULL;
+            delete thingsMaintenanceInstance;
+            thingsMaintenanceInstance = NULL;
         }
     }
 
-    std::string ThingsDiagnostics::getAttributeByDiagnosticsName(DiagnosticsName name)
+    std::string ThingsMaintenance::getAttributeByMaintenanceName(MaintenanceName name)
     {
-        for (auto it = DiagnosticsUnitTable.begin(); DiagnosticsUnitTable.end() != it; it++)
+        for (auto it = MaintenanceUnitTable.begin(); MaintenanceUnitTable.end() != it; it++)
         {
             if ((*it).m_name == name)
                 return (*it).m_attribute;
@@ -113,9 +113,9 @@ namespace OIC
         return "";
     }
 
-    std::string ThingsDiagnostics::getUriByDiagnosticsName(DiagnosticsName name)
+    std::string ThingsMaintenance::getUriByMaintenanceName(MaintenanceName name)
     {
-        for (auto it = DiagnosticsUnitTable.begin(); DiagnosticsUnitTable.end() != it; it++)
+        for (auto it = MaintenanceUnitTable.begin(); MaintenanceUnitTable.end() != it; it++)
         {
             if ((*it).m_name == name)
                 return (*it).m_uri;
@@ -124,40 +124,40 @@ namespace OIC
         return "";
     }
 
-    std::string ThingsDiagnostics::getUpdateVal(std::string diag)
+    std::string ThingsMaintenance::getUpdateVal(std::string mnt)
     {
-        std::map< std::string, DiagnosticsRequestEntry >::iterator it =
-                diagnosticsRequestTable.find(diag);
+        std::map< std::string, MaintenanceRequestEntry >::iterator it =
+                maintenanceRequestTable.find(mnt);
 
-        if (it == diagnosticsRequestTable.end())
+        if (it == maintenanceRequestTable.end())
             return NULL;
         else
             return it->second.m_updateVal;
 
     }
-    std::shared_ptr< OCResource > ThingsDiagnostics::getResource(std::string diag)
+    std::shared_ptr< OCResource > ThingsMaintenance::getResource(std::string mnt)
     {
-        std::map< std::string, DiagnosticsRequestEntry >::iterator it =
-                diagnosticsRequestTable.find(diag);
+        std::map< std::string, MaintenanceRequestEntry >::iterator it =
+                maintenanceRequestTable.find(mnt);
 
-        if (it == diagnosticsRequestTable.end())
+        if (it == maintenanceRequestTable.end())
             return NULL;
         else
             return it->second.m_resource;
     }
 
-    DiagnosticsCallback ThingsDiagnostics::getCallback(std::string diag)
+    MaintenanceCallback ThingsMaintenance::getCallback(std::string mnt)
     {
-        std::map< std::string, DiagnosticsRequestEntry >::iterator it =
-                diagnosticsRequestTable.find(diag);
+        std::map< std::string, MaintenanceRequestEntry >::iterator it =
+                maintenanceRequestTable.find(mnt);
 
-        if (it == diagnosticsRequestTable.end())
+        if (it == maintenanceRequestTable.end())
             return NULL;
         else
             return it->second.m_callback;
     }
 
-    std::string ThingsDiagnostics::getHostFromURI(std::string oldUri)
+    std::string ThingsMaintenance::getHostFromURI(std::string oldUri)
     {
         size_t f;
         std::string newUri;
@@ -170,19 +170,19 @@ namespace OIC
         return newUri;
     }
 
-    std::string ThingsDiagnostics::getListOfSupportedDiagnosticsUnits()
+    std::string ThingsMaintenance::getListOfSupportedMaintenanceUnits()
     {
         std::string res;
 
-        res = "{\"Diagnostics Units\":[";
+        res = "{\"Maintenance Units\":[";
 
-        auto it = DiagnosticsUnitTable.begin();
+        auto it = MaintenanceUnitTable.begin();
         while (1)
         {
             res = res + (*it).getJSON();
             it++;
 
-            if (it == DiagnosticsUnitTable.end())
+            if (it == MaintenanceUnitTable.end())
                 break;
             else
                 res += ",";
@@ -193,13 +193,13 @@ namespace OIC
         return res;
     }
 
-    void ThingsDiagnostics::onGetChildInfoForUpdate(const HeaderOptions& headerOptions,
-            const OCRepresentation& rep, const int eCode, std::string diag)
+    void ThingsMaintenance::onGetChildInfoForUpdate(const HeaderOptions& headerOptions,
+            const OCRepresentation& rep, const int eCode, std::string mnt)
     {
         if (eCode != OC_STACK_OK)
         {
             std::cout << "onGet Response error: " << eCode << std::endl;
-            getCallback(diag)(headerOptions, rep, eCode);
+            getCallback(mnt)(headerOptions, rep, eCode);
             return ;
         }
 
@@ -213,11 +213,11 @@ namespace OIC
             std::cout << "\t\tChild Resource URI: " << oit->getUri() << std::endl;
         }
 
-        // Get information by using diagnostics name(diag)
-        std::shared_ptr < OCResource > resource = getResource(diag);
-        std::string actionstring = diag;
-        std::string uri = getUriByDiagnosticsName(diag);
-        std::string attrKey = diag;
+        // Get information by using maintenance name(mnt)
+        std::shared_ptr < OCResource > resource = getResource(mnt);
+        std::string actionstring = mnt;
+        std::string uri = getUriByMaintenanceName(mnt);
+        std::string attrKey = mnt;
 
         if (uri == "")
             return;
@@ -228,7 +228,7 @@ namespace OIC
             // Required information consists of a host address, URI, attribute key, and
             // attribute value.
             ActionSet *newActionSet = new ActionSet();
-            newActionSet->actionsetName = diag;
+            newActionSet->actionsetName = mnt;
 
             for (auto oit = children.begin(); oit != children.end(); ++oit)
             {
@@ -242,7 +242,7 @@ namespace OIC
 
                 Capability *newCapability = new Capability();
                 newCapability->capability = attrKey;
-                newCapability->status = getUpdateVal(diag);
+                newCapability->status = getUpdateVal(mnt);
 
                 newAction->listOfCapability.push_back(newCapability);
                 newActionSet->listOfAction.push_back(newAction);
@@ -253,97 +253,97 @@ namespace OIC
                     std::function<
                             void(const HeaderOptions& headerOptions,
                                     const OCRepresentation& rep, const int eCode) >(
-                            std::bind(&ThingsDiagnostics::onCreateActionSet, this,
+                            std::bind(&ThingsMaintenance::onCreateActionSet, this,
                                     std::placeholders::_1, std::placeholders::_2,
-                                    std::placeholders::_3, diag)));
+                                    std::placeholders::_3, mnt)));
 
             delete(newActionSet);
 
         }
     }
 
-    void ThingsDiagnostics::onCreateActionSet(const HeaderOptions& headerOptions,
-            const OCRepresentation& rep, const int eCode, std::string diag)
+    void ThingsMaintenance::onCreateActionSet(const HeaderOptions& headerOptions,
+            const OCRepresentation& rep, const int eCode, std::string mnt)
     {
         if (eCode != OC_STACK_OK)
         {
             std::cout << "onPut Response error: " << eCode << std::endl;
-            getCallback(diag)(headerOptions, rep, eCode);
+            getCallback(mnt)(headerOptions, rep, eCode);
             return ;
         }
 
         std::cout << "PUT request was successful" << std::endl;
 
-        std::shared_ptr < OCResource > resource = getResource(diag);
+        std::shared_ptr < OCResource > resource = getResource(mnt);
         if (resource)
         {
             // Now, it is time to execute the action set.
-            g_groupmanager->executeActionSet(resource, diag,
+            g_groupmanager->executeActionSet(resource, mnt,
                     std::function<
                             void(const HeaderOptions& headerOptions,
                                     const OCRepresentation& rep, const int eCode) >(
-                            std::bind(&ThingsDiagnostics::onExecuteForGroupAction, this,
+                            std::bind(&ThingsMaintenance::onExecuteForGroupAction, this,
                                     std::placeholders::_1, std::placeholders::_2,
-                                    std::placeholders::_3, diag)));
+                                    std::placeholders::_3, mnt)));
         }
     }
 
-    void ThingsDiagnostics::onExecuteForGroupAction(const HeaderOptions& headerOptions,
-            const OCRepresentation& rep, const int eCode, std::string diag)
+    void ThingsMaintenance::onExecuteForGroupAction(const HeaderOptions& headerOptions,
+            const OCRepresentation& rep, const int eCode, std::string mnt)
     {
         if (eCode != OC_STACK_OK)
         {
             std::cout << "onPut Response error: " << eCode << std::endl;
-            getCallback(diag)(headerOptions, rep, eCode);
+            getCallback(mnt)(headerOptions, rep, eCode);
             return ;
         }
 
         std::cout << "PUT request was successful" << std::endl;
-        getCallback(diag)(headerOptions, rep, eCode);
+        getCallback(mnt)(headerOptions, rep, eCode);
 
         // Delete the created actionset
-        std::shared_ptr < OCResource > resource = getResource(diag);
+        std::shared_ptr < OCResource > resource = getResource(mnt);
         if (resource)
         {
-            g_groupmanager->deleteActionSet(resource, diag,
+            g_groupmanager->deleteActionSet(resource, mnt,
                     std::function<
                             void(const HeaderOptions& headerOptions,
                                     const OCRepresentation& rep, const int eCode) >(
-                            std::bind(&ThingsDiagnostics::onDeleteGroupAction, this,
+                            std::bind(&ThingsMaintenance::onDeleteGroupAction, this,
                                     std::placeholders::_1, std::placeholders::_2,
-                                    std::placeholders::_3, diag)));
+                                    std::placeholders::_3, mnt)));
         }
     }
 
-    void ThingsDiagnostics::onDeleteGroupAction(const HeaderOptions& headerOptions,
-            const OCRepresentation& rep, const int eCode, std::string diag)
+    void ThingsMaintenance::onDeleteGroupAction(const HeaderOptions& headerOptions,
+            const OCRepresentation& rep, const int eCode, std::string mnt)
     {
         if (eCode != OC_STACK_OK)
         {
-            std::cout << "Delete actionset returned with error: " << eCode << diag << std::endl;
+            std::cout << "Delete actionset returned with error: " << eCode << mnt << std::endl;
             return;
         }
 
-        std::cout << "Deleted the actionset created!" << diag<< std::endl;
+        std::cout << "Deleted the actionset created!" << mnt<< std::endl;
     }
 
-    void ThingsDiagnostics::onPut(const HeaderOptions& headerOptions, const OCRepresentation& rep,
-            const int eCode, std::string diag)
+    void ThingsMaintenance::onPut(const HeaderOptions& headerOptions, const OCRepresentation& rep,
+            const int eCode, std::string mnt)
     {
         if (eCode != OC_STACK_OK)
         {
             std::cout << "onPut Response error: " << eCode << std::endl;
-            getCallback(diag)(headerOptions, rep, eCode);
+            getCallback(mnt)(headerOptions, rep, eCode);
             return ;
         }
 
         std::cout << "PUT request was successful" << std::endl;
 
-        getCallback(diag)(headerOptions, rep, eCode);
+        getCallback(mnt)(headerOptions, rep, eCode);
 
     }
 
-    bool ThingsDiagnostics::isSimpleResource(std::shared_ptr< OCResource > resource)
+    bool ThingsMaintenance::isSimpleResource(std::shared_ptr< OCResource > resource)
     {
         for (unsigned int i = 0; i < resource->getResourceTypes().size(); ++i)
         {
@@ -354,8 +354,8 @@ namespace OIC
         return true;
     }
 
-    OCStackResult ThingsDiagnostics::reboot(std::shared_ptr< OCResource > resource,
-            DiagnosticsCallback callback)
+    OCStackResult ThingsMaintenance::reboot(std::shared_ptr< OCResource > resource,
+            MaintenanceCallback callback)
     {
         if (!resource)
         {
@@ -363,17 +363,17 @@ namespace OIC
             return OC_STACK_ERROR;
         }
 
-        std::string diag = "rb";
+        std::string mnt = "rb";
 
         // Check the request queue if a previous request is still left. If so, remove it.
-        std::map< std::string, DiagnosticsRequestEntry >::iterator iter =
-                diagnosticsRequestTable.find(diag);
-        if (iter != diagnosticsRequestTable.end())
-            diagnosticsRequestTable.erase(iter);
+        std::map< std::string, MaintenanceRequestEntry >::iterator iter =
+                maintenanceRequestTable.find(mnt);
+        if (iter != maintenanceRequestTable.end())
+            maintenanceRequestTable.erase(iter);
 
         // Create new request entry stored in the queue
-        DiagnosticsRequestEntry newCallback(diag, callback, resource, "true");
-        diagnosticsRequestTable.insert(std::make_pair(diag, newCallback));
+        MaintenanceRequestEntry newCallback(mnt, callback, resource, "true");
+        maintenanceRequestTable.insert(std::make_pair(mnt, newCallback));
 
         QueryParamsMap query;
         OCRepresentation rep;
@@ -382,14 +382,14 @@ namespace OIC
         {
             // This resource is a simple resource. Just send a PUT message
             OCRepresentation rep;
-            rep.setValue < std::string > (diag, "true");
+            rep.setValue < std::string > (mnt, "true");
 
             return resource->put(resource->getResourceTypes().at(0), DEFAULT_INTERFACE, rep, query,
                     std::function<
                             void(const HeaderOptions& headerOptions, const OCRepresentation& rep,
                                     const int eCode) >(
-                            std::bind(&ThingsDiagnostics::onPut, this, std::placeholders::_1,
-                                    std::placeholders::_2, std::placeholders::_3, diag)));
+                            std::bind(&ThingsMaintenance::onPut, this, std::placeholders::_1,
+                                    std::placeholders::_2, std::placeholders::_3, mnt)));
         }
         else
         {
@@ -401,14 +401,14 @@ namespace OIC
                     std::function<
                             void(const HeaderOptions& headerOptions, const OCRepresentation& rep,
                                     const int eCode) >(
-                            std::bind(&ThingsDiagnostics::onGetChildInfoForUpdate, this,
+                            std::bind(&ThingsMaintenance::onGetChildInfoForUpdate, this,
                                     std::placeholders::_1, std::placeholders::_2,
-                                    std::placeholders::_3, diag)));
+                                    std::placeholders::_3, mnt)));
         }
     }
 
-    OCStackResult ThingsDiagnostics::factoryReset(std::shared_ptr< OCResource > resource,
-            DiagnosticsCallback callback)
+    OCStackResult ThingsMaintenance::factoryReset(std::shared_ptr< OCResource > resource,
+            MaintenanceCallback callback)
     {
         if (!resource)
         {
@@ -416,17 +416,17 @@ namespace OIC
             return OC_STACK_ERROR;
         }
 
-        std::string diag = "fr";
+        std::string mnt = "fr";
 
         // Check the request queue if a previous request is still left. If so, remove it.
-        std::map< std::string, DiagnosticsRequestEntry >::iterator iter =
-                diagnosticsRequestTable.find(diag);
-        if (iter != diagnosticsRequestTable.end())
-            diagnosticsRequestTable.erase(iter);
+        std::map< std::string, MaintenanceRequestEntry >::iterator iter =
+                maintenanceRequestTable.find(mnt);
+        if (iter != maintenanceRequestTable.end())
+            maintenanceRequestTable.erase(iter);
 
         // Create new request entry stored in the queue
-        DiagnosticsRequestEntry newCallback(diag, callback, resource, "true");
-        diagnosticsRequestTable.insert(std::make_pair(diag, newCallback));
+        MaintenanceRequestEntry newCallback(mnt, callback, resource, "true");
+        maintenanceRequestTable.insert(std::make_pair(mnt, newCallback));
 
         QueryParamsMap query;
         OCRepresentation rep;
@@ -441,8 +441,8 @@ namespace OIC
                     std::function<
                             void(const HeaderOptions& headerOptions, const OCRepresentation& rep,
                                     const int eCode) >(
-                            std::bind(&ThingsDiagnostics::onPut, this, std::placeholders::_1,
-                                    std::placeholders::_2, std::placeholders::_3, diag)));
+                            std::bind(&ThingsMaintenance::onPut, this, std::placeholders::_1,
+                                    std::placeholders::_2, std::placeholders::_3, mnt)));
         }
         else
         {
@@ -454,9 +454,9 @@ namespace OIC
                     std::function<
                             void(const HeaderOptions& headerOptions, const OCRepresentation& rep,
                                     const int eCode) >(
-                            std::bind(&ThingsDiagnostics::onGetChildInfoForUpdate, this,
+                            std::bind(&ThingsMaintenance::onGetChildInfoForUpdate, this,
                                     std::placeholders::_1, std::placeholders::_2,
-                                    std::placeholders::_3, diag)));
+                                    std::placeholders::_3, mnt)));
         }
     }
 }
diff --git a/service/things-manager/sdk/src/ThingsManager.cpp b/service/things-manager/sdk/src/ThingsManager.cpp
deleted file mode 100644 (file)
index 3c0178f..0000000
+++ /dev/null
@@ -1,215 +0,0 @@
-//******************************************************************
-//
-// Copyright 2014 Samsung Electronics All Rights Reserved.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-/**
- * @file
- *
- */
-
-#include "ThingsManager.h"
-#include "GroupManager.h"
-#include "GroupSynchronization.h"
-#include "ThingsConfiguration.h"
-#include "ThingsDiagnostics.h"
-#include <algorithm>
-#include <thread>
-
-using namespace OC;
-namespace OIC
-{
-
-    GroupManager *g_groupManager;
-    GroupSynchronization *g_groupSync = NULL;
-    ThingsConfiguration *g_thingsConf = NULL;
-    ThingsDiagnostics *g_thingsDiag = NULL;
-
-    ThingsManager::ThingsManager(void)
-    {
-        g_groupManager = new GroupManager();
-        g_groupSync = GroupSynchronization::getInstance();
-        g_thingsConf = ThingsConfiguration::getInstance();
-        g_thingsDiag = ThingsDiagnostics::getInstance();
-        g_thingsConf->setGroupManager(g_groupManager);
-        g_thingsDiag->setGroupManager(g_groupManager);
-    }
-
-    /**
-     * Virtual destructor
-     */
-    ThingsManager::~ThingsManager(void)
-    {
-        delete g_groupManager;
-        g_groupSync->deleteInstance();
-        g_thingsConf->deleteInstance();
-        g_thingsDiag->deleteInstance();
-    }
-
-    OCStackResult ThingsManager::findCandidateResources(std::vector< std::string > resourceTypes,
-            std::function< void(std::vector< std::shared_ptr< OCResource > >) > callback,
-            int waitsec)
-    {
-        OCStackResult result = g_groupManager->findCandidateResources(resourceTypes, callback,
-                waitsec);
-
-        return result;
-    }
-
-    OCStackResult ThingsManager::subscribeCollectionPresence(std::shared_ptr< OCResource > resource,
-            std::function< void(std::string, OCStackResult) > callback)
-    {
-        OCStackResult result = g_groupManager->subscribeCollectionPresence(resource, callback);
-
-        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)
-    {
-        OCStackResult result = g_groupSync->findGroup(collectionResourceTypes, callback);
-
-        return result;
-    }
-
-    OCStackResult ThingsManager::createGroup(std::string collectionResourceType)
-    {
-        OCStackResult result = g_groupSync->createGroup(collectionResourceType);
-
-        return result;
-    }
-
-    OCStackResult ThingsManager::joinGroup(std::string collectionResourceType,
-            OCResourceHandle resourceHandle)
-    {
-        OCStackResult result = g_groupSync->joinGroup(collectionResourceType, resourceHandle);
-
-        return result;
-    }
-
-    OCStackResult ThingsManager::joinGroup(const std::shared_ptr< OCResource > resource,
-            OCResourceHandle resourceHandle)
-    {
-        OCStackResult result = g_groupSync->joinGroup(resource, resourceHandle);
-
-        return result;
-    }
-
-    OCStackResult ThingsManager::leaveGroup(std::string collectionResourceType,
-            OCResourceHandle resourceHandle)
-    {
-        OCStackResult result = g_groupSync->leaveGroup(collectionResourceType, resourceHandle);
-
-        return result;
-    }
-
-    OCStackResult ThingsManager::leaveGroup(const std::shared_ptr< OCResource > resource,
-                            std::string collectionResourceType,
-                            OCResourceHandle resourceHandle)
-    {
-        return g_groupSync->leaveGroup(resource, collectionResourceType, resourceHandle);
-    }
-
-    void ThingsManager::deleteGroup(std::string collectionResourceType)
-    {
-        g_groupSync->deleteGroup(collectionResourceType);
-    }
-
-    std::map< std::string, OCResourceHandle > ThingsManager::getGroupList()
-    {
-        return g_groupSync->getGroupList();
-    }
-
-    OCStackResult ThingsManager::updateConfigurations(std::shared_ptr< OCResource > resource,
-            std::map< ConfigurationName, ConfigurationValue > configurations,
-            ConfigurationCallback callback)
-    {
-        return g_thingsConf->updateConfigurations(resource, configurations, callback);
-    }
-    OCStackResult ThingsManager::getConfigurations(std::shared_ptr< OCResource > resource,
-            std::vector< ConfigurationName > configurations, ConfigurationCallback callback)
-    {
-        return g_thingsConf->getConfigurations(resource, configurations, callback);
-    }
-    std::string ThingsManager::getListOfSupportedConfigurationUnits()
-    {
-        return g_thingsConf->getListOfSupportedConfigurationUnits();
-    }
-
-    OCStackResult ThingsManager::doBootstrap(ConfigurationCallback callback)
-    {
-        return g_thingsConf->doBootstrap(callback);
-    }
-
-    OCStackResult ThingsManager::reboot(std::shared_ptr< OCResource > resource,
-            ConfigurationCallback callback)
-    {
-        return g_thingsDiag->reboot(resource, callback);
-    }
-    OCStackResult ThingsManager::factoryReset(std::shared_ptr< OCResource > resource,
-            ConfigurationCallback callback)
-    {
-        return g_thingsDiag->factoryReset(resource, callback);
-    }
-
-    std::string ThingsManager::getStringFromActionSet(const ActionSet *newActionSet)
-    {
-        return g_groupManager->getStringFromActionSet(newActionSet);
-    }
-    ActionSet* ThingsManager::getActionSetfromString(std::string desc)
-    {
-        return g_groupManager->getActionSetfromString(desc);
-    }
-    OCStackResult ThingsManager::addActionSet(std::shared_ptr< OCResource > resource,
-            const ActionSet* newActionSet, PutCallback cb)
-    {
-        return g_groupManager->addActionSet(resource, newActionSet, cb);
-    }
-    OCStackResult ThingsManager::executeActionSet(std::shared_ptr< OCResource > resource,
-            std::string actionsetName, PostCallback cb)
-    {
-        return g_groupManager->executeActionSet(resource, actionsetName, cb);
-    }
-    OCStackResult ThingsManager::executeActionSet(std::shared_ptr< OCResource > resource,
-                    std::string actionsetName, long int delay, PostCallback cb)
-    {
-        return g_groupManager->executeActionSet(resource, actionsetName, delay, cb);
-    }
-    OCStackResult ThingsManager::cancelActionSet(std::shared_ptr< OCResource > resource,
-                    std::string actionsetName, PostCallback cb)
-    {
-        return g_groupManager->cancelActionSet(resource, actionsetName, cb);
-    }
-    OCStackResult ThingsManager::getActionSet(std::shared_ptr< OCResource > resource,
-            std::string actionsetName, GetCallback cb)
-    {
-        return g_groupManager->getActionSet(resource, actionsetName, cb);
-    }
-    OCStackResult ThingsManager::deleteActionSet(std::shared_ptr< OCResource > resource,
-            std::string actionsetName, PostCallback cb)
-    {
-        return g_groupManager->deleteActionSet(resource, actionsetName, cb);
-    }
-}