Renaming of BundleResource APIs
authorMarkus Jung <markus.jung@samsung.com>
Wed, 23 Sep 2015 05:53:36 +0000 (14:53 +0900)
committerMadan Lanka <lanka.madan@samsung.com>
Wed, 23 Sep 2015 07:00:21 +0000 (07:00 +0000)
Renamed the BundleResource APIs from simple setAttribute and getAttribute to
handleSetAttributeRequest and handleGetAttributeRequest. The maintainer
of the primitive services prefers these names in order to avoid
confusion with other resource encapsulation APIs.
The plain setters and getters are just for basic data structure manipulation and
do not handle any bundle resource specific logic any more.

Change-Id: Ie8f486269694ca7ee2a44f2e2390cdb2b27ba45b
Signed-off-by: Markus Jung <markus.jung@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/2975
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
14 files changed:
service/resource-encapsulation/src/resourceContainer/bundle-api/include/BundleResource.h
service/resource-encapsulation/src/resourceContainer/bundle-api/include/ProtocolBridgeResource.h
service/resource-encapsulation/src/resourceContainer/bundle-api/include/SoftSensorResource.h
service/resource-encapsulation/src/resourceContainer/examples/BMISensorBundle/include/BMISensorResource.h
service/resource-encapsulation/src/resourceContainer/examples/BMISensorBundle/src/BMISensorResource.cpp
service/resource-encapsulation/src/resourceContainer/examples/DiscomfortIndexSensorBundle/include/DiscomfortIndexSensorResource.h
service/resource-encapsulation/src/resourceContainer/examples/DiscomfortIndexSensorBundle/src/DiscomfortIndexSensorResource.cpp
service/resource-encapsulation/src/resourceContainer/examples/HueSampleBundle/include/HueLight.h
service/resource-encapsulation/src/resourceContainer/examples/HueSampleBundle/src/HueLight.cpp
service/resource-encapsulation/src/resourceContainer/src/BundleResource.cpp
service/resource-encapsulation/src/resourceContainer/src/ProtocolBridgeResource.cpp
service/resource-encapsulation/src/resourceContainer/src/ResourceContainerImpl.cpp
service/resource-encapsulation/src/resourceContainer/src/SoftSensorResource.cpp
service/resource-encapsulation/src/resourceContainer/unittests/TestBundle/include/TestBundleActivator.h

index 339000b..82fdbed 100644 (file)
@@ -69,9 +69,11 @@ namespace OIC
                 virtual void initAttributes() = 0;
 
                 /**
-                * Register notification receiver(resource container) to notify for the changes of attributes
+                * Register notification receiver(resource container) to notify for the
+                * changes of attributes
                 *
-                * @param pNotiReceiver Notification Receiver to get notification from bundle resource
+                * @param pNotiReceiver Notification Receiver to get notification from
+                * bundle resource
                 *
                 * @return void
                 */
@@ -82,7 +84,7 @@ namespace OIC
                 *
                 * @return Attributes of the resource
                 */
-                virtual RCSResourceAttributes &getAttributes();
+                RCSResourceAttributes &getAttributes();
 
                 /**
                 * Set attributes of the resource
@@ -91,7 +93,7 @@ namespace OIC
                 *
                 * @return void
                 */
-                virtual void setAttributes(RCSResourceAttributes &attrs);
+                void setAttributes(RCSResourceAttributes &attrs);
 
                 /**
                 * Execute the logic of bundle to get the value of attribute
@@ -100,23 +102,111 @@ namespace OIC
                 *
                 * @return Value of the attribute
                 */
-                virtual RCSResourceAttributes::Value getAttribute(const std::string &key);
+                RCSResourceAttributes::Value getAttribute(const std::string &key);
 
                 /**
-                * Execute the logic of bundle to set the value of attribute
+                * Sets the value of an attribute
                 *
                 * @param key Name of attribute to set
                 *
                 * @param value Value of attribute to set
                 *
+                * @param notify Flag to indicate if OIC clients should be notified about an update
+                *
                 * @return void
                 */
