resource-container: add make it possible to specify OIC interface name
authorHauke Mehrtens <hauke.mehrtens@lantiq.com>
Wed, 11 Nov 2015 17:05:27 +0000 (18:05 +0100)
committerMadan Lanka <lanka.madan@samsung.com>
Tue, 24 Nov 2015 01:54:45 +0000 (01:54 +0000)
Without this the interface name of a bridged device is hard coded to
"oic.if.baseline" with this patch it is possible to change it to
something else if needed.

Change-Id: If593ed43c6deb1787f689ef1be928a0aee66bb24
Signed-off-by: Hauke Mehrtens <hauke.mehrtens@lantiq.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/4149
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Markus Jung <markus.jung85@gmail.com>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
service/resource-container/bundle-api/include/BundleResource.h
service/resource-container/src/ResourceContainerImpl.cpp
service/resource-container/src/ResourceContainerImpl.h
service/resource-container/unittests/ResourceContainerTest.cpp

index 80414c5..8b3dbe5 100644 (file)
@@ -174,7 +174,7 @@ namespace OIC
 
             public:
                 std::string m_bundleId;
-                std::string m_name, m_uri, m_resourceType, m_address;
+                std::string m_name, m_uri, m_resourceType, m_interface, m_address;
                 std::map< std::string,
                     std::vector< std::map< std::string, std::string > > > m_mapResourceProperty;
 
index b75f7cc..9607622 100644 (file)
@@ -262,6 +262,7 @@ namespace OIC
         {
             string strUri = resource->m_uri;
             string strResourceType = resource->m_resourceType;
+            string strInterface = resource->m_interface;
             RCSResourceObject::Ptr server = nullptr;
             int ret = EINVAL;
 
@@ -271,7 +272,11 @@ namespace OIC
             registrationLock.lock();
             if (m_mapResources.find(strUri) == m_mapResources.end())
             {
-                server = buildResourceObject(strUri, strResourceType);
+                if (strInterface.empty()) {
+                    strInterface = "oic.if.baseline";
+                }
+
+                server = buildResourceObject(strUri, strResourceType, strInterface);
 
                 if (server != nullptr)
                 {
@@ -431,10 +436,10 @@ namespace OIC
         }
 
         RCSResourceObject::Ptr ResourceContainerImpl::buildResourceObject(const std::string &strUri,
-                const std::string &strResourceType)
+                const std::string &strResourceType, const std::string &strInterface)
         {
             return RCSResourceObject::Builder(strUri, strResourceType,
-                                              "oic.if.baseline").setObservable(
+                                              strInterface).setObservable(
                        true).setDiscoverable(true).build();
         }
 
index 6ae4a62..f798fac 100644 (file)
@@ -81,7 +81,7 @@ namespace OIC
 
                 static ResourceContainerImpl *getImplInstance();
                 static RCSResourceObject::Ptr buildResourceObject(const std::string &strUri,
-                        const std::string &strResourceType);
+                        const std::string &strResourceType, const std::string &strInterface);
 
                 void startBundle(const std::string &bundleId);
                 void stopBundle(const std::string &bundleId);
index 9cc1127..98a146b 100644 (file)
@@ -317,7 +317,7 @@ TEST_F(ResourceContainerBundleAPITest, ResourceServerCreatedWhenRegisterResource
     m_pBundleResource->m_resourceType = "container.test";
 
     mocks.ExpectCallFunc(ResourceContainerImpl::buildResourceObject).With(m_pBundleResource->m_uri,
-            m_pBundleResource->m_resourceType).Return(nullptr);
+            m_pBundleResource->m_resourceType, m_pBundleResource->m_interface).Return(nullptr);
 
     m_pResourceContainer->registerResource(m_pBundleResource);
 }