resource-manipulation: Update container bundle-api doxygen comments
authorMinji Park <minjii.park@samsung.com>
Wed, 22 Jul 2015 02:44:44 +0000 (11:44 +0900)
committerUze Choi <uzchoi@samsung.com>
Wed, 22 Jul 2015 06:48:22 +0000 (06:48 +0000)
- add bundle-api doxygen comments for updates regarding bundle resource attributes and dynamic configuration
- update bundles and bundle resources for applying resource attribute

Change-Id: Ic1389eb0c643ded2df313e1b1bfa2968743af525
Signed-off-by: Minji Park <minjii.park@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1806
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
13 files changed:
service/resource-manipulation/src/resourceContainer/bundle-api/include/BundleActivator.h
service/resource-manipulation/src/resourceContainer/bundle-api/include/BundleResource.h
service/resource-manipulation/src/resourceContainer/bundle-api/include/NotificationReceiver.h
service/resource-manipulation/src/resourceContainer/bundle-api/include/ProtocolBridgeConnector.h
service/resource-manipulation/src/resourceContainer/bundle-api/include/ProtocolBridgeResource.h
service/resource-manipulation/src/resourceContainer/bundle-api/include/ResourceContainerBundleAPI.h
service/resource-manipulation/src/resourceContainer/bundle-api/include/SoftSensorResource.h
service/resource-manipulation/src/resourceContainer/examples/HueSampleBundle/src/HueSampleBundleActivator.cpp
service/resource-manipulation/src/resourceContainer/examples/SoftSensorSampleBundle/include/DiscomfortIndexSensorResource.h
service/resource-manipulation/src/resourceContainer/examples/SoftSensorSampleBundle/src/DiscomfortIndexSensorResource.cpp
service/resource-manipulation/src/resourceContainer/examples/SoftSensorSampleBundle/src/SoftSensorBundleActivator.cpp
service/resource-manipulation/src/resourceContainer/src/ContainerSample.cpp
service/resource-manipulation/src/resourceContainer/src/ResourceContainerImpl.cpp

index 38d5cdc..5a802ad 100644 (file)
@@ -69,8 +69,22 @@ namespace OIC
                 */
                 virtual void deactivateBundle();
 
+                /**
+                * Create Bundle Resource instance and register the resource in the container
+                *
+                * @param resourceInfo - information to create bundle resource
+                *
+                * @return void
+                */
                 virtual void createResource(resourceInfo resourceInfo) = 0;
 
+                /**
+                * Destroy Bundle Resource instance and register the resource in the container
+                *
+                * @param pBundleResource - bundle resource to be destroyed
+                *
+                * @return void
+                */
                 virtual void destroyResource(BundleResource *pBundleResource) = 0;
         };
     }
index 93be008..96890db 100644 (file)
@@ -57,28 +57,6 @@ namespace OIC
                 virtual ~BundleResource();
 
                 /**
-                * Execute the logic of bundle to get the value of attribute
-                *
-                * @param attributeName - name of attribute to get
-                *
-                * @return string - return value of the attribute
-                *
-                * @todo use type variant mechanism
-                */
-                //virtual string getAttribute(string attributeName);
-
-                /**
-                * Execute the logic of bundle to set the value of attribute
-                *
-                * @param attributeName - name of attribute to set
-                *
-                * @param value - value of attribute to set
-                *
-                * @return void
-                */
-                //virtual void setAttribute(string attributeName, string value);
-
-                /**
                 * Return the list of attribute names of the resource
                 *
                 * @return std::list - return list of the attribute names
@@ -101,11 +79,32 @@ namespace OIC
                 */
                 void registerObserver(NotificationReceiver *pNotiReceiver);
 
-                virtual ResourceAttributes& getAttributes();
+                /**
+                * Return all attributes of the resource
+                *
+                * @return ResourceAttributes - attributes of the resource
+                */
+                virtual ResourceAttributes &getAttributes();
 