-                virtual void setAttribute(std::string key, RCSResourceAttributes::Value &&value);
+                void setAttribute(const std::string &key, RCSResourceAttributes::Value &&value,
+                        bool notify);
+
+                /**
+                   * Sets the value of an attribute
+                   *
+                   * @param key Name of attribute to set
+                   *
+                   * @param value Value of attribute to set
+                   *
+                   * @return void
+                   */
+                void setAttribute(const std::string &key, RCSResourceAttributes::Value &&value);
+
+                /**
+                  * This function should be implemented by the according bundle resource
+                  * and execute the according business logic (e.g., light switch or sensor resource)
+                  * and write either on soft sensor values or external bridged devices.
+                  *
+                  * The call of this method could for example trigger a HTTP PUT request on
+                  * an external APIs. This method is responsible to update the resource internal
+                  * data and call the setAttribute method.
+                  *
+                  * The implementor of the function can decide weather to notify OIC clients
+                  * about the changed state or not.
+                  *
+                  * @param key Name of attribute to set
+                  *
+                  * @param attrs Attributes to set
+                  *
+                  * @return void
+                  */
+                virtual void handleSetAttributesRequest(RCSResourceAttributes &attrs);
+
+                /**
+                  * This function should be implemented by the according bundle resource
+                  * and execute the according business logic (e.g., light switch or sensor resource)
+                  * and write either on soft sensor values or external bridged devices.
+                  *
+                  * The call of this method could for example trigger a HTTP PUT request on
+                  * an external APIs. This method is responsible to update the resource internal
+                  * data and call the setAttribute method.
+                  *
+                  * The implementor of the function can decide weather to notify OIC clients
+                  * about the changed state or not.
+                  *
+                  * @param key Name of attribute to set
+                  *
+                  * @param value Value of attribute to set
+                  *
+                  * @return void
+                  */
+                virtual void handleSetAttributeRequest(const std::string &key,
+                        RCSResourceAttributes::Value &&value);
+
+                /**
+                  * This function should be implemented by the according bundle resource
+                  * and execute the according business logic (e.g., light switch or sensor resource)
+                  * to retrieve a sensor value. If a new sensor value is retrieved, the
+                  * setAttribute data should be called to update the value.
+                  * The implementor of the function can decide weather to notify OIC clients
+                  * about the changed state or not.
+                  *
+                  * @param key Name of attribute to get
+                  *
+                  *
+                  * @return Value of the attribute
+                  */
+                virtual RCSResourceAttributes::Value handleGetAttributeRequest(
+                        const std::string &key);
+
+
+                /**
+                  * This function should be implemented by the according bundle resource
+                  * and execute the according business logic (e.g., light switch or sensor resource)
+                  * to retrieve a sensor value. If a new sensor value is retrieved, the
+                  * setAttribute data should be called to update the value.
+                  * The implementor of the function can decide weather to notify OIC clients
+                  * about the changed state or not.
+                  *
+                  * @param key Name of attribute to get
+                  *
+                  *
+                  * @return All attributes
+                  */
+                virtual RCSResourceAttributes& handleGetAttributesRequest();
 
             public:
                 std::string m_bundleId;
                 std::string m_name, m_uri, m_resourceType, m_address;
-                std::map< std::string, std::vector< std::map< std::string, std::string > > > m_mapResourceProperty;
+                std::map< std::string,
+                    std::vector< std::map< std::string, std::string > > > m_mapResourceProperty;
 
             private:
                 NotificationReceiver *m_pNotiReceiver;
@@ -125,4 +215,4 @@ namespace OIC
     }
 }
 
