From: jaesick.shin Date: Tue, 8 Mar 2016 03:09:48 +0000 (+0900) Subject: RE ServerBuilder always included "oic.if.baseline" interface. X-Git-Tag: 1.2.0+RC1~355^2^2~230 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=781512a0d2fa7f5592ef916d1c6eb561a02ae4bd;p=platform%2Fupstream%2Fiotivity.git RE ServerBuilder always included "oic.if.baseline" interface. 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 Reviewed-on: https://gerrit.iotivity.org/gerrit/5529 Tested-by: jenkins-iotivity Reviewed-by: Uze Choi (cherry picked from commit 6768956d2bdbf81f1180caf137e246d877ef1992) Reviewed-on: https://gerrit.iotivity.org/gerrit/5647 --- diff --git a/service/resource-encapsulation/include/RCSResourceObject.h b/service/resource-encapsulation/include/RCSResourceObject.h index 00644cf..8a58b15 100644 --- a/service/resource-encapsulation/include/RCSResourceObject.h +++ b/service/resource-encapsulation/include/RCSResourceObject.h @@ -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 * diff --git a/service/resource-encapsulation/src/serverBuilder/src/RCSResourceObject.cpp b/service/resource-encapsulation/src/serverBuilder/src/RCSResourceObject.cpp index db834f5..4d37f6f 100644 --- a/service/resource-encapsulation/src/serverBuilder/src/RCSResourceObject.cpp +++ b/service/resource-encapsulation/src/serverBuilder/src/RCSResourceObject.cpp @@ -121,6 +121,16 @@ namespace return {}; } + void insertValue(std::vector& 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; }