RE ServerBuilder always included "oic.if.baseline" interface.
authorjaesick.shin <jaesick.shin@samsung.com>
Tue, 8 Mar 2016 03:09:48 +0000 (12:09 +0900)
committerUze Choi <uzchoi@samsung.com>
Thu, 10 Mar 2016 01:33:45 +0000 (01:33 +0000)
If User don't setting "oic.if.baseline" interface.
but, RE ServerBuilder always support "oic.if.baseline" interface.

setDefaultInterface API(Modified comment of header) and Modified Initialize of Builder Constructor
If it is not called, the interface passed to the constructor is the default.

Added, Duplicate check the resource property of interface and resourcetype.

Change-Id: Ie25f1135cc7c99fbf5fe1b04f3121b9e2707be21
Signed-off-by: jaesick.shin <jaesick.shin@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/5529
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
service/resource-encapsulation/include/RCSResourceObject.h
service/resource-encapsulation/src/serverBuilder/src/RCSResourceObject.cpp

index 00644cf..8a58b15 100644 (file)
@@ -162,7 +162,7 @@ namespace OIC
 
                 /**
                  * Sets the default interface.
-                 * If the default interface is not sepcified, "oic.if.baseline"
+                 * If it is not called, the interface passed to the constructor is the default.
                  *
                  * @param interface default interface name
                  *
index db834f5..4d37f6f 100644 (file)
@@ -121,6 +121,16 @@ namespace
         return {};
     }
 
+    void insertValue(std::vector<std::string>& container, std::string value)
+    {
+        if (value.empty()) return;
+
+        if (std::find(container.begin(), container.end(), value) == container.end())
+        {
+            container.push_back(std::move(value));
+        }
+    }
+
 } // unnamed namespace
 
 namespace OIC
@@ -132,22 +142,29 @@ namespace OIC
                 std::string interface) :
                 m_uri{ std::move(uri) },
                 m_types{ std::move(type) },
-                m_interfaces{ std::move(interface) },
-                m_defaultInterface { BASELINE_INTERFACE },
+                m_interfaces{ },
+                m_defaultInterface{ interface },
                 m_properties{ OC_DISCOVERABLE | OC_OBSERVABLE },
                 m_resourceAttributes{ }
         {
+            addInterface(interface);
+            addInterface(BASELINE_INTERFACE);
+
+            if (m_defaultInterface.empty())
+            {
+                m_defaultInterface = BASELINE_INTERFACE;
+            }
         }
 
         RCSResourceObject::Builder& RCSResourceObject::Builder::addInterface(std::string interface)
         {
-            m_interfaces.push_back(std::move(interface));
+            insertValue(m_interfaces, std::move(interface));
             return *this;
         }
 
         RCSResourceObject::Builder& RCSResourceObject::Builder::addType(std::string type)
         {
-            m_types.push_back(std::move(type));
+            insertValue(m_types, std::move(type));
             return *this;
         }