-                virtual void setAttribute(std::string key, ResourceAttributes::Value&&);
+                /**
+                * 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, ResourceAttributes::Value &&value);
 
-                virtual ResourceAttributes::Value getAttribute(const std::string& key);
+                /**
+                * Execute the logic of bundle to get the value of attribute
+                *
+                * @param key - key of attribute to get
+                *
+                * @return ResourceAttributes::Value - return value of the attribute
+                */
+                virtual ResourceAttributes::Value getAttribute(const std::string &key);
 
 
             public:
@@ -114,7 +113,6 @@ namespace OIC
                 map< string, vector< map< string, string > > > m_mapResourceProperty;
 
             private:
-                //map< string, string > m_mapAttributes;
                 NotificationReceiver *m_pNotiReceiver;
                 ResourceAttributes m_resourceAttributes;
 
index cc9ea7c..8c378ca 100644 (file)
@@ -51,6 +51,8 @@ namespace OIC
                 /**
                 * Callback method for getting notification from bundle resources
                 *
+                * @param strResourceUri - uri of attribute updated bundle resource
+                *
                 * @return void
                 */
                 virtual void onNotificationReceived(std::string strResourceUri) = 0;
index a0b3196..414d688 100644 (file)
@@ -32,8 +32,8 @@ namespace OIC
 
         /**
         * @class    ProtocolBridgeConnector
-        * @brief    This class represents connector for Protocol Bridge
-        *               to
+        * @brief    This class represents connector
+        *               to bridge non-IoTivity protocol and IoTivity for Protocol Bridge
         *
         */
         class ProtocolBridgeConnector
@@ -51,14 +51,14 @@ namespace OIC
                 virtual ~ProtocolBridgeConnector();
 
                 /**
-                * Execute the logic needed for connection with diffrent protocol from IoTivity
+                * Execute the logic needed for connection with different protocol from IoTivity
                 *
                 * @return void
                 */
                 virtual void connect() = 0;
 
                 /**
-                * Execute the logic needed for disconnection with diffrent protocol from IoTivity
+                * Execute the logic needed for disconnection with different protocol from IoTivity
                 *
                 * @return void
                 */
index c140b68..349368e 100644 (file)
@@ -50,11 +50,32 @@ namespace OIC
                 */
                 virtual ~ProtocolBridgeResource();
 
-                virtual ResourceAttributes& getAttributes()=0;
+                /**
+                * Return all attributes of the resource
+                *
+                * @return ResourceAttributes - attributes of the resource
+                */
+                virtual ResourceAttributes &getAttributes() = 0;
 
-                virtual void setAttribute(std::string key, ResourceAttributes::Value&&)=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, ResourceAttributes::Value &&value) = 0;
 
-                virtual ResourceAttributes::Value getAttribute(const std::string& key)=0;
+                /**
+                * Execute the logic of bundle to get the value of attribute
+                *
+                * @param key - key of attribute to get
+                *
+                * @return ResourceAttributes::Value - return value of the attribute
+                */
+                virtual ResourceAttributes::Value getAttribute(const std::string &key) = 0;
         };
     }
 }
index edaf16b..52d361c 100644 (file)
@@ -54,26 +54,31 @@ namespace OIC
                 virtual ~SoftSensorResource();
 
                 /**
-                * Execute the logic of bundle to get the value of attribute
-                *
-                * @param attributeName - name of attribute to get
-                *
-                * @return string - return value of the attribute
+                * Return all attributes of the resource
                 *
-                * @todo use type variant mechanism
+                * @return ResourceAttributes - attributes of the resource
                 */
-                virtual ResourceAttributes::Value getAttribute(string attributeName) = 0;
+                virtual ResourceAttributes &getAttributes() = 0;
 
                 /**
                 * Execute the logic of bundle to set the value of attribute
                 *
-                * @param attributeName - name of attribute to set
+                * @param key - name of attribute to set
                 *
                 * @param value - value of attribute to set
                 *
                 * @return void
                 */
