Replaced Watching word to Monitoring in ResourceClient
authorJay Sharma <jay.sharma@samsung.com>
Mon, 20 Jul 2015 04:57:05 +0000 (10:27 +0530)
committerUze Choi <uzchoi@samsung.com>
Mon, 20 Jul 2015 07:15:39 +0000 (07:15 +0000)
- updated ResourceClient and Sample
- updated Notification manager (HostingObject.cpp)

Change-Id: Iee01cbfabf175d731265bb161cfb3a1aa921302a
Signed-off-by: Jay Sharma <jay.sharma@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1747
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
service/notification-manager/NotificationManager/src/HostingObject.cpp
service/resource-manipulation/examples/linux/SampleResourceClient.cpp
service/resource-manipulation/include/ResourceClient.h
service/resource-manipulation/src/ResourceClient.cpp

index 8c9a84f..a8c030c 100644 (file)
@@ -29,7 +29,7 @@ namespace Service
 
 HostingObject::HostingObject()
 : remoteObject(nullptr), mirroredServer(nullptr),
-  remoteState(ResourceState::NOT_WATCHING),
+  remoteState(ResourceState::NOT_MONITORING),
   pStateChangedCB(nullptr), pDataUpdateCB(nullptr),
   pDestroyCB(nullptr), pSetRequestHandler(nullptr)
 {
@@ -106,7 +106,7 @@ void HostingObject::stateChangedCB(ResourceState state, RemoteObjectPtr rObject)
                         e.what());
             }
         }
