sensor: remove necessity of dynamic_cast in SleepLogger 16/77816/1
authorMu-Woong Lee <muwoong.lee@samsung.com>
Fri, 1 Jul 2016 06:44:31 +0000 (15:44 +0900)
committerMu-Woong Lee <muwoong.lee@samsung.com>
Fri, 1 Jul 2016 06:44:31 +0000 (15:44 +0900)
Change-Id: I8d9579b7650ebcdaffeab3808968db065a35e97f
Signed-off-by: Mu-Woong Lee <muwoong.lee@samsung.com>
src/sensor/sleep/SleepLogger.cpp
src/sensor/sleep/SleepLogger.h

index 81f1547..f3e1470 100644 (file)
 
 using namespace ctx;
 
+static SleepDetector *__sleepDetector = NULL;
+static SleepMonitor  *__sleepMonitor  = NULL;
+
 SleepLogger::SleepLogger() :
-       __sleepDetector(NULL),
-       __sleepMonitor(NULL),
        __startTime(0),
        __endTime(0)
 {
+       __sleepDetector = NULL;
+       __sleepMonitor = NULL;
+
        /* Create the log table */
        executeQuery(
                        "CREATE TABLE IF NOT EXISTS " SLEEP_MONITOR_RECORD " (" \
@@ -81,7 +85,7 @@ bool SleepLogger::start()
        __endTime = 0;
        __resetInsertionQuery();
 
-       return dynamic_cast<SleepDetector*>(__sleepDetector)->start();
+       return __sleepDetector->start();
 }
 
 void SleepLogger::stop()
@@ -89,8 +93,8 @@ void SleepLogger::stop()
        IF_FAIL_VOID_TAG(__sleepDetector, _D, "Stopped already");
        _I(GREEN("Stop recording"));
 
-       dynamic_cast<SleepDetector*>(__sleepDetector)->stop();
-       dynamic_cast<SleepMonitor*>(__sleepMonitor)->stop();
+       __sleepDetector->stop();
+       __sleepMonitor->stop();
 
        __appendQuery(__startTime, __endTime);
        flush();
@@ -106,13 +110,13 @@ void SleepLogger::fallAsleep(uint64_t timestamp)
 {
        _D("Fall asleep");
        record(timestamp, TimeUtil::getTime(), STATE_SLEEP);
-       dynamic_cast<SleepMonitor*>(__sleepMonitor)->start();
+       __sleepMonitor->start();
 }
 
 void SleepLogger::wakeUp(uint64_t timestamp)
 {
        _D("Wake up");
-       dynamic_cast<SleepMonitor*>(__sleepMonitor)->lazyStop();
+       __sleepMonitor->lazyStop();
 }
 
 void SleepLogger::record(uint64_t startTime, uint64_t endTime, int state)
index 12f5dd2..447c59c 100644 (file)
@@ -18,7 +18,6 @@
 #define __CONTEXT_SLEEP_LOGGER_H__
 
 #include "../SensorLogger.h"
-#include "../SensorProxy.h"
 
 #define STATE_SLEEP    1
 #define STATE_WAKE     0
@@ -44,8 +43,6 @@ namespace ctx {
                void __appendQuery(uint64_t startTime, uint64_t endTime);
 
                std::string __insertionQuery;
-               SensorProxy *__sleepDetector;
-               SensorProxy *__sleepMonitor;
                uint64_t __startTime;
                uint64_t __endTime;
        };