-#endif
\ No newline at end of file
+#endif
index 2bd5645..9c441aa 100644 (file)
@@ -58,43 +58,78 @@ namespace OIC
                 virtual void initAttributes() = 0;
 
                 /**
-                * Return all attributes of the resource
-                *
-                * @return Attributes of the resource
-                */
-                virtual RCSResourceAttributes &getAttributes();
+                  * This function should be implemented by the according bundle resource
+                  * and execute the according business logic (e.g., light switch or sensor resource)
+                  * and write either on soft sensor values or external bridged devices.
+                  *
+                  * The call of this method could for example trigger a HTTP PUT request on
+                  * an external APIs. This method is responsible to update the resource internal
+                  * data and call the setAttribute method.
+                  *
+                  * The implementor of the function can decide weather to notify OIC clients
+                  * about the changed state or not.
+                  *
+                  * @param key Name of attribute to set
+                  *
+                  * @param attrs Attributes to set
+                  *
+                  * @return void
+                  */
+                virtual void handleSetAttributesRequest(RCSResourceAttributes &attrs) = 0;
 
                 /**
-                * Set attributes of the resource
-                *
-                * @param attrs Attributes to set
-                *
-                * @return void
-                */
-                virtual void setAttributes(RCSResourceAttributes &attrs);
+                  * This function should be implemented by the according bundle resource
+                  * and execute the according business logic (e.g., light switch or sensor resource)
+                  * and write either on soft sensor values or external bridged devices.
+                  *
+                  * The call of this method could for example trigger a HTTP PUT request on
+                  * an external APIs. This method is responsible to update the resource internal
+                  * data and call the setAttribute method.
+                  *
+                  * The implementor of the function can decide weather to notify OIC clients
+                  * about the changed state or not.
+                  *
+                  * @param key Name of attribute to set
+                  *
+                  * @param value Value of attribute to set
+                  *
+                  * @return void
+                  */
+                virtual void handleSetAttributeRequest(const std::string &key,
+                        RCSResourceAttributes::Value &&value) = 0;
 
                 /**
-                * Execute the logic of bundle to get the value of attribute
-                *
-                * @param key Key of attribute to get
-                *
-                * @return Value of the attribute
-                */
-                virtual RCSResourceAttributes::Value getAttribute(const std::string &key) = 0;
+                  * This function should be implemented by the according bundle resource
+                  * and execute the according business logic (e.g., light switch or sensor resource)
+                  * to retrieve a sensor value. If a new sensor value is retrieved, the
+                  * setAttribute data should be called to update the value.
+                  * The implementor of the function can decide weather to notify OIC clients
+                  * about the changed state or not.
+                  *
+                  * @param key Name of attribute to get
+                  *
+                  *
+                  * @return Attribute value
+                  */
+                virtual RCSResourceAttributes::Value handleGetAttributeRequest(
+                        const std::string &key) = 0;
 
                 /**
-                * Execute the logic of bundle to set the value of attribute
-                *
-                * @param key Name of attribute to set
-                *
-                * @param value Value of attribute to set
-                *
-                * @return void
-                */
-                virtual void setAttribute(std::string key,
-                                          RCSResourceAttributes::Value &&value) = 0;
+                  * This function should be implemented by the according bundle resource
+                  * and execute the according business logic (e.g., light switch or sensor resource)
+                  * to retrieve a sensor value. If a new sensor value is retrieved, the
+                  * setAttribute data should be called to update the value.
+                  * The implementor of the function can decide weather to notify OIC clients
+                  * about the changed state or not.
+                  *
+                  * @param key Name of attribute to get
+                  *
+                  *
+                  * @return Value of all attributes
+                  */
+                virtual RCSResourceAttributes& handleGetAttributesRequest() = 0;
         };
     }
 }
 