-                virtual void setAttribute(string attributeName, ResourceAttributes::Value value) = 0;
+                virtual void setAttribute(std::string key, ResourceAttributes::Value &&value) = 0;
+
+                /**
+                * Execute the logic of bundle to get the value of attribute
+                *
+                * @param key - key of attribute to get
+                *
+                * @return ResourceAttributes::Value - return value of the attribute
+                */
+                virtual ResourceAttributes::Value getAttribute(const std::string &key) = 0;
 
                 /**
                 * Set Input data to update output value of the soft sensor
@@ -85,6 +90,7 @@ namespace OIC
                 virtual void setInputAttribute(SensorData inputs) = 0;
 
 
+            public:
                 unsigned int inputCount;
                 vector<string> m_vecInputAttributes;
                 map< string, SensorData > m_mapStoredInputData;
index 35d7e0b..714cd57 100644 (file)
@@ -59,9 +59,10 @@ void HueSampleBundleActivator::deactivateBundle()
 {
     std::cout << "HueSampleBundle::deactivateBundle called" << std::endl;
 
-    for (unsigned int i = 0; i < m_vecResources.size(); i++)
+    std::vector<BundleResource *>::iterator itor;
+    for (itor = m_vecResources.begin(); itor != m_vecResources.end();)
     {
-        destroyResource(m_vecResources.at(i));
+        destroyResource(*itor);
     }
 
     delete m_connector;
@@ -99,16 +100,6 @@ void HueSampleBundleActivator::destroyResource(BundleResource *pBundleResource)
         m_pResourceContainer->unregisterResource(pBundleResource);
         m_vecResources.erase(itor);
     }
-
-    //TODO
-    /*std::cout << "Clearing up memory.\n";
-
-    if (itor != m_vecResources.end())
-        m_vecResources.erase(itor);*/
-
-    // check
-    //delete resource;
-
 }
 
 extern "C" void externalActivateBundle(ResourceContainerBundleAPI *resourceContainer,
index a07958f..d0fe7c8 100644 (file)
@@ -36,9 +36,10 @@ class DiscomfortIndexSensorResource : public SoftSensorResource
         DiscomfortIndexSensorResource(vector<string> inputAttributes);
         ~DiscomfortIndexSensorResource();
 
-        ResourceAttributes::Value getAttribute(string attributeName);
-        void setAttribute(string attributeName, ResourceAttributes::Value value);
         virtual void initAttributes();
+        virtual ResourceAttributes &getAttributes();
+        virtual void setAttribute(std::string key, ResourceAttributes::Value &&value);
+        virtual ResourceAttributes::Value getAttribute(const std::string &key);
 
         void setInputAttribute(SensorData input);
 
index 8be9398..67161cf 100644 (file)
@@ -45,18 +45,25 @@ void DiscomfortIndexSensorResource::initAttributes()
 
     BundleResource::setAttribute("temperature", "23");
     BundleResource::setAttribute("humidity", "40");
-    BundleResource::setAttribute("discomfortIndex","5");
+    BundleResource::setAttribute("discomfortIndex", "5");
 }
 
-ResourceAttributes::Value DiscomfortIndexSensorResource::getAttribute(string attributeName)
+ResourceAttributes &DiscomfortIndexSensorResource::getAttributes()
 {
-    cout << "DiscomfortIndexSensorResource::getAttribute called !!" << endl;
-    return BundleResource::getAttribute(attributeName);
+    return BundleResource::getAttributes();
 }
 
