resource-container: add method to manually send a notification
authorHauke Mehrtens <hauke.mehrtens@lantiq.com>
Fri, 13 Nov 2015 12:58:49 +0000 (13:58 +0100)
committerMadan Lanka <lanka.madan@samsung.com>
Wed, 18 Nov 2015 06:22:00 +0000 (06:22 +0000)
When I am setting more than one attribute at a time I only want to send one
notification after all the attributes have been set. This change makes it
possible to send the notification at the end.

Change-Id: I8a4825edab97b92041a67a8cdf57f9a6fd832f3b
Signed-off-by: Hauke Mehrtens <hauke.mehrtens@lantiq.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/4207
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/BundleResource.cpp

index 5315edda6c4cf68cf49b32dc174ea4829edab4f9..80414c5f6e9f58d0bdd87755d9fea447554a0bb5 100644 (file)
@@ -131,6 +131,16 @@ namespace OIC
                 */
                 void setAttribute(const std::string &key, RCSResourceAttributes::Value &&value);
 
+                /**
+                * Sends a notification to all observers.
+                *
+                * Calling this is not needed when setAttribute() was called
+                * with notify == true.
+                *
+                * @return void
+                */
+                void sendNotification();
+
                 /**
                 * This function should be implemented by the according bundle resource
                 * and execute the according business logic (e.g., light switch or sensor resource)
index 93c255febc993da747769d069ad0312b859a7aea..cb8d437f77a9baccd3a5f85e0be68cdc937f80f8 100644 (file)
@@ -79,8 +79,7 @@ namespace OIC
 
             m_resourceAttributes[key] = value;
 
-            if (notify && m_pNotiReceiver)
-                m_pNotiReceiver->onNotificationReceived(m_uri);
+            sendNotification();
         }
 
         void BundleResource::setAttribute(const std::string &key, RCSResourceAttributes::Value &&value)
@@ -94,5 +93,11 @@ namespace OIC
 
             return m_resourceAttributes.at(key);
         }
+
+        void BundleResource::sendNotification()
+        {
+            if (m_pNotiReceiver)
+                m_pNotiReceiver->onNotificationReceived(m_uri);
+        }
     }
 }