- 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>
*/
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;
};
}
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
*/
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:
map< string, vector< map< string, string > > > m_mapResourceProperty;
private:
- //map< string, string > m_mapAttributes;
NotificationReceiver *m_pNotiReceiver;
ResourceAttributes m_resourceAttributes;
/**
* 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;
/**
* @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
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
*/
*/
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;
};
}
}
#include <string.h>
#include <fstream>
-//#include "ResourceContainer.h"
#include "BundleInfo.h"
#include "Configuration.h"
#include "NotificationReceiver.h"
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
virtual void setInputAttribute(SensorData inputs) = 0;
+ public:
unsigned int inputCount;
vector<string> m_vecInputAttributes;
map< string, SensorData > m_mapStoredInputData;
{
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;
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,
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);
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)
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()));
}
}
}
{
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);
}
}
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;
{
cout << "\t>>> bundle Id : " << (*bundleIt)->getID().c_str() << endl;
}
+#endif
cout << "\nPress enter to stop container " << endl;
getchar();
((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;