-#endif
\ No newline at end of file
+#endif
index 4b1bd1d..6722383 100644 (file)
@@ -55,40 +55,76 @@ namespace OIC
                 virtual void initAttributes();
 
                 /**
-                * Return all attributes of the resource
-                *
-                * @return RCSResourceAttributes Attributes of the resource
-                */
-                virtual RCSResourceAttributes &getAttributes();
+                  * This function should be implemented by the according bundle resource
+                  * and execute the according business logic (e.g., light switch or sensor resource)
+                  * and write either on soft sensor values or external bridged devices.
+                  *
+                  * The call of this method could for example trigger a HTTP PUT request on
+                  * an external APIs. This method is responsible to update the resource internal
+                  * data and call the setAttribute method.
+                  *
+                  * The implementor of the function can decide weather to notify OIC clients
+                  * about the changed state or not.
+                  *
+                  * @param key Name of attribute to set
+                  *
+                  * @param attrs Attributes to set
+                  *
+                  * @return void
+                  */
+                virtual void handleSetAttributesRequest(RCSResourceAttributes &attrs) = 0;
 
                 /**
-                * Set attributes of the resource
-                *
-                * @param attrs Attributes to set
-                *
-                * @return void
-                */
-                virtual void setAttributes(RCSResourceAttributes &attrs);
+                  * This function should be implemented by the according bundle resource
+                  * and execute the according business logic (e.g., light switch or sensor resource)
+                  * and write either on soft sensor values or external bridged devices.
+                  *
+                  * The call of this method could for example trigger a HTTP PUT request on
+                  * an external APIs. This method is responsible to update the resource internal
+                  * data and call the setAttribute method.
+                  *
+                  * The implementor of the function can decide weather to notify OIC clients
+                  * about the changed state or not.
+                  *
+                  * @param key Name of attribute to set
+                  *
+                  * @param value Value of attribute to set
+                  *
+                  * @return void
+                  */
+                virtual void handleSetAttributeRequest(const std::string &key,
+                        RCSResourceAttributes::Value &&value) = 0;
 
                 /**
-                * Execute the logic of bundle to get the value of attribute
-                *
-                * @param key Key of attribute to get
-                *
-                * @return Value of the attribute
-                */
-                virtual RCSResourceAttributes::Value getAttribute(const std::string &key) = 0;
+                  * This function should be implemented by the according bundle resource
+                  * and execute the according business logic (e.g., light switch or sensor resource)
+                  * to retrieve a sensor value. If a new sensor value is retrieved, the
+                  * setAttribute data should be called to update the value.
+                  * The implementor of the function can decide weather to notify OIC clients
+                  * about the changed state or not.
+                  *
+                  * @param key Name of attribute to get
+                  *
+                  *
+                  * @return Attribute value
+                  */
+                virtual RCSResourceAttributes::Value handleGetAttributeRequest(
+                        const std::string &key) = 0;
 
                 /**
-                * Execute the logic of bundle to set the value of attribute
-                *
-                * @param key Name of attribute to set
-                *
-                * @param value Value of attribute to set
-                *
-                * @return void
-                */
-                virtual void setAttribute(std::string key, RCSResourceAttributes::Value &&value) = 0;
+                  * This function should be implemented by the according bundle resource
+                  * and execute the according business logic (e.g., light switch or sensor resource)
+                  * to retrieve a sensor value. If a new sensor value is retrieved, the
+                  * setAttribute data should be called to update the value.
+                  * The implementor of the function can decide weather to notify OIC clients
+                  * about the changed state or not.
+                  *
+                  * @param key Name of attribute to get
+                  *
+                  *
+                  * @return Value of all attributes
+                  */
+                virtual RCSResourceAttributes& handleGetAttributesRequest() = 0;
 
                 /**
                 * SoftSensor logic. Has to be provided by the soft sensor developer.
@@ -99,7 +135,7 @@ namespace OIC
                 virtual void executeLogic() = 0;
 
                 virtual void onUpdatedInputResource(const std::string attributeName,
-                                                    std::vector<RCSResourceAttributes::Value> values) = 0;
+                                             std::vector<RCSResourceAttributes::Value> values) = 0;
 
 
             public:
@@ -108,4 +144,4 @@ namespace OIC
     }
 }
 
-#endif
\ No newline at end of file
+#endif
index f350b9c..553a489 100644 (file)
@@ -33,8 +33,14 @@ class BMISensorResource : public SoftSensorResource
         BMISensorResource();
         ~BMISensorResource();
 
-        virtual RCSResourceAttributes::Value getAttribute(const std::string &key);
-        virtual void setAttribute(std::string key, RCSResourceAttributes::Value &&value);
+        virtual RCSResourceAttributes::Value handleGetAttributeRequest(const std::string &key);
+
+        virtual void handleSetAttributeRequest(const std::string &key,
+                RCSResourceAttributes::Value &&value);
+
+        virtual RCSResourceAttributes& handleGetAttributesRequest();
+
+        virtual void handleSetAttributesRequest(RCSResourceAttributes &attrs);
 
         virtual void executeLogic();
 
index 1f1cd1b..206a50b 100644 (file)
@@ -31,17 +31,29 @@ BMISensorResource::~BMISensorResource()
     delete m_pBMISensor;
 }
 
-RCSResourceAttributes::Value BMISensorResource::getAttribute(const std::string &key)
+RCSResourceAttributes::Value BMISensorResource::handleGetAttributeRequest(const std::string &key)
 {
     return BundleResource::getAttribute(key);
 }
 
-void BMISensorResource::setAttribute(std::string key,
+void BMISensorResource::handleSetAttributeRequest(const std::string &key,
                                      RCSResourceAttributes::Value &&value)
 {
     BundleResource::setAttribute(key, std::move(value));
 }
 
+RCSResourceAttributes& BMISensorResource::handleGetAttributesRequest()
+{
+    return BundleResource::getAttributes();
+}
+
+void BMISensorResource::handleSetAttributesRequest(
+                                     RCSResourceAttributes &value)
+{
+    BundleResource::setAttributes(value);
+}
+
+
 void BMISensorResource::executeLogic()
 {
     std::string strBMIResult;
@@ -63,4 +75,4 @@ void BMISensorResource::onUpdatedInputResource(const std::string attributeName,
         m_mapInputData.insert(std::make_pair("height", values.back().toString()));
 
     executeLogic();
-}
\ No newline at end of file
+}
index b784e20..65469f8 100644 (file)
@@ -33,8 +33,14 @@ class DiscomfortIndexSensorResource : public SoftSensorResource
         DiscomfortIndexSensorResource();
         ~DiscomfortIndexSensorResource();
 
-        virtual void setAttribute(std::string key, RCSResourceAttributes::Value &&value);
-        virtual RCSResourceAttributes::Value getAttribute(const std::string &key);
+        virtual RCSResourceAttributes::Value handleGetAttributeRequest(const std::string &key);
+
+        virtual void handleSetAttributeRequest(const std::string &key,
+                RCSResourceAttributes::Value &&value);
+
+        virtual RCSResourceAttributes& handleGetAttributesRequest();
+
+        virtual void handleSetAttributesRequest(RCSResourceAttributes &attrs);
 
         virtual void executeLogic();
 
index 01740be..b5337f6 100644 (file)
@@ -34,17 +34,28 @@ DiscomfortIndexSensorResource::~DiscomfortIndexSensorResource()
     delete m_pDiscomfortIndexSensor;
 }
 
-void DiscomfortIndexSensorResource::setAttribute(std::string key,
-        RCSResourceAttributes::Value &&value)
+RCSResourceAttributes::Value DiscomfortIndexSensorResource::handleGetAttributeRequest(
+        const std::string &key)
+{
+    return BundleResource::getAttribute(key);
+}
+
+void DiscomfortIndexSensorResource::handleSetAttributeRequest(const std::string &key,
+                                     RCSResourceAttributes::Value &&value)
 {
     BundleResource::setAttribute(key, std::move(value));
 }
 
-RCSResourceAttributes::Value DiscomfortIndexSensorResource::getAttribute(const std::string &key)
+RCSResourceAttributes& DiscomfortIndexSensorResource::handleGetAttributesRequest()
 {
-    return BundleResource::getAttribute(key);
+    return BundleResource::getAttributes();
 }
 
+void DiscomfortIndexSensorResource::handleSetAttributesRequest(
+                                     RCSResourceAttributes &value)
+{
+    BundleResource::setAttributes(value);
+}
 void DiscomfortIndexSensorResource::executeLogic()
 {
     std::string strDiscomfortIndex;
@@ -90,4 +101,4 @@ void DiscomfortIndexSensorResource::onUpdatedInputResource(const std::string att
     {
         executeLogic();
     }
-}
\ No newline at end of file
+}
index e20b3d8..a433098 100644 (file)
@@ -40,8 +40,15 @@ namespace OIC
 
                 virtual void initAttributes();
 
-                virtual void setAttribute(std::string key, RCSResourceAttributes::Value &&);
-                virtual RCSResourceAttributes::Value getAttribute(const std::string &key);
+                virtual void handleSetAttributesRequest(RCSResourceAttributes &attrs);
+
+                virtual void handleSetAttributeRequest(const std::string &key,
+                        RCSResourceAttributes::Value &&value);
+
+                virtual RCSResourceAttributes::Value handleGetAttributeRequest(
+                        const std::string &key);
+
+                virtual RCSResourceAttributes& handleGetAttributesRequest();
 
             private:
                 std::string m_address;
index 68296cc..4cb223a 100644 (file)
@@ -50,13 +50,21 @@ void HueLight::initAttributes()
     BundleResource::setAttribute("color", 0);
 }
 
-RCSResourceAttributes::Value HueLight::getAttribute(const std::string &key)
+RCSResourceAttributes::Value HueLight::handleGetAttributeRequest(const std::string &key)
 {
     cout << "HueLight::getAttribute called for " << key <<  " called" << endl;
+    // TODO read from HueLight and update attribute data
     return BundleResource::getAttribute(key);
 }
 
-void HueLight::setAttribute(std::string attributeName, RCSResourceAttributes::Value &&value)
+RCSResourceAttributes& HueLight::handleGetAttributesRequest()
+{
+    cout << "HueLight::getAttributes" << endl;
+    // TODO read from HueLight and update attribute data
+    return BundleResource::getAttributes();
+}
+
+void HueLight::handleSetAttributeRequest(const std::string &attributeName, RCSResourceAttributes::Value &&value)
 {
     cout << "HueLight::setAttribute setting " << attributeName << " to " << value.toString() <<
          std::endl;
@@ -81,3 +89,12 @@ void HueLight::setAttribute(std::string attributeName, RCSResourceAttributes::Va
     BundleResource::setAttribute(attributeName, std::move(value));
 }
 
+void HueLight::handleSetAttributesRequest(RCSResourceAttributes &value)
+{
+    cout << "HueLight::setAttributes "<< std::endl;
+
+    // TODO construct single write
+
+    BundleResource::setAttributes(value);
+}
+
index de16153..0344e68 100644 (file)
@@ -68,22 +68,47 @@ namespace OIC
             }
         }
 
-        void BundleResource::setAttribute(std::string key, RCSResourceAttributes::Value &&value)
+        void BundleResource::setAttribute(const std::string &key,
+                RCSResourceAttributes::Value &&value, bool notify)
         {
             OC_LOG_V(INFO, CONTAINER_TAG, "set attribute \(%s)'", std::string(key + "\', with " +
                      value.toString()).c_str());
 
             m_resourceAttributes[key] = value;
 
-            if (m_pNotiReceiver)
+            if (notify && m_pNotiReceiver)
                 m_pNotiReceiver->onNotificationReceived(m_uri);
         }
 
+        void BundleResource::setAttribute(const std::string &key, RCSResourceAttributes::Value &&value){
+            setAttribute(key, std::move(value), true);
+        }
+
         RCSResourceAttributes::Value BundleResource::getAttribute(const std::string &key)
         {
             OC_LOG_V(INFO, CONTAINER_TAG, "get attribute \'(%s)" , std::string(key + "\'").c_str());
 
             return m_resourceAttributes.at(key);
         }
+
+        RCSResourceAttributes::Value BundleResource::handleGetAttributeRequest(const std::string &key)
+        {
+            return BundleResource::getAttribute(key);
+        }
+
+        void BundleResource::handleSetAttributeRequest(const std::string &key, RCSResourceAttributes::Value &&value)
+        {
+            BundleResource::setAttribute(key, std::move(value));
+        }
+
+        RCSResourceAttributes& BundleResource::handleGetAttributesRequest()
+        {
+            return BundleResource::getAttributes();
+        }
+
+        void BundleResource::handleSetAttributesRequest(RCSResourceAttributes &value)
+        {
+            BundleResource::setAttributes(value);
+        }
     }
-}
\ No newline at end of file
+}
index c78a177..5820cef 100644 (file)
@@ -35,28 +35,6 @@ namespace OIC
         {
 
         }
-
-        RCSResourceAttributes &ProtocolBridgeResource::getAttributes()
-        {
-            // execute implemented logic to get attribute, and update bundle resource attribute data
-            RCSResourceAttributes attr;
-            for (std::string attrName : getAttributeNames())
-            {
-                attr[attrName] = getAttribute(attrName);
-            }
-            BundleResource::setAttributes(attr);
-
-            return BundleResource::getAttributes();
-        }
-
-        void ProtocolBridgeResource::setAttributes(RCSResourceAttributes &attrs)
-        {
-            // execute implemented logic to set attribute
-            for (RCSResourceAttributes::iterator it = attrs.begin(); it != attrs.end(); ++it)
-            {
-                setAttribute(it->key(), std::move(it->value()));
-            }
-        }
     }
 }
 
index 2fa3407..91c7db6 100644 (file)
@@ -395,7 +395,7 @@ namespace OIC
                             }
                         }
 
-                        m_mapResources[strResourceUri]->setAttributes(attr);
+                        m_mapResources[strResourceUri]->handleSetAttributesRequest(attr);
                     };
                     boost::thread setThread(setFunction);
                     setThread.timed_join(boost::posix_time::seconds(BUNDLE_SET_GET_WAIT_SEC));
index 6239e06..753dd69 100644 (file)
@@ -52,28 +52,6 @@ namespace OIC
                  itor != m_mapResourceProperty[SS_RESOURCE_OUTPUT].end(); itor++)
                 BundleResource::setAttribute((*itor)[SS_RESOURCE_OUTPUTNAME], nullptr);
         }
-
-        RCSResourceAttributes &SoftSensorResource::getAttributes()
-        {
-            // execute implemented logic to get attribute, and update bundle resource attribute data
-            RCSResourceAttributes attr;
-            for (std::string attrName : getAttributeNames())
-            {
-                attr[attrName] = getAttribute(attrName);
-            }
-            BundleResource::setAttributes(attr);
-
-            return BundleResource::getAttributes();
-        }
-
-        void SoftSensorResource::setAttributes(RCSResourceAttributes &attrs)
-        {
-            // execute implemented logic to set attribute
-            for (RCSResourceAttributes::iterator it = attrs.begin(); it != attrs.end(); ++it)
-            {
-                setAttribute(it->key(), std::move(it->value()));
-            }
-        }
     }
 }
 
index 5a2e254..69f3729 100644 (file)
@@ -51,6 +51,29 @@ class TestBundleResource : public BundleResource
 {
     public:
         void initAttributes() { };
+
+        RCSResourceAttributes::Value handleGetAttributeRequest(
+                const std::string &key)
+        {
+            return BundleResource::getAttribute(key);
+        }
+
+        void handleSetAttributeRequest(const std::string &key,
+                                             RCSResourceAttributes::Value &&value)
+        {
+            BundleResource::setAttribute(key, std::move(value));
+        }
+
+        RCSResourceAttributes& handleGetAttributesRequest()
+        {
+            return BundleResource::getAttributes();
+        }
+
+        void handleSetAttributesRequest(
+                                             RCSResourceAttributes &value)
+        {
+            BundleResource::setAttributes(value);
+        }
 };
 
 #endif /* TESTBUNDLE_H_ */