-void DiscomfortIndexSensorResource::setAttribute(string attributeName, ResourceAttributes::Value value)
+ResourceAttributes::Value DiscomfortIndexSensorResource::getAttribute(const std::string &key)
 {
-    cout << "DiscomfortIndexSensorResource::setAttribute called !!" << endl;
+    cout << "DiscomfortIndexSensorResource::getAttribute called for " << key << " called" << endl;
+    return BundleResource::getAttribute(key);
+}
+
+void DiscomfortIndexSensorResource::setAttribute(std::string key, ResourceAttributes::Value &&value)
+{
+    cout << "DiscomfortIndexSensorResource::setAttribute setting " << key << " to " << value.toString()
+         << std::endl;
+    BundleResource::setAttribute(key, std::move(value));
 }
 
 void DiscomfortIndexSensorResource::setInputAttribute(SensorData input)
@@ -83,13 +90,16 @@ void DiscomfortIndexSensorResource::setInputAttribute(SensorData input)
             for (unsigned int i = 0; i < m_outputs.data.size(); i++)
             {
                 if (!m_outputs.data.at(i)["name"].compare("temperature"))
-                    BundleResource::setAttribute("temperature", m_outputs.data.at(i)["value"]);
+                    BundleResource::setAttribute("temperature",
+                                                 ResourceAttributes::Value(m_outputs.data.at(i)["value"].c_str()));
 
                 else if (!m_outputs.data.at(i)["name"].compare("humidity"))
-                    BundleResource::setAttribute("humidity", m_outputs.data.at(i)["value"]);
+                    BundleResource::setAttribute("humidity",
+                                                 ResourceAttributes::Value(m_outputs.data.at(i)["value"].c_str()));
 
                 else if (!m_outputs.data.at(i)["name"].compare("discomfortIndex"))
-                    BundleResource::setAttribute("discomfortIndex", m_outputs.data.at(i)["value"]);
+                    BundleResource::setAttribute("discomfortIndex",
+                                                 ResourceAttributes::Value(m_outputs.data.at(i)["value"].c_str()));
             }
         }
     }
index f801c7a..e85c094 100644 (file)
@@ -54,9 +54,10 @@ void SoftSensorBundleActivator::deactivateBundle()
 {
     std::cout << "SoftSensorSampleBundle::deactivateBundle called" << std::endl;
 
-    for (unsigned int i = 0; i < m_vecResources.size(); i++)
+    std::vector<BundleResource *>::iterator itor;
+    for (itor = m_vecResources.begin(); itor != m_vecResources.end();)
     {
-        destroyResource(m_vecResources.at(i));
+        destroyResource(*itor);
     }
 }
 
index 830bf19..dff6250 100644 (file)
@@ -110,6 +110,7 @@ int main()
         cout << "\t>>> bundle Id : " << (*bundleIt)->getID().c_str() << endl;
     }
 
+#if(JAVA_SUPPORT)
     /*java bundle add test*/
     cout << "\n++++++++++++++++++++++++++++" << endl;
     cout << "+++ Test for JAVA Bundle +++" << endl;
@@ -147,6 +148,7 @@ int main()
     {
         cout << "\t>>> bundle Id : " << (*bundleIt)->getID().c_str() << endl;
     }
+#endif
 
     cout << "\nPress enter to stop container " << endl;
     getchar();
index 80a0742..d1c6080 100644 (file)
@@ -404,13 +404,6 @@ namespace OIC
                     ((BundleInfoInternal *) bundleInfo)->setActivatorName(activatorName);
                     ((BundleInfoInternal *) bundleInfo)->setLibraryPath(params["libraryPath"]);
                 }
-                if (params.find("activator") != params.end())
-                {
-                    string activatorName = params["activator"];
-                    std::replace(activatorName.begin(), activatorName.end(), '.', '/');
-                    ((BundleInfoInternal *) bundleInfo)->setActivatorName(activatorName);
-                    ((BundleInfoInternal *) bundleInfo)->setLibraryPath(params["libraryPath"]);
-                }
 
                 info_logger() << "Add Bundle:" << bundleInfo->getID().c_str() << ";"
                         << bundleInfo->getPath().c_str() << endl;