Commit 88bbfc37 authored by KIM JungYong's avatar KIM JungYong Committed by Uze Choi

Fix to apply Coding convention on services.

Change-Id: I9bdb0e8147bcbbad6a28a6635cd7c4c3c16d9359
Signed-off-by: default avatarKIM JungYong <jyong2.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/12345Tested-by: default avatarjenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: default avatarUze Choi <uzchoi@samsung.com>
parent 099bdb09
......@@ -43,12 +43,18 @@ namespace OIC
/**
* Constructor for BundleActivator
*/
BundleActivator() { };
BundleActivator()
{
};
/**
* Virtual destructor for BundleActivator
*/
virtual ~BundleActivator() { };
virtual ~BundleActivator()
{
};
/**
* Activate the Bundle to make bundle work and create bundle resources
......
......@@ -41,12 +41,18 @@ namespace OIC
/**
* Constructor for NotificationReceiver
*/
NotificationReceiver() {};
NotificationReceiver()
{
};
/**
* destructor for NotificationReceiver
*/
~NotificationReceiver() {};
~NotificationReceiver()
{
};
/**
* Callback method for getting notification from bundle resources
......
......@@ -43,12 +43,18 @@ namespace OIC
/**
* Constructor for ProtocolBridgeConnector
*/
ProtocolBridgeConnector() { };
ProtocolBridgeConnector()
{
};
/**
* Virtual destructor for ProtocolBridgeConnector
*/
virtual ~ProtocolBridgeConnector() { };
virtual ~ProtocolBridgeConnector()
{
};
/**
* Execute the logic needed for connection with different protocol from IoTivity
......
......@@ -43,12 +43,18 @@ namespace OIC
/**
* Constructor for ProtocolBridgeResource
*/
ProtocolBridgeResource() { };
ProtocolBridgeResource()
{
};
/**
* Virtual destructor for ProtocolBridgeResource
*/
virtual ~ProtocolBridgeResource() { };
virtual ~ProtocolBridgeResource()
{
};
/**
* Initialize attributes of the resource
......
......@@ -51,7 +51,9 @@ void BMISensorResource::executeLogic()
std::string strBMIResult;
if (m_pBMISensor->executeBMISensorLogic(&m_mapInputData, &strBMIResult) != -1)
{
setAttribute("BMIresult", RCSResourceAttributes::Value(strBMIResult.c_str()));
}
}
void BMISensorResource::onUpdatedInputResource(const std::string attributeName,
......@@ -61,10 +63,14 @@ void BMISensorResource::onUpdatedInputResource(const std::string attributeName,
m_mapInputData.clear();
if (!attributeName.compare("weight"))
{
m_mapInputData.insert(std::make_pair("weight", values.back().get< std::string >()));
}
if (!attributeName.compare("height"))
{
m_mapInputData.insert(std::make_pair("height", values.back().get< std::string >()));
}
executeLogic();
}
......@@ -46,7 +46,9 @@ namespace
EXIT = 11
} APPMenu;
struct CloseApp {};
struct CloseApp
{
};
const int MAX_PATH = 2048;
......@@ -69,7 +71,9 @@ void getCurrentPath(std::string *pPath)
char buffer[MAX_PATH];
if (!pPath->empty())
{
pPath->clear();
}
#if defined(__linux__)
char *strPath = NULL;
......@@ -81,7 +85,9 @@ void getCurrentPath(std::string *pPath)
strPath = strrchr(buffer, '/');
if (strPath != NULL)
{
*strPath = '\0';
}
}
#endif
pPath->append(buffer);
......@@ -94,7 +100,9 @@ int processUserInput(int min, int max)
std::cin >> input;
if (!std::cin.fail() && min <= input && input <= max)
{
return input;
}
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
......@@ -141,7 +149,9 @@ bool checkBundleRegistered(std::string bundleId)
for (auto &bundle : bundleList)
{
if (bundle->getID().compare(bundleId) == 0)
{
return true;
}
}
}
......@@ -160,7 +170,9 @@ bool checkResourceRegistered(std::string bundleId, std::string resourceUri)
for (auto &resource : resourceList)
{
if (resource.compare(resourceUri) == 0)
{
return true;
}
}
}
......@@ -237,7 +249,9 @@ void StopSampleBundle()
g_bSampleBundleStarted = false;
}
else
{
std::cout << "Sample Bundle is not started." << std::endl;
}
}
else
{
......@@ -250,7 +264,9 @@ void RemoveSampleBundle()
if (g_pResourceContainer && g_bContainerStarted)
{
if (checkBundleRegistered(EXAMPLE_BUNDLE_ID))
{
g_pResourceContainer->removeBundle(EXAMPLE_BUNDLE_ID);
}
}
else
{
......@@ -273,7 +289,9 @@ void AddSampleBundleResource()
resourceParams);
}
else
{
std::cout << "Sample Bundle is not started." << std::endl;
}
}
else
{
......@@ -287,9 +305,13 @@ void RemoveSampleBundleResource()
{
if (checkResourceRegistered(EXAMPLE_BUNDLE_ID, EXAMPLE_RESOURCE_URI)
&& g_bSampleBundleStarted)
{
g_pResourceContainer->removeResourceConfig(EXAMPLE_BUNDLE_ID, EXAMPLE_RESOURCE_URI);
}
else
{
std::cout << "Sample Bundle is not started." << std::endl;
}
}
else
{
......@@ -434,7 +456,9 @@ int main()
}
if (g_bContainerStarted)
{
g_pResourceContainer->stopContainer();
}
g_pResourceContainer = nullptr;
......
......@@ -180,9 +180,13 @@ void onPost2(const HeaderOptions &headerOptions, const OCRepresentation &rep, co
}
if (OBSERVE_TYPE_TO_USE == ObserveType::Observe)
{
std::cout << std::endl << "Observe is used." << std::endl << std::endl;
}
else if (OBSERVE_TYPE_TO_USE == ObserveType::ObserveAll)
{
std::cout << std::endl << "ObserveAll is used." << std::endl << std::endl;
}
curResource->observe(OBSERVE_TYPE_TO_USE, QueryParamsMap(), &onObserve);
......
......@@ -95,7 +95,9 @@ std::string HueConnector::transmit(std::string target, std::string payload)
res = curl_easy_perform(curl);
/* Check for errors */
if (res != CURLE_OK)
{
fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
}
/* always cleanup */
curl_easy_cleanup(curl);
......
......@@ -90,8 +90,12 @@ namespace OIC
*/
virtual bool isActivated() = 0;
RCSBundleInfo(){};
virtual ~RCSBundleInfo(){};
RCSBundleInfo()
{
};
virtual ~RCSBundleInfo()
{
};
protected:
std::string m_ID, m_path, m_version;
......
......@@ -51,7 +51,8 @@ namespace OIC
{
std::list< std::string > ret;
for (auto &it : m_resourceAttributes){
for (auto &it : m_resourceAttributes)
{
ret.push_back(it.key());
}
......@@ -81,12 +82,14 @@ namespace OIC
m_resourceAttributes[it.key()] = it.value();
}
if(notify){
if(notify)
{
// asynchronous notification
auto notifyFunc = [](NotificationReceiver *notificationReceiver,
std::string uri)
{
if (notificationReceiver){
if (notificationReceiver)
{
notificationReceiver->onNotificationReceived(uri);
}
};
......@@ -104,12 +107,14 @@ namespace OIC
std::lock_guard<std::mutex> lock(m_resourceAttributes_mutex);
m_resourceAttributes[key] = std::move(value);
if(notify){
if(notify)
{
// asynchronous notification
auto notifyFunc = [](NotificationReceiver *notificationReceiver,
std::string uri)
{
if (notificationReceiver){
if (notificationReceiver)
{
notificationReceiver->onNotificationReceived(uri);
}
};
......
......@@ -152,7 +152,8 @@ namespace OIC
{
strBundleId = bundle->first_node(BUNDLE_ID)->value();
}
else{
else
{
strBundleId = "";
}
......@@ -161,19 +162,23 @@ namespace OIC
bundleConfigMap.insert(std::make_pair(BUNDLE_ID, trim_both(strBundleId)));
// <path>
if (bundle->first_node(BUNDLE_PATH)){
if (bundle->first_node(BUNDLE_PATH))
{
strPath = bundle->first_node(BUNDLE_PATH)->value();
}
else{
else
{
strPath = "";
}
bundleConfigMap.insert(std::make_pair(BUNDLE_PATH, trim_both(strPath)));
// <version>
if (bundle->first_node(BUNDLE_VERSION)){
if (bundle->first_node(BUNDLE_VERSION))
{
strVersion = bundle->first_node(BUNDLE_VERSION)->value();
}
else{
else
{
strVersion = "";
}
bundleConfigMap.insert(
......@@ -195,7 +200,8 @@ namespace OIC
}
void Configuration::getResourceConfiguration(std::string bundleId, std::string resourceUri,
resourceInfo *resourceInfoOut){
resourceInfo *resourceInfoOut)
{
rapidxml::xml_node< char > *bundle;
rapidxml::xml_node< char > *resource;
rapidxml::xml_node< char > *item, *subItem, *subItem2;
......@@ -227,7 +233,8 @@ namespace OIC
OIC_LOG_V(INFO, CONTAINER_TAG, "Inspecting");
// <resourceInfo>
bundle = bundle->first_node(OUTPUT_RESOURCES_TAG);
if (bundle){
if (bundle)
{
for (resource = bundle->first_node(OUTPUT_RESOURCE_INFO);
resource; resource = resource->next_sibling())
{
......@@ -254,10 +261,14 @@ namespace OIC
}
else if (!strKey.compare(OUTPUT_RESOURCE_ADDR))
{
resourceInfoOut->address = trim_both(strValue);
}
else if (!strKey.compare(OUTPUT_RESOURCE_TYPE))
{
resourceInfoOut->resourceType = trim_both(strValue);
}
else
{
......@@ -307,7 +318,8 @@ namespace OIC
OIC_LOG_V(ERROR, CONTAINER_TAG, "Exception (%s)", e.what());
}
}
else{
else
{
OIC_LOG(INFO, CONTAINER_TAG, "config is not loaded yet !!");
}
}
......@@ -360,16 +372,24 @@ namespace OIC
strValue = item->value();
if (!strKey.compare(OUTPUT_RESOURCE_NAME))
{
tempResourceInfo.name = trim_both(strValue);
}
else if (!strKey.compare(OUTPUT_RESOURCE_URI))
{
tempResourceInfo.uri = trim_both(strValue);
}
else if (!strKey.compare(OUTPUT_RESOURCE_ADDR))
{
tempResourceInfo.address = trim_both(strValue);
}
else if (!strKey.compare(OUTPUT_RESOURCE_TYPE))
{
tempResourceInfo.resourceType = trim_both(strValue);
}
else
{
......@@ -420,7 +440,8 @@ namespace OIC
OIC_LOG_V(ERROR, CONTAINER_TAG, "Exception (%s)", e.what());
}
}
else{
else
{
OIC_LOG(INFO, CONTAINER_TAG, "config is not loaded yet !!");
}
}
......
......@@ -89,7 +89,8 @@ void DiscoverResourceUnit::discoverdCB(RCSRemoteResourceObject::Ptr remoteObject
if (remoteObject && !isAlreadyDiscoveredResource(remoteObject))
{
OIC_LOG_V(DEBUG, DISCOVER_TAG, "Discovered - uri: %s", uri.c_str());
if (uri.empty() || uri.compare(remoteObject->getUri()) == 0){
if (uri.empty() || uri.compare(remoteObject->getUri()) == 0)
{
RemoteResourceUnit::Ptr newDiscoveredResource =
RemoteResourceUnit::createRemoteResourceInfo(remoteObject,
pUpdatedCBFromServer);
......@@ -99,7 +100,8 @@ void DiscoverResourceUnit::discoverdCB(RCSRemoteResourceObject::Ptr remoteObject
OIC_LOG_V(DEBUG, DISCOVER_TAG, "Created remote resource unit");
}
else{
else
{
OIC_LOG_V(DEBUG, DISCOVER_TAG, "URI is not matching - uri: %s", uri.c_str());
}
}
......
......@@ -44,9 +44,15 @@ namespace OIC
struct DiscoverResourceInfo
{
DiscoverResourceInfo()
: resourceUri(), resourceType(), attributeName() {}
: resourceUri(), resourceType(), attributeName()
{
}
DiscoverResourceInfo(std::string uri, std::string type, std::string name)
: resourceUri(uri), resourceType(type), attributeName(name) {}
: resourceUri(uri), resourceType(type), attributeName(name)
{
}
std::string resourceUri;
std::string resourceType;
std::string attributeName;
......
......@@ -39,19 +39,23 @@ RemoteResourceUnit::~RemoteResourceUnit()
{
if(remoteObject->isCaching())
{
try{
try
{
remoteObject->stopCaching();
}
catch(std::exception &e){
catch(std::exception &e)
{
OIC_LOG_V(ERROR, CONTAINER_TAG, "%s", e.what());
}
}
if(remoteObject->isMonitoring())
{
try{
try
{
remoteObject->stopMonitoring();
}
catch(std::exception &e){
catch(std::exception &e)
{
OIC_LOG_V(ERROR, CONTAINER_TAG, "%s", e.what());
}
}
......
......@@ -68,7 +68,8 @@ namespace OIC
activationLock.lock();
try{
try
{
if (!configFile.empty())
{
m_config = new Configuration(configFile);
......@@ -111,7 +112,9 @@ namespace OIC
}
OIC_LOG(INFO, CONTAINER_TAG, "Resource container started.");
}catch(...){
}
catch (...)
{
OIC_LOG(INFO, CONTAINER_TAG, "Resource container failed starting.");
}
activationLock.unlock();
......@@ -142,7 +145,9 @@ namespace OIC
}
if (m_config)
{
delete m_config;
}
}
void ResourceContainerImpl::activateBundle(shared_ptr<RCSBundleInfo> bundleInfo)
......@@ -175,10 +180,12 @@ namespace OIC
std::string(m_bundles[id]->getID()).c_str());
activationLock.lock();
try{
try
{
activateBundleThread(id);
}
catch(...){
catch (...)
{
OIC_LOG_V(INFO, CONTAINER_TAG, "Activating bundle: (%s) failed",
std::string(m_bundles[id]->getID()).c_str());
}
......@@ -222,14 +229,15 @@ namespace OIC
registerExtBundle(bundleInfo);
#endif
}
else if(has_suffix(bundleInfo->getPath(), ".so"))
else if (has_suffix(bundleInfo->getPath(), ".so"))
{
bundleInfoInternal->setSoBundle(true);
bundleInfoInternal->setJavaBundle(false);
registerSoBundle(bundleInfo);
}
// other cases might be for example .apk for android, which are loaded in the wrapper
else{
else
{
bundleInfoInternal->setSoBundle(false);
bundleInfoInternal->setJavaBundle(false);
registerExtBundle(bundleInfo);
......@@ -246,7 +254,7 @@ namespace OIC
{
unregisterBundleSo(bundleInfo->getID());
}
else if(bundleInfoInternal->getJavaBundle())
else if (bundleInfoInternal->getJavaBundle())
{
#if(JAVA_SUPPORT)
unregisterBundleJava(bundleInfo->getID());
......@@ -290,7 +298,8 @@ namespace OIC
registrationLock.lock();
if (m_mapResources.find(strUri) == m_mapResources.end())
{
if (strInterface.empty()) {
if (strInterface.empty())
{
strInterface = "oic.if.baseline";
}
......@@ -321,7 +330,8 @@ namespace OIC
strResourceType).c_str());
discoverInputResource(strUri);
}
else{
else
{
OIC_LOG_V(INFO, CONTAINER_TAG, "Resource has no input (%s)",
std::string(strUri + ", " +
strResourceType).c_str());
......@@ -395,7 +405,8 @@ namespace OIC
{
m_config->getResourceConfiguration(bundleId, configOutput);
}
else{
else
{
OIC_LOG_V(DEBUG, CONTAINER_TAG, "no config present ");
}
}
......@@ -499,7 +510,9 @@ namespace OIC
if (m_bundles.find(bundleId) != m_bundles.end())
{
if (!m_bundles[bundleId]->isActivated())
{
activateBundle(m_bundles[bundleId]);
}
else
{
OIC_LOG(ERROR, CONTAINER_TAG, "Bundle already started");
......@@ -518,7 +531,9 @@ namespace OIC
if (m_bundles.find(bundleId) != m_bundles.end())
{
if (m_bundles[bundleId]->isActivated())
{
deactivateBundle(m_bundles[bundleId]);
}
else
{
OIC_LOG(ERROR, CONTAINER_TAG, "Bundle not activated");
......@@ -540,7 +555,9 @@ namespace OIC
(void) bundleUri;
if (m_bundles.find(bundleId) != m_bundles.end())
{
OIC_LOG(ERROR, CONTAINER_TAG, "BundleId already exist");
}
else
{
......@@ -571,10 +588,14 @@ namespace OIC
{