Remove "define variables" on Notification Manager.
authorjyong2.kim <jyong2.kim@samsung.com>
Fri, 24 Jul 2015 07:37:28 +0000 (16:37 +0900)
committerUze Choi <uzchoi@samsung.com>
Fri, 24 Jul 2015 11:03:44 +0000 (11:03 +0000)
change anonymous namespace variables from define variables.
change macro to function in OIC::Service namespace.

Change-Id: I9d1e2a8d23d92b190b3255d21434c84efe359c73
Signed-off-by: jyong2.kim <jyong2.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1875
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
service/notification-manager/NotificationManager/src/HostingObject.cpp
service/notification-manager/NotificationManager/src/HostingObject.h
service/notification-manager/NotificationManager/src/ResourceHosting.cpp
service/notification-manager/NotificationManager/src/hosting.cpp

index 22d4b5c..8dcf868 100644 (file)
@@ -24,8 +24,20 @@ namespace OIC
 {
 namespace Service
 {
-#define HOSTING_LOG_TAG  PCF("Hosting")
-#define OIC_HOSTING_LOG(level, tag, ...)  OCLogv((level), (HOSTING_LOG_TAG), __VA_ARGS__)
+
+void OIC_HOSTING_LOG(LogLevel level, const char * format, ...)
+{
+    if (!format)
+    {
+        return;
+    }
+    char buffer[MAX_LOG_V_BUFFER_SIZE] = {};
+    va_list args;
+    va_start(args, format);
+    vsnprintf(buffer, sizeof buffer - 1, format, args);
+    va_end(args);
+    OCLog(level, PCF("Hosting"), buffer);
+}
 
 HostingObject::HostingObject()
 : remoteObject(nullptr), mirroredServer(nullptr),
index a93a30a..514eb43 100644 (file)
@@ -33,6 +33,8 @@ namespace OIC
 namespace Service
 {
 
+void OIC_HOSTING_LOG(LogLevel level, const char * format, ...);
+
 class HostingObject
 {
 private:
index 46289b4..2e77d8b 100755 (executable)
@@ -28,13 +28,10 @@ namespace OIC
 namespace Service
 {
 
-#define HOSTING_TAG "/hosting"
-#define HOSTING_TAG_SIZE ((size_t)8)
-#define HOSTING_LOG_TAG  PCF("Hosting")
-#define OIC_HOSTING_LOG(level, tag, ...)  OCLogv((level), (HOSTING_LOG_TAG), __VA_ARGS__)
-
 namespace
 {
+    std::string HOSTING_TAG = "/hosting";
+    size_t HOSTING_TAG_SIZE = (size_t)HOSTING_TAG.size();
     std::string MULTICAST_PRESENCE_ADDRESS = std::string("coap://") + OC_MULTICAST_PREFIX;
     std::string HOSTING_RESOURSE_TYPE = "Resource.Hosting";
 }
index 79ba751..d222795 100644 (file)
 #include "octypes.h"
 #include "logger.h"
 #include "ResourceHosting.h"
-
-namespace
-{
-    #define OC_TRANSPORT CT_ADAPTER_IP
-    #define HOSTING_TAG  PCF("Hosting")
-    #define OIC_HOSTING_LOG(level, tag, ...)  OCLogv((level), (HOSTING_TAG), __VA_ARGS__)
-    OIC::Service::ResourceHosting * rhInstance = OIC::Service::ResourceHosting::getInstance();
-}
+#include "HostingObject.h"
 
 OCStackResult OICStartCoordinate()
 {
+    using namespace OIC::Service;
     OCStackResult retResult = OC_STACK_OK;
     try
     {
-        rhInstance->startHosting();
-    }catch(OIC::Service::PlatformException &e)
+        ResourceHosting::getInstance()->startHosting();
+    }catch(PlatformException &e)
     {
-        OIC_HOSTING_LOG(DEBUG, "[OICStartCoordinate] platformException, reason:%s", e.what());
+        OIC_HOSTING_LOG(DEBUG,
+                "[OICStartCoordinate] platformException, reason:%s", e.what());
         retResult = OC_STACK_ERROR;
         throw;
-    }catch(OIC::Service::InvalidParameterException &e)
+    }catch(InvalidParameterException &e)
     {
         OIC_HOSTING_LOG(DEBUG,
                 "[OICStartCoordinate] InvalidParameterException, reason:%s", e.what());
@@ -57,7 +52,7 @@ OCStackResult OICStartCoordinate()
         throw;
     }catch(...)
     {
-        OIC_HOSTING_LOG(DEBUG, "[OICStartCoordinate] Unknown Exception", "");
+        OIC_HOSTING_LOG(DEBUG, "[OICStartCoordinate] Unknown Exception");
         retResult = OC_STACK_ERROR;
     }
 
@@ -67,7 +62,7 @@ OCStackResult OICStartCoordinate()
 OCStackResult OICStopCoordinate()
 {
     OCStackResult retResult = OC_STACK_OK;
-    rhInstance->stopHosting();
+    OIC::Service::ResourceHosting::getInstance()->stopHosting();
 
     return retResult;
 }