-        if(rObject->isWatching() == true)
+        if(rObject->isMonitoring() == true)
         {
             try
             {
index 53ed6ef..35fd950 100644 (file)
@@ -29,14 +29,14 @@ void OnResourceDiscovered(std::shared_ptr<RemoteResourceObject> foundResource)
     isReady = true;
 }
 
-//callback for StartWatching()
+//callback for StartMonitoring()
 void OnResourceStateChanged(ResourceState resourceState)
 {
 
     cout << "\nOnResourceStateChanged callback" << std::endl;
 
-    if (resourceState == ResourceState::NOT_WATCHING)
-        cout << "State changed to : NOT_WATCHING" << std::endl;
+    if (resourceState == ResourceState::NOT_MONITORING)
+        cout << "State changed to : NOT_MONITORING" << std::endl;
     else if (resourceState == ResourceState::ALIVE)
         cout << "State changed to : ALIVE" << std::endl;
     else if (resourceState == ResourceState::REQUESTED)
index 1b7f1ef..e754543 100644 (file)
@@ -31,7 +31,6 @@
 
 #include<vector>
 #include "ResourceAttributes.h"
-#include "PrimitiveResource.h"
 
 namespace OIC
 {
@@ -56,7 +55,7 @@ namespace OIC
         */
         enum class ResourceState
         {
-            NOT_WATCHING,
+            NOT_MONITORING,
             ALIVE, REQUESTED,
             LOST_SIGNAL,
             DESTROYED
@@ -67,6 +66,7 @@ namespace OIC
         */
         class RCSException;
         class RemoteResourceObject;
+        class PrimitiveResource;
 
         /**
          * @class  BadRequestException
@@ -112,7 +112,7 @@ namespace OIC
                 RemoteResourceObject(std::shared_ptr<PrimitiveResource>  pResource);
 
                 /**
-                 *  Typedef for callback of startWatching API
+                 *  Typedef for callback of startMonitoring API
                  *
                  * @see ResourceState
                  */
@@ -143,13 +143,13 @@ namespace OIC
                 RemoteAttributesSetCallback;
 
                 /**
-                 * Check current watching state.
+                 * Check monitoring state.
                  *
-                 * @details This API checks the current watching state for the resource of interest.
+                 * @details This API checks the current monitoring state for the resource of interest.
                  *
-                 * @return bool - true if Watching otherwise false.
+                 * @return bool - true if monitoring the resource otherwise false.
                  */
-                bool isWatching() const;
+                bool isMonitoring() const;
 
                 /**
                  * Check current Caching state.
@@ -171,7 +171,7 @@ namespace OIC
                 bool isObservable() const;
 
                 /**
-                 * Start watching the resource.
+                 * Start Monitoring the resource.
                  *
                  * @details This API will start monitoring the resource of interest.
                  *               Once this API is called it will check whether the particular resource
@@ -376,9 +376,9 @@ namespace OIC
                 typedef unsigned int BrokerID;
 
                 /**
-                 *  Flag to check watching state.
+                 *  Flag to check monitoring state.
                  */
-                bool m_watchingFlag;
+                bool m_monitoringFlag;
 
                 /**
                  *  Flag to check caching state.
index f181a1f..14b740d 100644 (file)
@@ -49,11 +49,14 @@ namespace
         {
             return ResourceState::DESTROYED;
         }
-
+        else if (state == BROKER_STATE::NONE)
+        {
+            return ResourceState::NOT_MONITORING;
+        }
         OC_LOG(ERROR, CLIENT_W_TAG, "getResourceStateFromBrokerState ERROR");
 
         //Default return value
-        return ResourceState::DESTROYED;
+        return ResourceState::NOT_MONITORING;
     }
 
     CacheState getCacheState(CACHE_STATE state)
@@ -166,12 +169,12 @@ namespace OIC
     {
 
         RemoteResourceObject:: RemoteResourceObject(std::shared_ptr<PrimitiveResource>  pResource) :
-            m_watchingFlag(false), m_cachingFlag(false),  m_observableFlag(pResource->isObservable()),
+            m_monitoringFlag(false), m_cachingFlag(false),  m_observableFlag(pResource->isObservable()),
             m_primitiveResource(pResource), m_cacheId(0), m_brokerId(0) {}
 
-        bool RemoteResourceObject::isWatching() const
+        bool RemoteResourceObject::isMonitoring() const
         {
-            return m_watchingFlag;
+            return m_monitoringFlag;
         }
 
         bool RemoteResourceObject::isCaching() const
@@ -181,10 +184,10 @@ namespace OIC
 
         void RemoteResourceObject::startMonitoring(ResourceStateChangedCallback cb)
         {
-            OC_LOG(DEBUG, CLIENT_W_TAG, "RemoteResourceObject::startWatching entry");
-            if (true == m_watchingFlag)
+            OC_LOG(DEBUG, CLIENT_W_TAG, "RemoteResourceObject::startMonitoring entry");
+            if (true == m_monitoringFlag)
             {
-                OC_LOG(DEBUG, CLIENT_W_TAG, "RemoteResourceObject::startWatching : Already started");
+                OC_LOG(DEBUG, CLIENT_W_TAG, "RemoteResourceObject::startMonitoring : Already started");
             }
             else
             {
@@ -193,7 +196,7 @@ namespace OIC
                     BrokerID brokerId =  ResourceBroker::getInstance()->hostResource(m_primitiveResource,
                                          std::bind(hostingCallback, std::placeholders::_1,
                                                    cb));
-                    m_watchingFlag = true;
+                    m_monitoringFlag = true;
                     m_brokerId = brokerId;
                 }
                 catch (std::exception &exception)
@@ -201,30 +204,30 @@ namespace OIC
                     throw InvalidParameterException {exception.what()};
                 }
             }
-            OC_LOG(DEBUG, CLIENT_W_TAG, "RemoteResourceObject::startWatching exit");
+            OC_LOG(DEBUG, CLIENT_W_TAG, "RemoteResourceObject::startMonitoring exit");
         }
 
         void RemoteResourceObject::stopMonitoring()
         {
-            OC_LOG(DEBUG, CLIENT_W_TAG, "RemoteResourceObject::stopWatching entry");
-            if (true == m_watchingFlag)
+            OC_LOG(DEBUG, CLIENT_W_TAG, "RemoteResourceObject::stopMonitoring entry");
+            if (true == m_monitoringFlag)
             {
                 try
                 {
                     ResourceBroker::getInstance()->cancelHostResource(m_brokerId);
-                    m_watchingFlag = false;
+                    m_monitoringFlag = false;
                 }
                 catch (std::exception &exception)
                 {
-                    OC_LOG(DEBUG, CLIENT_W_TAG, "RemoteResourceObject::stopWatching InvalidParameterException");
+                    OC_LOG(DEBUG, CLIENT_W_TAG, "RemoteResourceObject::stopMonitoring InvalidParameterException");
                 }
             }
             else
             {
-                OC_LOG(DEBUG, CLIENT_W_TAG, "RemoteResourceObject:: stopWatching : already terminated");
+                OC_LOG(DEBUG, CLIENT_W_TAG, "RemoteResourceObject:: stopMonitoring : already terminated");
             }
 
-            OC_LOG(DEBUG, CLIENT_W_TAG, "RemoteResourceObject::stopWatching exit");
+            OC_LOG(DEBUG, CLIENT_W_TAG, "RemoteResourceObject::stopMonitoring exit");
         }
 
         ResourceState RemoteResourceObject::getState() const