From: Minji Park Date: Wed, 22 Jul 2015 02:44:44 +0000 (+0900) Subject: resource-manipulation: Update container bundle-api doxygen comments X-Git-Tag: 1.2.0+RC1~1408 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1486f598ecfdbf08b8a57c9eca7a3086d80f1533;p=platform%2Fupstream%2Fiotivity.git resource-manipulation: Update container bundle-api doxygen comments - 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 Reviewed-on: https://gerrit.iotivity.org/gerrit/1806 Tested-by: jenkins-iotivity Reviewed-by: Uze Choi --- diff --git a/service/resource-manipulation/src/resourceContainer/bundle-api/include/BundleActivator.h b/service/resource-manipulation/src/resourceContainer/bundle-api/include/BundleActivator.h index 38d5cdc..5a802ad 100644 --- a/service/resource-manipulation/src/resourceContainer/bundle-api/include/BundleActivator.h +++ b/service/resource-manipulation/src/resourceContainer/bundle-api/include/BundleActivator.h @@ -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; }; } diff --git a/service/resource-manipulation/src/resourceContainer/bundle-api/include/BundleResource.h b/service/resource-manipulation/src/resourceContainer/bundle-api/include/BundleResource.h index 93be008..96890db 100644 --- a/service/resource-manipulation/src/resourceContainer/bundle-api/include/BundleResource.h +++ b/service/resource-manipulation/src/resourceContainer/bundle-api/include/BundleResource.h @@ -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; diff --git a/service/resource-manipulation/src/resourceContainer/bundle-api/include/NotificationReceiver.h b/service/resource-manipulation/src/resourceContainer/bundle-api/include/NotificationReceiver.h index cc9ea7c..8c378ca 100644 --- a/service/resource-manipulation/src/resourceContainer/bundle-api/include/NotificationReceiver.h +++ b/service/resource-manipulation/src/resourceContainer/bundle-api/include/NotificationReceiver.h @@ -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; diff --git a/service/resource-manipulation/src/resourceContainer/bundle-api/include/ProtocolBridgeConnector.h b/service/resource-manipulation/src/resourceContainer/bundle-api/include/ProtocolBridgeConnector.h index a0b3196..414d688 100644 --- a/service/resource-manipulation/src/resourceContainer/bundle-api/include/ProtocolBridgeConnector.h +++ b/service/resource-manipulation/src/resourceContainer/bundle-api/include/ProtocolBridgeConnector.h @@ -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 */ diff --git a/service/resource-manipulation/src/resourceContainer/bundle-api/include/ProtocolBridgeResource.h b/service/resource-manipulation/src/resourceContainer/bundle-api/include/ProtocolBridgeResource.h index c140b68..349368e 100644 --- a/service/resource-manipulation/src/resourceContainer/bundle-api/include/ProtocolBridgeResource.h +++ b/service/resource-manipulation/src/resourceContainer/bundle-api/include/ProtocolBridgeResource.h @@ -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; }; } } diff --git a/service/resource-manipulation/src/resourceContainer/bundle-api/include/ResourceContainerBundleAPI.h b/service/resource-manipulation/src/resourceContainer/bundle-api/include/ResourceContainerBundleAPI.h index 1506e67..c7a869c 100644 --- a/service/resource-manipulation/src/resourceContainer/bundle-api/include/ResourceContainerBundleAPI.h +++ b/service/resource-manipulation/src/resourceContainer/bundle-api/include/ResourceContainerBundleAPI.h @@ -25,7 +25,6 @@ #include #include -//#include "ResourceContainer.h" #include "BundleInfo.h" #include "Configuration.h" #include "NotificationReceiver.h" diff --git a/service/resource-manipulation/src/resourceContainer/bundle-api/include/SoftSensorResource.h b/service/resource-manipulation/src/resourceContainer/bundle-api/include/SoftSensorResource.h index edaf16b..52d361c 100644 --- a/service/resource-manipulation/src/resourceContainer/bundle-api/include/SoftSensorResource.h +++ b/service/resource-manipulation/src/resourceContainer/bundle-api/include/SoftSensorResource.h @@ -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 m_vecInputAttributes; map< string, SensorData > m_mapStoredInputData; diff --git a/service/resource-manipulation/src/resourceContainer/examples/HueSampleBundle/src/HueSampleBundleActivator.cpp b/service/resource-manipulation/src/resourceContainer/examples/HueSampleBundle/src/HueSampleBundleActivator.cpp index 35d7e0b..714cd57 100644 --- a/service/resource-manipulation/src/resourceContainer/examples/HueSampleBundle/src/HueSampleBundleActivator.cpp +++ b/service/resource-manipulation/src/resourceContainer/examples/HueSampleBundle/src/HueSampleBundleActivator.cpp @@ -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::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, diff --git a/service/resource-manipulation/src/resourceContainer/examples/SoftSensorSampleBundle/include/DiscomfortIndexSensorResource.h b/service/resource-manipulation/src/resourceContainer/examples/SoftSensorSampleBundle/include/DiscomfortIndexSensorResource.h index a07958f..d0fe7c8 100644 --- a/service/resource-manipulation/src/resourceContainer/examples/SoftSensorSampleBundle/include/DiscomfortIndexSensorResource.h +++ b/service/resource-manipulation/src/resourceContainer/examples/SoftSensorSampleBundle/include/DiscomfortIndexSensorResource.h @@ -36,9 +36,10 @@ class DiscomfortIndexSensorResource : public SoftSensorResource DiscomfortIndexSensorResource(vector 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); diff --git a/service/resource-manipulation/src/resourceContainer/examples/SoftSensorSampleBundle/src/DiscomfortIndexSensorResource.cpp b/service/resource-manipulation/src/resourceContainer/examples/SoftSensorSampleBundle/src/DiscomfortIndexSensorResource.cpp index 8be9398..67161cf 100644 --- a/service/resource-manipulation/src/resourceContainer/examples/SoftSensorSampleBundle/src/DiscomfortIndexSensorResource.cpp +++ b/service/resource-manipulation/src/resourceContainer/examples/SoftSensorSampleBundle/src/DiscomfortIndexSensorResource.cpp @@ -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())); } } } diff --git a/service/resource-manipulation/src/resourceContainer/examples/SoftSensorSampleBundle/src/SoftSensorBundleActivator.cpp b/service/resource-manipulation/src/resourceContainer/examples/SoftSensorSampleBundle/src/SoftSensorBundleActivator.cpp index f801c7a..e85c094 100644 --- a/service/resource-manipulation/src/resourceContainer/examples/SoftSensorSampleBundle/src/SoftSensorBundleActivator.cpp +++ b/service/resource-manipulation/src/resourceContainer/examples/SoftSensorSampleBundle/src/SoftSensorBundleActivator.cpp @@ -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::iterator itor; + for (itor = m_vecResources.begin(); itor != m_vecResources.end();) { - destroyResource(m_vecResources.at(i)); + destroyResource(*itor); } } diff --git a/service/resource-manipulation/src/resourceContainer/src/ContainerSample.cpp b/service/resource-manipulation/src/resourceContainer/src/ContainerSample.cpp index 830bf19..dff6250 100644 --- a/service/resource-manipulation/src/resourceContainer/src/ContainerSample.cpp +++ b/service/resource-manipulation/src/resourceContainer/src/ContainerSample.cpp @@ -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(); diff --git a/service/resource-manipulation/src/resourceContainer/src/ResourceContainerImpl.cpp b/service/resource-manipulation/src/resourceContainer/src/ResourceContainerImpl.cpp index 80a0742..d1c6080 100644 --- a/service/resource-manipulation/src/resourceContainer/src/ResourceContainerImpl.cpp +++ b/service/resource-manipulation/src/resourceContainer/src/ResourceContainerImpl.cpp @@ -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;