Applying Tizen C++ coding style to place context provider(recognition) part 2. 16/65616/3
authorMarcin Masternak <m.masternak@samsung.com>
Tue, 12 Apr 2016 15:23:35 +0000 (17:23 +0200)
committerMarcin Masternak <m.masternak@samsung.com>
Tue, 12 Apr 2016 15:23:35 +0000 (17:23 +0200)
Change-Id: Ic8c198dc776eae2261ced0e48b0814ecd0419a5b
Signed-off-by: Marcin Masternak <m.masternak@samsung.com>
26 files changed:
src/place/PlaceContextProvider.cpp
src/place/recognition/place_recognition.cpp
src/place/recognition/place_recognition.h
src/place/recognition/place_recognition_types.h
src/place/recognition/user_places/gmap.cpp
src/place/recognition/user_places/gmap.h
src/place/recognition/user_places/graph.cpp
src/place/recognition/user_places/location_logger.cpp
src/place/recognition/user_places/location_logger.h
src/place/recognition/user_places/mahal.cpp
src/place/recognition/user_places/mahal.h
src/place/recognition/user_places/place_categer.cpp
src/place/recognition/user_places/place_categer.h
src/place/recognition/user_places/places_detector.cpp
src/place/recognition/user_places/places_detector.h
src/place/recognition/user_places/user_places.cpp
src/place/recognition/user_places/user_places.h
src/place/recognition/user_places/user_places_types.cpp
src/place/recognition/user_places/user_places_types.h
src/place/recognition/user_places/visit_categer.cpp
src/place/recognition/user_places/visit_categer.h
src/place/recognition/user_places/visit_detector.cpp
src/place/recognition/user_places/visit_detector.h
src/place/recognition/user_places/wifi_listener_iface.h
src/place/recognition/user_places/wifi_logger.cpp
src/place/recognition/user_places/wifi_logger.h

index f168dd11662eaf96bbcf38a0adb4b843fb1cdb4b..8eb75962eb9d48eca8011f73f3c9df244f7749ae 100644 (file)
@@ -43,8 +43,8 @@ EXTAPI bool ctx::initPlaceContextProvider()
        PlaceGeofenceProvider::submitTriggerItem();
 
 #ifndef _DISABLE_RECOG_ENGINE_
-       place_recognition_provider::create(NULL);
-       registerProvider<place_recognition_provider>(PLACE_SUBJ_RECOGNITION, PLACE_PRIV_RECOGNITION);
+       PlaceRecognitionProvider::create(NULL);
+       registerProvider<PlaceRecognitionProvider>(PLACE_SUBJ_RECOGNITION, PLACE_PRIV_RECOGNITION);
 #endif /* _DISABLE_RECOG_ENGINE_ */
 
 #endif /* _MOBILE_ */
index 60b174fb41e5f4980c62104206f7838300e4e06f..76c09e134654979ad8ddca3f18dc21b83563dab1 100644 (file)
 #include "place_recognition.h"
 #include "user_places/user_places.h"
 
-ctx::place_recognition_provider *ctx::place_recognition_provider::__instance = NULL;
+ctx::PlaceRecognitionProvider *ctx::PlaceRecognitionProvider::__instance = NULL;
 
-ctx::ContextProviderBase *ctx::place_recognition_provider::create(void *data)
+ctx::ContextProviderBase *ctx::PlaceRecognitionProvider::create(void *data)
 {
        IF_FAIL_RETURN(!__instance, __instance);
-       __instance = new(std::nothrow) place_recognition_provider();
+       __instance = new(std::nothrow) PlaceRecognitionProvider();
        IF_FAIL_RETURN_TAG(__instance, NULL, _E, "Memory allocation failed");
        _I(BLUE("Created"));
        return __instance;
 }
 
-void ctx::place_recognition_provider::destroy(void *data)
+void ctx::PlaceRecognitionProvider::destroy(void *data)
 {
        IF_FAIL_VOID(__instance);
        delete __instance;
@@ -38,40 +38,42 @@ void ctx::place_recognition_provider::destroy(void *data)
        _I(BLUE("Destroyed"));
 }
 
-int ctx::place_recognition_provider::subscribe(const char *subject, ctx::Json option, ctx::Json* requestResult)
+int ctx::PlaceRecognitionProvider::subscribe(const char *subject, ctx::Json option, ctx::Json* requestResult)
 {
        return ERR_NOT_SUPPORTED;
 }
 
-int ctx::place_recognition_provider::unsubscribe(const char *subject, ctx::Json option)
+int ctx::PlaceRecognitionProvider::unsubscribe(const char *subject, ctx::Json option)
 {
        return ERR_NOT_SUPPORTED;
 }
 
-int ctx::place_recognition_provider::read(const char *subject, ctx::Json option, ctx::Json* requestResult)
+int ctx::PlaceRecognitionProvider::read(const char *subject, ctx::Json option, ctx::Json* requestResult)
 {
        _I(BLUE("Read"));
        _J("Option", option);
 
-       std::vector<std::shared_ptr<ctx::Place>> places = engine.getPlaces();
+       std::vector<std::shared_ptr<ctx::Place>> places = __engine.getPlaces();
        Json dataRead = UserPlaces::composeJson(places);
 
-       // The below function needs to be called once.
-       // It does not need to be called within this read() function.
-       // In can be called later, in another scope.
-       // Please just be sure that, the 2nd input parameter "option" should be the same to the
-       // "option" parameter received via ctx::place_recognition_provider::read().
+       /*
+        * The below function needs to be called once.
+        * It does not need to be called within this read() function.
+        * In can be called later, in another scope.
+        * Please just be sure that, the 2nd input parameter "option" should be the same to the
+        * "option" parameter received via ctx::PlaceRecognitionProvider::read().
+        */
        ctx::context_manager::replyToRead(PLACE_SUBJ_RECOGNITION, option, ERR_NONE, dataRead);
 
        return ERR_NONE;
 }
 
-int ctx::place_recognition_provider::write(const char *subject, ctx::Json data, ctx::Json* requestResult)
+int ctx::PlaceRecognitionProvider::write(const char *subject, ctx::Json data, ctx::Json* requestResult)
 {
        return ERR_NOT_SUPPORTED;
 }
 
-bool ctx::place_recognition_provider::isSupported()
+bool ctx::PlaceRecognitionProvider::isSupported()
 {
        return true;
 }
index f5de60ef3328e6a0c485e7a4e3f6f65458f987ef..545c9537eb50a3eb08a5920ffc794bd378793236 100644 (file)
@@ -23,7 +23,7 @@
 
 namespace ctx {
 
-       class place_recognition_provider : public ContextProviderBase {
+       class PlaceRecognitionProvider : public ContextProviderBase {
 
        public:
                static ContextProviderBase *create(void *data);
@@ -36,13 +36,13 @@ namespace ctx {
                int write(const char *subject, ctx::Json data, ctx::Json *requestResult);
 
        private:
-               static place_recognition_provider *__instance;
-               UserPlaces engine;
+               static PlaceRecognitionProvider *__instance;
+               UserPlaces __engine;
 
-               place_recognition_provider() : engine(PLACE_RECOG_HIGH_ACCURACY_MODE) {}
-               ~place_recognition_provider() {}
+               PlaceRecognitionProvider() : __engine(PLACE_RECOG_HIGH_ACCURACY_MODE) {}
+               ~PlaceRecognitionProvider() {}
 
-       };      /* class place_recognition_provider */
+       };      /* class PlaceRecognitionProvider */
 
 }      /* namespace ctx */
 
index 435ea4a3d2ae409a7f15f894446c25c17c5e8f2f..95763318c342b8aaa87919add1788f67c468e11d 100644 (file)
@@ -81,9 +81,9 @@ enum PlaceCategId {
        PLACE_CATEG_ID_OTHER = 3
 };
 
-typedef enum {
+enum PlaceRecogMode {
        PLACE_RECOG_HIGH_ACCURACY_MODE = 0,
        PLACE_RECOG_LOW_POWER_MODE = 1
-} place_recog_mode_e;
+};
 
 #endif /* End of _CONTEXT_PLACE_RECOGNITION_TYPES_ */
index 99b155acc9b1c981f711393dde2443450e07e45b..845b3cf34a14fe32bcd6842cb4764c9735262e0e 100644 (file)
@@ -18,7 +18,7 @@
 #include <iostream>
 #include <fstream>
 
-const std::string ctx::Gmap::__htmlHeader = R"(
+const std::string ctx::Gmap::__HTML_HEADER = R"(
 <!DOCTYPE html>
 <html>
   <head>
@@ -42,7 +42,7 @@ function initialize() {
   var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
 )";
 
-const std::string ctx::Gmap::__htmlFooter = R"(
+const std::string ctx::Gmap::__HTML_FOOTER = R"(
 }
 
 google.maps.event.addDomListener(window, 'load', initialize);
@@ -55,9 +55,9 @@ google.maps.event.addDomListener(window, 'load', initialize);
 </html>
 )";
 
-std::string ctx::Gmap::__iconForCategId(PlaceCategId categ_id)
+std::string ctx::Gmap::__iconForCategId(PlaceCategId categId)
 {
-       switch (categ_id) {
+       switch (categId) {
        case PLACE_CATEG_ID_HOME:  return "markerH.png";
        case PLACE_CATEG_ID_WORK:  return "markerW.png";
        case PLACE_CATEG_ID_OTHER: return "markerO.png";
@@ -68,22 +68,22 @@ std::string ctx::Gmap::__iconForCategId(PlaceCategId categ_id)
 
 void ctx::Gmap::__placeMarker2Stream(const ctx::Place& place, std::ostream& out)
 {
-       if (place.location_valid) {
+       if (place.locationValid) {
                out << "new google.maps.Marker({" << std::endl;
                out << "    position: new google.maps.LatLng(" << place.location.latitude << "," << place.location.longitude << ")," << std::endl;
                out << "    map: map," << std::endl;
-               out << "    icon: \"http://maps.google.com/mapfiles/" << __iconForCategId(place.categ_id)<< "\"" << std::endl;
+               out << "    icon: \"http://maps.google.com/mapfiles/" << __iconForCategId(place.categId)<< "\"" << std::endl;
                out << "});" << std::endl;
        }
 }
 
 void ctx::Gmap::__html2Stream(const std::vector<std::shared_ptr<ctx::Place>>& places, std::ostream& out)
 {
-       out << __htmlHeader;
+       out << __HTML_HEADER;
        for (std::shared_ptr<ctx::Place> place : places) {
                __placeMarker2Stream(*place, out);
        }
-       out << __htmlFooter;
+       out << __HTML_FOOTER;
 }
 
 void ctx::Gmap::writeMap(const std::vector<std::shared_ptr<ctx::Place>>& places)
index 5d1f885de8795968e19845f75d50fb3d89e23f8f..29eacd21bfc995b3b0ef1a8c74f1cea36c159011 100644 (file)
@@ -31,9 +31,9 @@ namespace ctx {
        class Gmap {
 
        private:
-               const static std::string __htmlHeader;
-               const static std::string __htmlFooter;
-               static std::string __iconForCategId(PlaceCategId categ_id);
+               static const std::string __HTML_HEADER;
+               static const std::string __HTML_FOOTER;
+               static std::string __iconForCategId(PlaceCategId categId);
                static void __placeMarker2Stream(const Place& place, std::ostream& out);
                static void __html2Stream(const std::vector<std::shared_ptr<Place>>& places, std::ostream& out);
 
index b8bab2726d25b82a2a89ffff161ed68e6024efcb..53daeb3af4e3d4233931db0446d27c9adb57fb6a 100644 (file)
@@ -32,17 +32,17 @@ std::shared_ptr<ctx::graph::Components> ctx::graph::connectedComponents(Graph &g
                ccs->push_back(c);
                fringe.insert(i);
                while (!fringe.empty()) {
-                       Node curr_node = *fringe.begin();
+                       Node currNode = *fringe.begin();
                        fringe.erase(fringe.begin());
-                       c->insert(curr_node);
+                       c->insert(currNode);
 
-                       std::shared_ptr<NeighbourNodes> curr_nhood = graph[curr_node];
-                       for (Node nhood_node : *curr_nhood) {
-                               if (graph[nhood_node] && fringe.find(nhood_node) == fringe.end()) {
-                                       fringe.insert(nhood_node);
+                       std::shared_ptr<NeighbourNodes> currNhood = graph[currNode];
+                       for (Node nhoodNode : *currNhood) {
+                               if (graph[nhoodNode] && fringe.find(nhoodNode) == fringe.end()) {
+                                       fringe.insert(nhoodNode);
                                }
                        }
-                       graph[curr_node].reset();  // removing current node
+                       graph[currNode].reset();  // removing current node
                }
        }
        return ccs;
index 47b5e37a515cbbc1bcd45f4e7da660a3cf927937..ed9ea6f5586826f6cb4a3aa0c962c11583c47528 100644 (file)
@@ -24,7 +24,7 @@
 #include "debug_utils.h"
 
 #ifdef TIZEN_ENGINEER_MODE
-#define LOCATION_CREATE_TABLE_COLUMNS \
+#define __LOCATION_CREATE_TABLE_COLUMNS \
        LOCATION_COLUMN_LATITUDE " REAL NOT NULL, "\
        LOCATION_COLUMN_LONGITUDE " REAL NOT NULL, "\
        LOCATION_COLUMN_ACCURACY " REAL, "\
        LOCATION_COLUMN_TIMESTAMP_HUMAN " TEXT, "\
        LOCATION_COLUMN_METHOD " INTEGER "
 #else /* TIZEN_ENGINEER_MODE */
-#define LOCATION_CREATE_TABLE_COLUMNS \
+#define __LOCATION_CREATE_TABLE_COLUMNS \
        LOCATION_COLUMN_LATITUDE " REAL NOT NULL, "\
        LOCATION_COLUMN_LONGITUDE " REAL NOT NULL, "\
        LOCATION_COLUMN_ACCURACY " REAL, "\
        LOCATION_COLUMN_TIMESTAMP " timestamp NOT NULL "
 #endif /* TIZEN_ENGINEER_MODE */
 
-#define _LOCATION_ERROR_LOG(error) { \
+#define __LOCATION_ERROR_LOG(error) { \
        if (error != LOCATIONS_ERROR_NONE) { \
                _E("ERROR == %s", __locationError2Str(error)); \
        } else { \
@@ -47,9 +47,9 @@
        } \
 }
 
-void ctx::LocationLogger::__locationServiceStateChangedCb(location_service_state_e state, void *user_data)
+void ctx::LocationLogger::__locationServiceStateChangedCb(location_service_state_e state, void *userData)
 {
-       ctx::LocationLogger* locationLogger = (ctx::LocationLogger *)user_data;
+       ctx::LocationLogger* locationLogger = (ctx::LocationLogger *)userData;
        locationLogger->__locationServiceState = state;
        if (state == LOCATIONS_SERVICE_ENABLED) {
                _D("LOCATIONS_SERVICE_ENABLED");
@@ -73,9 +73,9 @@ void ctx::LocationLogger::__locationServiceStateChangedCb(location_service_state
        }
 }
 
-void ctx::LocationLogger::__locationSettingChangedCb(location_method_e method, bool enable, void *user_data)
+void ctx::LocationLogger::__locationSettingChangedCb(location_method_e method, bool enable, void *userData)
 {
-       ctx::LocationLogger* locationLogger = (ctx::LocationLogger *)user_data;
+       ctx::LocationLogger* locationLogger = (ctx::LocationLogger *)userData;
        locationLogger->__locationMethodState = enable;
        if (method == locationLogger->__locationMethod) {
                if (enable) {
@@ -106,10 +106,10 @@ void ctx::LocationLogger::__locationSettingChangedCb(location_method_e method, b
 }
 
 void ctx::LocationLogger::__positionUpdatedCb(double latitude, double longitude,
-               double altitude, time_t timestamp, void *user_data)
+               double altitude, time_t timestamp, void *userData)
 {
        _D("");
-       ctx::LocationLogger* locationLogger = (ctx::LocationLogger *)user_data;
+       ctx::LocationLogger* locationLogger = (ctx::LocationLogger *)userData;
        double horizontal = locationLogger->__locationManagerGetHorizontalAccuracy();
 #ifdef TIZEN_ENGINEER_MODE
        ctx::LocationEvent location(latitude, longitude, horizontal, timestamp, LOCATION_METHOD_REQUEST);
@@ -121,10 +121,10 @@ void ctx::LocationLogger::__positionUpdatedCb(double latitude, double longitude,
 }
 
 void ctx::LocationLogger::__locationUpdatedCb(location_error_e error, double latitude, double longitude,
-               double altitude, time_t timestamp, double speed, double direction, double climb, void *user_data)
+               double altitude, time_t timestamp, double speed, double direction, double climb, void *userData)
 {
        _D("");
-       __positionUpdatedCb(latitude, longitude, altitude, timestamp, user_data);
+       __positionUpdatedCb(latitude, longitude, altitude, timestamp, userData);
 }
 
 const char* ctx::LocationLogger::__locationError2Str(int error)
@@ -175,26 +175,26 @@ void ctx::LocationLogger::__log(location_accessibility_state_e state)
 
 int ctx::LocationLogger::__dbCreateTable()
 {
-       bool ret = db_manager::create_table(0, LOCATION_TABLE_NAME, LOCATION_CREATE_TABLE_COLUMNS, NULL, NULL);
+       bool ret = db_manager::create_table(0, LOCATION_TABLE_NAME, __LOCATION_CREATE_TABLE_COLUMNS, NULL, NULL);
        _D("%s -> Table Creation Request", ret ? "SUCCESS" : "FAIL");
        return 0;
 }
 
-int ctx::LocationLogger::__dbInsertLog(LocationEvent location_event)
+int ctx::LocationLogger::__dbInsertLog(LocationEvent locationEvent)
 {
        Json data;
-       data.set(NULL, LOCATION_COLUMN_LATITUDE, location_event.coordinates.latitude);
-       data.set(NULL, LOCATION_COLUMN_LONGITUDE, location_event.coordinates.longitude);
-       data.set(NULL, LOCATION_COLUMN_ACCURACY, location_event.coordinates.accuracy);
-       data.set(NULL, LOCATION_COLUMN_TIMESTAMP, static_cast<int>(location_event.timestamp));
+       data.set(NULL, LOCATION_COLUMN_LATITUDE, locationEvent.coordinates.latitude);
+       data.set(NULL, LOCATION_COLUMN_LONGITUDE, locationEvent.coordinates.longitude);
+       data.set(NULL, LOCATION_COLUMN_ACCURACY, locationEvent.coordinates.accuracy);
+       data.set(NULL, LOCATION_COLUMN_TIMESTAMP, static_cast<int>(locationEvent.timestamp));
 #ifdef TIZEN_ENGINEER_MODE
-       std::string time_human = DebugUtils::humanReadableDateTime(location_event.timestamp, "%F %T", 80);
-       data.set(NULL, LOCATION_COLUMN_TIMESTAMP_HUMAN, time_human);
-       data.set(NULL, LOCATION_COLUMN_METHOD, static_cast<int>(location_event.method));
+       std::string timeHuman = DebugUtils::humanReadableDateTime(locationEvent.timestamp, "%F %T", 80);
+       data.set(NULL, LOCATION_COLUMN_TIMESTAMP_HUMAN, timeHuman);
+       data.set(NULL, LOCATION_COLUMN_METHOD, static_cast<int>(locationEvent.method));
 #endif /* TIZEN_ENGINEER_MODE */
 
-       int64_t row_id;
-       bool ret = db_manager::insert_sync(LOCATION_TABLE_NAME, data, &row_id);
+       int64_t rowId;
+       bool ret = db_manager::insert_sync(LOCATION_TABLE_NAME, data, &rowId);
        _D("%s -> DB: location table insert result", ret ? "SUCCESS" : "FAIL");
        return ret;
 }
@@ -243,46 +243,46 @@ ctx::LocationLogger::~LocationLogger()
 void ctx::LocationLogger::__locationManagerCreate()
 {
        int ret = location_manager_create(__locationMethod, &__locationManager);
-       _LOCATION_ERROR_LOG(ret);
+       __LOCATION_ERROR_LOG(ret);
 }
 
 void ctx::LocationLogger::__locationManagerDestroy()
 {
        int ret = location_manager_destroy(__locationManager);
-       _LOCATION_ERROR_LOG(ret);
+       __LOCATION_ERROR_LOG(ret);
 }
 
 void ctx::LocationLogger::__locationManagerSetServiceStateChangedCb()
 {
        int ret = location_manager_set_service_state_changed_cb(__locationManager, __locationServiceStateChangedCb, this);
-       _LOCATION_ERROR_LOG(ret);
+       __LOCATION_ERROR_LOG(ret);
 }
 
 void ctx::LocationLogger::__locationManagerUnsetServiceStateChangedCb()
 {
        int ret = location_manager_unset_service_state_changed_cb(__locationManager);
-       _LOCATION_ERROR_LOG(ret);
+       __LOCATION_ERROR_LOG(ret);
 }
 
 void ctx::LocationLogger::__locationManagerStart()
 {
        int ret = location_manager_start(__locationManager);
-       _LOCATION_ERROR_LOG(ret);
+       __LOCATION_ERROR_LOG(ret);
        __startServiceTimerStart();
 }
 
 void ctx::LocationLogger::__locationManagerStop()
 {
        int ret = location_manager_stop(__locationManager);
-       _LOCATION_ERROR_LOG(ret);
+       __LOCATION_ERROR_LOG(ret);
 }
 
 double ctx::LocationLogger::__locationManagerGetHorizontalAccuracy()
 {
-       location_accuracy_level_e accuracy_level;
+       location_accuracy_level_e accuracyLevel;
        double horizontal, vertical;
-       int ret = location_manager_get_accuracy(__locationManager, &accuracy_level, &horizontal, &vertical);
-       _LOCATION_ERROR_LOG(ret);
+       int ret = location_manager_get_accuracy(__locationManager, &accuracyLevel, &horizontal, &vertical);
+       __LOCATION_ERROR_LOG(ret);
        return horizontal;
 }
 
@@ -290,20 +290,20 @@ location_accessibility_state_e ctx::LocationLogger::__locationManagerGetAccessib
 {
        location_accessibility_state_e state;
        int ret = location_manager_get_accessibility_state(&state);
-       _LOCATION_ERROR_LOG(ret);
+       __LOCATION_ERROR_LOG(ret);
        return state;
 }
 
 void ctx::LocationLogger::__locationManagerSetSettingChangedCb()
 {
        int ret = location_manager_set_setting_changed_cb(__locationMethod, __locationSettingChangedCb, this);
-       _LOCATION_ERROR_LOG(ret);
+       __LOCATION_ERROR_LOG(ret);
 }
 
 void ctx::LocationLogger::__locationManagerUnsetSettingChangedCb()
 {
        int ret = location_manager_unset_setting_changed_cb(__locationMethod);
-       _LOCATION_ERROR_LOG(ret);
+       __LOCATION_ERROR_LOG(ret);
 }
 
 bool ctx::LocationLogger::__locationManagerRequestSingleLocation()
@@ -321,7 +321,7 @@ bool ctx::LocationLogger::__locationManagerRequestSingleLocation()
                        LOCATION_LOGGER_MAX_LOCATION_ATTEMPTS,
                        __locationCount,
                        LOCATION_LOGGER_MAX_LOCATION_COUNT);
-       _LOCATION_ERROR_LOG(ret);
+       __LOCATION_ERROR_LOG(ret);
        __activeRequestAttempts++;
        __activeAttempts++;
        __allAttempts++;
@@ -350,7 +350,7 @@ bool ctx::LocationLogger::__locationManagerGetLocation()
                        LOCATION_LOGGER_MAX_LOCATION_ATTEMPTS,
                        __locationCount,
                        LOCATION_LOGGER_MAX_LOCATION_COUNT);
-       _LOCATION_ERROR_LOG(ret);
+       __LOCATION_ERROR_LOG(ret);
        __activeAttempts++;
        __allAttempts++;
        if (ret == LOCATIONS_ERROR_NONE) {
@@ -384,7 +384,7 @@ void ctx::LocationLogger::__locationManagerGetLastLocation()
                        LOCATION_LOGGER_MAX_LOCATION_ATTEMPTS,
                        __locationCount,
                        LOCATION_LOGGER_MAX_LOCATION_COUNT);
-       _LOCATION_ERROR_LOG(ret);
+       __LOCATION_ERROR_LOG(ret);
        __allAttempts++;
        if (ret == LOCATIONS_ERROR_NONE) {
 #ifdef TIZEN_ENGINEER_MODE
@@ -400,7 +400,7 @@ bool ctx::LocationLogger::__locationManagerIsEnabledMethod(location_method_e met
 {
        bool enable;
        int ret = location_manager_is_enabled_method(method, &enable);
-       _LOCATION_ERROR_LOG(ret);
+       __LOCATION_ERROR_LOG(ret);
        return enable;
 }
 
@@ -425,19 +425,19 @@ bool ctx::LocationLogger::__checkActiveRequestLimits()
 void ctx::LocationLogger::__locationRequest()
 {
        _D("");
-       bool request_single_location_ret = false;
-       bool get_location_ret = false;
+       bool requestSingleLocationRet = false;
+       bool getLocationRet = false;
        if (__checkGeneralLimits() && __checkActiveLimits() && __checkActiveRequestLimits()) {
-               request_single_location_ret = __locationManagerRequestSingleLocation();
+               requestSingleLocationRet = __locationManagerRequestSingleLocation();
        }
-       if (__checkGeneralLimits() && __checkActiveLimits() && !request_single_location_ret) {
-               get_location_ret = __locationManagerGetLocation();
+       if (__checkGeneralLimits() && __checkActiveLimits() && !requestSingleLocationRet) {
+               getLocationRet = __locationManagerGetLocation();
        }
-       if (__checkGeneralLimits() && !request_single_location_ret && !get_location_ret
+       if (__checkGeneralLimits() && !requestSingleLocationRet && !getLocationRet
                        && __activeAttempts >= LOCATION_LOGGER_MAX_ACTIVE_LOCATION_ATTEMPTS) {
                __locationManagerGetLastLocation();
        }
-       if (!request_single_location_ret) {
+       if (!requestSingleLocationRet) {
                __locationManagerStop();
                __setNextTimer();
        }
@@ -477,15 +477,15 @@ void ctx::LocationLogger::__onActiveLocationSucceeded()
        __activeLocationSucceeded = true;
 }
 
-void ctx::LocationLogger::__broadcast(ctx::LocationEvent location_event)
+void ctx::LocationLogger::__broadcast(ctx::LocationEvent locationEvent)
 {
        _D("");
        __locationCount++;
        if (__listener) {
-               __listener->onNewLocation(location_event);
+               __listener->onNewLocation(locationEvent);
        }
        if (LOCATION_LOGGER_DATABASE) {
-               __dbInsertLog(location_event);
+               __dbInsertLog(locationEvent);
        }
 }
 
@@ -612,4 +612,4 @@ void ctx::LocationLogger::onVisitEnd()
        }
 }
 
-#undef _LOCATION_ERROR_LOG
+#undef __LOCATION_ERROR_LOG
index caa1f216c6b7ba81483c04ddade665a35ef8f8dc..ae4c9bdca9acb2eae517fbe8f8f7ebfcb36fcf5b 100644 (file)
@@ -65,8 +65,7 @@ namespace ctx {
        class LocationLogger : public ITimerListener, public IVisitListener {
 
        public:
-               LocationLogger(ILocationListener *listener = nullptr,
-                               bool testMode = false);
+               LocationLogger(ILocationListener *listener = nullptr, bool testMode = false);
                ~LocationLogger();
 
        private:
@@ -76,7 +75,7 @@ namespace ctx {
 
                /* OUTPUT */
                ILocationListener * const __listener;
-               void __broadcast(LocationEvent location_event);
+               void __broadcast(LocationEvent locationEvent);
 
                /* INTERNAL */
                bool __testMode;
@@ -115,7 +114,7 @@ namespace ctx {
 
                /* DATABASE */
                static int __dbCreateTable();
-               int __dbInsertLog(LocationEvent location_event);
+               int __dbInsertLog(LocationEvent locationEvent);
 
                /* DEBUG */
                static const char* __locationError2Str(int error);
@@ -131,7 +130,7 @@ namespace ctx {
 
                /* LOCATION MANAGER : LOCATION SERVICE STATE */
                location_service_state_e __locationServiceState;
-               static void __locationServiceStateChangedCb(location_service_state_e state, void *user_data);
+               static void __locationServiceStateChangedCb(location_service_state_e state, void *userData);
                void __locationManagerSetServiceStateChangedCb();
                void __locationManagerUnsetServiceStateChangedCb();
 
@@ -139,7 +138,7 @@ namespace ctx {
                location_method_e __locationMethod;
                bool __locationMethodState;
                bool __locationManagerIsEnabledMethod(location_method_e method);
-               static void __locationSettingChangedCb(location_method_e method, bool enable, void *user_data);
+               static void __locationSettingChangedCb(location_method_e method, bool enable, void *userData);
                void __locationManagerSetSettingChangedCb();
                void __locationManagerUnsetSettingChangedCb();
 
@@ -152,10 +151,10 @@ namespace ctx {
 
                /* LOCATION MANAGER : LOCATION : ASYNCHRONOUS */
                static void __positionUpdatedCb(double latitude, double longitude,
-                               double altitude, time_t timestamp, void *user_data);
+                               double altitude, time_t timestamp, void *userData);
                static void __locationUpdatedCb(location_error_e error, double latitude,
                                double longitude, double altitude, time_t timestamp, double speed,
-                               double direction, double climb, void *user_data);
+                               double direction, double climb, void *userData);
                bool __locationManagerRequestSingleLocation();
 
        };      /* class LocationLogger */
index f1bdae8deba23347014a7a67fbefad2134b1c4fd..cd7ff78f702a83bbb4d33fb75e32e4307e7440a5 100644 (file)
@@ -18,7 +18,7 @@
 #include <math.h>
 #include <types_internal.h>
 
-ctx::num_t ctx::MahalModel::dist_s(const std::vector<num_t> &v1, const std::vector<num_t> &v2, const std::vector<num_t> &m)
+ctx::num_t ctx::MahalModel::distance(const std::vector<num_t> &v1, const std::vector<num_t> &v2, const std::vector<num_t> &m)
 {
        size_t n = v1.size();
        if (m.size() != n * n) {
@@ -40,7 +40,7 @@ ctx::num_t ctx::MahalModel::dist_s(const std::vector<num_t> &v1, const std::vect
        return sqrt(dist2);
 }
 
-ctx::num_t ctx::MahalModel::dist(const std::vector<ctx::num_t> &v)
+ctx::num_t ctx::MahalModel::distance(const std::vector<ctx::num_t> &v)
 {
-       return dist_s(v, __mean, __sigma);
+       return distance(v, __mean, __sigma);
 }
index 34093f2c27938f54d820058b6c386d3d0f4da59b..9e733c734b34e9d3335ee110216b378d352ebe40 100644 (file)
@@ -32,11 +32,11 @@ namespace ctx {
                std::vector<num_t> __sigma; // represents square matrix row-wise
 
        public:
-               static num_t dist_s(const std::vector<num_t> &v1, const std::vector<num_t> &v2, const std::vector<num_t> &m);
+               static num_t distance(const std::vector<num_t> &v1, const std::vector<num_t> &v2, const std::vector<num_t> &m);
                MahalModel(std::vector<num_t> mean, std::vector<num_t> sigma) :
                        __mean(mean),
                        __sigma(sigma) { }
-               num_t dist(const std::vector<num_t> &v);
+               num_t distance(const std::vector<num_t> &v);
 
        };      /* class MahalModel */
 
index 685f138a248ac3e2fa16f958d1c1d00d5a438b0c..f71fe2cfc6dda02ecdf06c9afcd5b5ef937c9246 100644 (file)
 #include <algorithm>
 #include <types_internal.h>
 
-void ctx::PlaceCateger::reduceOutliers(ctx::visits_t &visits)
+void ctx::PlaceCateger::reduceOutliers(ctx::Visits &visits)
 {
        int size = visits.size();
        visits.erase(std::remove_if(
                                        visits.begin(),
                                        visits.end(),
-                                       [](Visit v) {
+                                       [](Visit v)->bool {
                                                return v.categs[PLACE_CATEG_ID_HOME] < PLACES_CATEGER_MIN_VISITS_SCORE
                                                                && v.categs[PLACE_CATEG_ID_WORK] < PLACES_CATEGER_MIN_VISITS_SCORE
                                                                && v.categs[PLACE_CATEG_ID_OTHER] < PLACES_CATEGER_MIN_VISITS_SCORE;
                                        }),
                                visits.end());
-       int new_size = visits.size();
-       if (size != new_size) {
-               _D("Visits number from %d to %d (visits min scores checking)", size, new_size);
+       int newSize = visits.size();
+       if (size != newSize) {
+               _D("Visits number from %d to %d (visits min scores checking)", size, newSize);
        }
 }
 
 /*
  * Change category if home or work has to few visits
  */
-bool ctx::PlaceCateger::__reduceCategory(const PlaceCategId &categ, const ctx::visits_t &visits)
+bool ctx::PlaceCateger::__reduceCategory(const PlaceCategId &categId, const ctx::Visits &visits)
 {
-       return (categ == PLACE_CATEG_ID_HOME && visits.size() < PLACES_CATEGER_MIN_VISITS_PER_HOME)
-               || (categ == PLACE_CATEG_ID_WORK && visits.size() < PLACES_CATEGER_MIN_VISITS_PER_WORK);
+       return (categId == PLACE_CATEG_ID_HOME && visits.size() < PLACES_CATEGER_MIN_VISITS_PER_HOME)
+               || (categId == PLACE_CATEG_ID_WORK && visits.size() < PLACES_CATEGER_MIN_VISITS_PER_WORK);
 }
 
-void ctx::PlaceCateger::categorize(ctx::visits_t &visits, ctx::Place &place)
+void ctx::PlaceCateger::categorize(ctx::Visits &visits, ctx::Place &place)
 {
        reduceOutliers(visits);
 
-       place.categ_id = PLACE_CATEG_ID_NONE;
-       place.categ_confidence = 0.0;
+       place.categId = PLACE_CATEG_ID_NONE;
+       place.categConfidence = 0.0;
 
        if (!visits.empty()) {
-               const std::vector<PlaceCategId> categ_ids = {
+               const std::vector<PlaceCategId> categIds = {
                        PLACE_CATEG_ID_HOME,
                        PLACE_CATEG_ID_WORK,
                        PLACE_CATEG_ID_OTHER
                };
-               num_t sum_score = 0.0;
-               num_t max_score = 0.0;
-               for (PlaceCategId categ_id : categ_ids) {
-                       std::vector<num_t> categ_vector = categVectorFromVisits(visits, categ_id);
-                       num_t score = median(categ_vector);
-                       sum_score += score;
-                       if (score > max_score) {
-                               max_score = score;
-                               place.categ_id = categ_id;
+               num_t sumScore = 0.0;
+               num_t maxScore = 0.0;
+               for (PlaceCategId categId : categIds) {
+                       std::vector<num_t> categVector = categVectorFromVisits(visits, categId);
+                       num_t score = median(categVector);
+                       sumScore += score;
+                       if (score > maxScore) {
+                               maxScore = score;
+                               place.categId = categId;
                        }
                }
-               if (sum_score > 0) {
-                       place.categ_confidence = max_score / sum_score;
+               if (sumScore > 0) {
+                       place.categConfidence = maxScore / sumScore;
                }
-               if (__reduceCategory(place.categ_id, visits)) {
-                       place.categ_id = PLACE_CATEG_ID_OTHER;
-                       place.categ_confidence = 0.0;
+               if (__reduceCategory(place.categId, visits)) {
+                       place.categId = PLACE_CATEG_ID_OTHER;
+                       place.categConfidence = 0.0;
                }
        }
 
-       place.name = categId2Name(place.categ_id);
+       place.name = categId2Name(place.categId);
 }
 
-std::vector<ctx::num_t> ctx::PlaceCateger::categVectorFromVisits(const ctx::visits_t &visits, PlaceCategId categ_id)
+std::vector<ctx::num_t> ctx::PlaceCateger::categVectorFromVisits(const ctx::Visits &visits, PlaceCategId categId)
 {
        std::vector<ctx::num_t> vec;
        for (auto &visit : visits) {
-               auto search = visit.categs.find(categ_id);
+               auto search = visit.categs.find(categId);
                if (search != visit.categs.end()) {
                        vec.push_back(search->second);
                }
@@ -97,12 +97,17 @@ std::vector<ctx::num_t> ctx::PlaceCateger::categVectorFromVisits(const ctx::visi
        return vec;
 }
 
-std::string ctx::PlaceCateger::categId2Name(PlaceCategId categ_id) {
-       switch (categ_id) {
-       case PLACE_CATEG_ID_HOME:  return "home";
-       case PLACE_CATEG_ID_WORK:  return "work";
-       case PLACE_CATEG_ID_OTHER: return "other";
-       case PLACE_CATEG_ID_NONE:  return "none";
-       default: return "";
+std::string ctx::PlaceCateger::categId2Name(PlaceCategId categId) {
+       switch (categId) {
+       case PLACE_CATEG_ID_HOME:
+               return "home";
+       case PLACE_CATEG_ID_WORK:
+               return "work";
+       case PLACE_CATEG_ID_OTHER:
+               return "other";
+       case PLACE_CATEG_ID_NONE:
+               return "none";
+       default:
+               return "";
        }
 }
index 05612f39c8789887e9473a3a3715a210608669ed..0d127b17f2ee01d0942e289366ed1fc2217ba38d 100644 (file)
@@ -28,13 +28,13 @@ namespace ctx {
        class PlaceCateger {
 
        private:
-               static bool __reduceCategory(const PlaceCategId &categ, const ctx::visits_t &visits);
+               static bool __reduceCategory(const PlaceCategId &categId, const ctx::Visits &visits);
 
        public:
-               static void reduceOutliers(visits_t &visits); // TODO: move to private
-               static std::vector<ctx::num_t> categVectorFromVisits(const ctx::visits_t &visits, PlaceCategId categ_id); // TODO: move to private
-               static void categorize(ctx::visits_t &visits, ctx::Place &place);
-               static std::string categId2Name(PlaceCategId categ_id); // TODO: move to private
+               static void reduceOutliers(Visits &visits); // TODO: move to private
+               static std::vector<ctx::num_t> categVectorFromVisits(const ctx::Visits &visits, PlaceCategId categId); // TODO: move to private
+               static void categorize(ctx::Visits &visits, ctx::Place &place);
+               static std::string categId2Name(PlaceCategId categId); // TODO: move to private
 
        };      /* class PlaceCateger */
 
index 40faf67543cbf7ed4b01d8f847dd05d26a2fd94b..88281cfefb1dbaca719f7a0425660a3227e0f30e 100644 (file)
 #include <algorithm>
 #include "user_places_params.h"
 
-#define DELETE_PLACES_QUERY "DELETE FROM " PLACE_TABLE
+#define __DELETE_PLACES_QUERY "DELETE FROM " PLACE_TABLE
 
 #ifdef TIZEN_ENGINEER_MODE
-#define USER_PLACES_FILE "/opt/usr/media/Others/user_places.txt" // TODO: Only for debug purposes -> Remove in final solution
+#define __USER_PLACES_FILE "/opt/usr/media/Others/user_places.txt" // TODO: Only for debug purposes -> Remove in final solution
 #endif /* TIZEN_ENGINEER_MODE */
 
-#define GET_VISITS_QUERY "SELECT "\
+#define __GET_VISITS_QUERY "SELECT "\
        VISIT_COLUMN_END_TIME ", "\
        VISIT_COLUMN_START_TIME ", "\
        VISIT_COLUMN_WIFI_APS ", "\
@@ -49,7 +49,7 @@
        VISIT_COLUMN_CATEG_OTHER \
        " FROM " VISIT_TABLE
 
-#define GET_PLACES_QUERY "SELECT "\
+#define __GET_PLACES_QUERY "SELECT "\
        PLACE_COLUMN_CATEG_ID ", "\
        PLACE_COLUMN_CATEG_CONFIDENCE ", "\
        PLACE_COLUMN_NAME ", "\
@@ -60,7 +60,7 @@
        PLACE_COLUMN_CREATE_DATE \
        " FROM " PLACE_TABLE
 
-#define PLACE_TABLE_COLUMNS \
+#define __PLACE_TABLE_COLUMNS \
        PLACE_COLUMN_CATEG_ID " INTEGER, "\
        PLACE_COLUMN_CATEG_CONFIDENCE " REAL, "\
        PLACE_COLUMN_NAME " TEXT, "\
@@ -76,7 +76,7 @@ bool ctx::PlacesDetector::onTimerExpired(int timerId)
        __dbDeletePlaces();
        __dbDeleteOldVisits();
        std::vector<Json> records = __dbGetVisits();
-       visits_t visits = __visitsFromJsons(records);
+       Visits visits = __visitsFromJsons(records);
        __processVisits(visits);
        return true;
 }
@@ -84,7 +84,7 @@ bool ctx::PlacesDetector::onTimerExpired(int timerId)
 std::vector<ctx::Json> ctx::PlacesDetector::__dbGetVisits()
 {
        std::vector<Json> records;
-       bool ret = db_manager::execute_sync(GET_VISITS_QUERY, &records);
+       bool ret = db_manager::execute_sync(__GET_VISITS_QUERY, &records);
        _D("load visits execute query result: %s", ret ? "SUCCESS" : "FAIL");
        return records;
 }
@@ -92,7 +92,7 @@ std::vector<ctx::Json> ctx::PlacesDetector::__dbGetVisits()
 std::vector<ctx::Json> ctx::PlacesDetector::__dbGetPlaces()
 {
        std::vector<Json> records;
-       bool ret = db_manager::execute_sync(GET_PLACES_QUERY, &records);
+       bool ret = db_manager::execute_sync(__GET_PLACES_QUERY, &records);
        _D("load places execute query result: %s", ret ? "SUCCESS" : "FAIL");
        return records;
 }
@@ -105,9 +105,9 @@ double ctx::PlacesDetector::__doubleValueFromJson(Json &row, const char* key)
        return value;
 }
 
-ctx::categs_t ctx::PlacesDetector::__visitCategsFromJson(Json &row)
+ctx::Categs ctx::PlacesDetector::__visitCategsFromJson(Json &row)
 {
-       categs_t categs;
+       Categs categs;
        categs[PLACE_CATEG_ID_HOME] = __doubleValueFromJson(row, VISIT_COLUMN_CATEG_HOME);
        categs[PLACE_CATEG_ID_WORK] = __doubleValueFromJson(row, VISIT_COLUMN_CATEG_WORK);
        categs[PLACE_CATEG_ID_OTHER] = __doubleValueFromJson(row, VISIT_COLUMN_CATEG_OTHER);
@@ -116,27 +116,27 @@ ctx::categs_t ctx::PlacesDetector::__visitCategsFromJson(Json &row)
 
 ctx::Visit ctx::PlacesDetector::__visitFromJson(Json &row)
 {
-       int start_time;
-       int end_time;
-       std::string mac_set_string;
-       row.get(NULL, VISIT_COLUMN_START_TIME, &start_time);
-       row.get(NULL, VISIT_COLUMN_END_TIME, &end_time);
-       row.get(NULL, VISIT_COLUMN_WIFI_APS, &mac_set_string);
+       int startTime;
+       int endTime;
+       std::string str;
+       row.get(NULL, VISIT_COLUMN_START_TIME, &startTime);
+       row.get(NULL, VISIT_COLUMN_END_TIME, &endTime);
+       row.get(NULL, VISIT_COLUMN_WIFI_APS, &str);
 
-       std::stringstream mac_set_ss;
-       mac_set_ss << mac_set_string;
-       std::shared_ptr<mac_set_t> macSet = std::make_shared<mac_set_t>();
-       mac_set_ss >> *macSet;
+       std::stringstream ss;
+       ss << str;
+       std::shared_ptr<MacSet> macSet = std::make_shared<MacSet>();
+       ss >> *macSet;
 
-       Interval interval(start_time, end_time);
-       categs_t categs = __visitCategsFromJson(row);
+       Interval interval(startTime, endTime);
+       Categs categs = __visitCategsFromJson(row);
 
        Visit visit(interval, macSet, categs);
 
        { // location
-               int location_valid_int;
-               row.get(NULL, VISIT_COLUMN_LOCATION_VALID, &location_valid_int);
-               visit.location_valid = (bool) location_valid_int;
+               int locationValidInt;
+               row.get(NULL, VISIT_COLUMN_LOCATION_VALID, &locationValidInt);
+               visit.locationValid = (bool) locationValidInt;
                row.get(NULL, VISIT_COLUMN_LOCATION_LATITUDE, &(visit.location.latitude));
                row.get(NULL, VISIT_COLUMN_LOCATION_LONGITUDE, &(visit.location.longitude));
        }
@@ -144,9 +144,9 @@ ctx::Visit ctx::PlacesDetector::__visitFromJson(Json &row)
        return visit;
 }
 
-ctx::visits_t ctx::PlacesDetector::__visitsFromJsons(std::vector<Json>& records)
+ctx::Visits ctx::PlacesDetector::__visitsFromJsons(std::vector<Json>& records)
 {
-       visits_t visits;
+       Visits visits;
        _D("db_result: number of all visits: %d", records.size());
 
        for (Json &row : records) {
@@ -161,27 +161,27 @@ std::shared_ptr<ctx::Place> ctx::PlacesDetector::__placeFromJson(Json &row)
 {
        std::shared_ptr<Place> place = std::make_shared<Place>();
        { // category
-               int categ_id;
-               row.get(NULL, PLACE_COLUMN_CATEG_ID, &categ_id);
+               int categId;
+               row.get(NULL, PLACE_COLUMN_CATEG_ID, &categId);
                // This is due to the fact the JSON module API interface doesn't handle enum
-               place->categ_id = static_cast<PlaceCategId>(categ_id);
+               place->categId = static_cast<PlaceCategId>(categId);
        }
        row.get(NULL, PLACE_COLUMN_NAME, &(place->name));
-       row.get(NULL, PLACE_COLUMN_WIFI_APS, &(place->wifi_aps));
+       row.get(NULL, PLACE_COLUMN_WIFI_APS, &(place->wifiAps));
        { // location
-               int location_valid_int;
-               row.get(NULL, PLACE_COLUMN_LOCATION_VALID, &location_valid_int);
-               place->location_valid = (bool) location_valid_int;
+               int locationValidInt;
+               row.get(NULL, PLACE_COLUMN_LOCATION_VALID, &locationValidInt);
+               place->locationValid = (bool) locationValidInt;
                row.get(NULL, PLACE_COLUMN_LOCATION_LATITUDE, &(place->location.latitude));
                row.get(NULL, PLACE_COLUMN_LOCATION_LONGITUDE, &(place->location.longitude));
        }
-       { // create_date
-               int create_date;
-               row.get(NULL, PLACE_COLUMN_CREATE_DATE, &(create_date));
+       { // createDate
+               int createDate;
+               row.get(NULL, PLACE_COLUMN_CREATE_DATE, &(createDate));
                // This is due to the fact the JSON module API interface doesn't handle time_t
-               place->create_date = static_cast<time_t>(create_date);
+               place->createDate = static_cast<time_t>(createDate);
        }
-       _D("db_result: categ_id: %d; place: name: %s; wifi_aps: %s; location_valid: %d; latitude: %lf, longitude: %lf, create_date: %d", place->categ_id, place->name.c_str(), place->wifi_aps.c_str(), place->location_valid, place->location.latitude, place->location.longitude, place->create_date);
+       _D("db_result: categId: %d; place: name: %s; wifiAps: %s; locationValid: %d; latitude: %lf, longitude: %lf, createDate: %d", place->categId, place->name.c_str(), place->wifiAps.c_str(), place->locationValid, place->location.latitude, place->location.longitude, place->createDate);
        return place;
 }
 
@@ -198,25 +198,25 @@ std::vector<std::shared_ptr<ctx::Place>> ctx::PlacesDetector::__placesFromJsons(
        return places;
 }
 
-void ctx::PlacesDetector::reduceOutliers(ctx::visits_t &visits)
+void ctx::PlacesDetector::reduceOutliers(ctx::Visits &visits)
 {
        int size = visits.size();
        visits.erase(std::remove_if(
                                        visits.begin(),
                                        visits.end(),
-                                       [](Visit v) {
+                                       [](Visit v)->bool {
                                                int minutes = (v.interval.end - v.interval.start) / 60;
                                                return (minutes < PLACES_DETECTOR_MIN_VISIT_DURATION_MINUTES)
                                                                || (minutes > PLACES_DETECTOR_MAX_VISIT_DURATION_MINUTES);
                                        }),
                                visits.end());
-       int new_size = visits.size();
-       if (size != new_size) {
-               _D("Visits number from %d to %d (to short and to long reduction)", size, new_size);
+       int newSize = visits.size();
+       if (size != newSize) {
+               _D("Visits number from %d to %d (to short and to long reduction)", size, newSize);
        }
 }
 
-void ctx::PlacesDetector::__processVisits(ctx::visits_t &visits)
+void ctx::PlacesDetector::__processVisits(ctx::Visits &visits)
 {
        reduceOutliers(visits);
 
@@ -224,7 +224,7 @@ void ctx::PlacesDetector::__processVisits(ctx::visits_t &visits)
        auto components = __mergeVisits(visits);
        std::vector<std::shared_ptr<Place>> newDetectedPlaces;
 #ifdef TIZEN_ENGINEER_MODE
-       std::vector<visits_t> places_visits; // TODO: remove from final solution.
+       std::vector<Visits> placesVisits; // TODO: remove from final solution.
 #endif /* TIZEN_ENGINEER_MODE */
        for (std::shared_ptr<graph::Component> component : *components) {
                // Small places outliers reduction
@@ -232,12 +232,12 @@ void ctx::PlacesDetector::__processVisits(ctx::visits_t &visits)
                        continue;
                }
 
-               std::shared_ptr<visits_t> merged = std::make_shared<visits_t>();
+               std::shared_ptr<Visits> merged = std::make_shared<Visits>();
                for (graph::Node i : *component) {
                        merged->push_back(visits[i]);
                }
                std::shared_ptr<Place> place = __placeFromMergedVisits(*merged);
-               if (place->categ_id == PLACE_CATEG_ID_NONE) {
+               if (place->categId == PLACE_CATEG_ID_NONE) {
                        continue;
                }
                newDetectedPlaces.push_back(place);
@@ -247,11 +247,11 @@ void ctx::PlacesDetector::__processVisits(ctx::visits_t &visits)
 
 #ifdef TIZEN_ENGINEER_MODE
                { // TODO: Only for debug -> remove in final solution
-                       visits_t place_visits;
+                       Visits placeVisits;
                        for (graph::Node i : *component) {
-                               place_visits.push_back(visits[i]);
+                               placeVisits.push_back(visits[i]);
                        }
-                       places_visits.push_back(place_visits);
+                       placesVisits.push_back(placeVisits);
                }
 #endif /* TIZEN_ENGINEER_MODE */
        }
@@ -260,12 +260,12 @@ void ctx::PlacesDetector::__processVisits(ctx::visits_t &visits)
 
 #ifdef TIZEN_ENGINEER_MODE
        { // Print to file TODO: Only for debug -> remove in final solution
-               std::ofstream out(USER_PLACES_FILE);
+               std::ofstream out(__USER_PLACES_FILE);
                for (size_t i = 0; i < newDetectedPlaces.size(); i++) {
-                       newDetectedPlaces[i]->print_to_stream(out);
-                       visits_t place_visits = places_visits[i];
-                       for (Visit visit : place_visits) {
-                               visit.print_short_to_stream(out);
+                       newDetectedPlaces[i]->print2Stream(out);
+                       Visits placeVisits = placesVisits[i];
+                       for (Visit visit : placeVisits) {
+                               visit.printShort2Stream(out);
                        }
                }
                out.close();
@@ -277,47 +277,47 @@ void ctx::PlacesDetector::__processVisits(ctx::visits_t &visits)
 /*
  * Replace old places by new ones.
  */
-void ctx::PlacesDetector::__detectedPlacesUpdate(std::vector<std::shared_ptr<Place>> &new_places)
+void ctx::PlacesDetector::__detectedPlacesUpdate(std::vector<std::shared_ptr<Place>> &newPlaces)
 {
        _D("");
        // XXX: In case of thread safety issues use std::mutex to protect places list.
-       __detectedPlaces = new_places;
+       __detectedPlaces = newPlaces;
 }
 
-void ctx::PlacesDetector::__mergeLocation(const visits_t &visits, Place &place)
+void ctx::PlacesDetector::__mergeLocation(const Visits &visits, Place &place)
 {
-       place.location_valid = false;
+       place.locationValid = false;
        std::vector<double> latitudes;
        std::vector<double> longitudes;
        for (const Visit& visit : visits) {
-               if (visit.location_valid) {
+               if (visit.locationValid) {
                        latitudes.push_back(visit.location.latitude);
                        longitudes.push_back(visit.location.longitude);
-                       place.location_valid = true;
+                       place.locationValid = true;
                }
        }
-       if (place.location_valid) {
+       if (place.locationValid) {
                place.location.latitude = median(latitudes);
                place.location.longitude = median(longitudes);
        }
 }
 
-std::shared_ptr<ctx::Place> ctx::PlacesDetector::__placeFromMergedVisits(visits_t &merged_visits)
+std::shared_ptr<ctx::Place> ctx::PlacesDetector::__placeFromMergedVisits(Visits &mergedVisits)
 {
        std::shared_ptr<Place> place = std::make_shared<Place>();
-       place->create_date = std::time(nullptr);
-       std::vector<std::shared_ptr<mac_set_t>> macSets;
-       for (const Visit &visit : merged_visits) {
+       place->createDate = std::time(nullptr);
+       std::vector<std::shared_ptr<MacSet>> macSets;
+       for (const Visit &visit : mergedVisits) {
                macSets.push_back(visit.macSet);
        }
-       std::shared_ptr<mac_set_t> all_macs = mac_sets_union(macSets);
-       std::stringstream all_macs_ss;
-       all_macs_ss << *all_macs;
-       place->wifi_aps = all_macs_ss.str();
+       std::shared_ptr<MacSet> allMacs = macSetsUnion(macSets);
+       std::stringstream ss;
+       ss << *allMacs;
+       place->wifiAps = ss.str();
 
-       __mergeLocation(merged_visits, *place);
+       __mergeLocation(mergedVisits, *place);
 
-       PlaceCateger::categorize(merged_visits, *place);
+       PlaceCateger::categorize(mergedVisits, *place);
 
        return place;
 }
@@ -327,13 +327,13 @@ void ctx::PlacesDetector::reduceOutliers(std::shared_ptr<ctx::graph::Components>
        int size = cc->size();
        cc->erase(std::remove_if(cc->begin(),
                                                         cc->end(),
-                                                        [](std::shared_ptr<graph::Component> &c) {
+                                                        [](std::shared_ptr<graph::Component> &c)->bool {
                                                                 return c->size() < PLACES_DETECTOR_MIN_VISITS_PER_PLACE;
                                                         }),
                          cc->end());
-       int new_size = cc->size();
-       if (size != new_size) {
-               _D("Connected components from %d to %d (min visit per place)", size, new_size);
+       int newSize = cc->size();
+       if (size != newSize) {
+               _D("Connected components from %d to %d (min visit per place)", size, newSize);
        }
 }
 
@@ -364,16 +364,16 @@ std::shared_ptr<ctx::graph::Graph> ctx::PlacesDetector::__graphFromVisits(const
 void ctx::PlacesDetector::__dbDeletePlaces()
 {
        std::vector<Json> records;
-       bool ret = db_manager::execute_sync(DELETE_PLACES_QUERY, &records);
+       bool ret = db_manager::execute_sync(__DELETE_PLACES_QUERY, &records);
        _D("delete places execute query result: %s", ret ? "SUCCESS" : "FAIL");
 }
 
 void ctx::PlacesDetector::__dbDeleteOldVisits()
 {
-       time_t current_time;
-       time(&current_time);
-       time_t threshold_time = current_time - PLACES_DETECTOR_RETENTION_SECONDS;
-       __dbDeleteOlderVisitsThan(threshold_time);
+       time_t currentTime;
+       time(&currentTime);
+       time_t thresholdTime = currentTime - PLACES_DETECTOR_RETENTION_SECONDS;
+       __dbDeleteOlderVisitsThan(thresholdTime);
 }
 
 void ctx::PlacesDetector::__dbDeleteOlderVisitsThan(time_t threshold)
@@ -396,32 +396,32 @@ ctx::PlacesDetector::PlacesDetector(bool testMode) :
        }
        __dbCreateTable();
        std::vector<Json> records = __dbGetPlaces();
-       std::vector<std::shared_ptr<Place>> db_places = __placesFromJsons(records);
-       __detectedPlacesUpdate(db_places);
+       std::vector<std::shared_ptr<Place>> dbPlaces = __placesFromJsons(records);
+       __detectedPlacesUpdate(dbPlaces);
 }
 
 void ctx::PlacesDetector::__dbCreateTable()
 {
-       bool ret = db_manager::create_table(0, PLACE_TABLE, PLACE_TABLE_COLUMNS);
+       bool ret = db_manager::create_table(0, PLACE_TABLE, __PLACE_TABLE_COLUMNS);
        _D("db: place Table Creation Result: %s", ret ? "SUCCESS" : "FAIL");
 }
 
 void ctx::PlacesDetector::__dbInsertPlace(const Place &place)
 {
        Json data;
-       data.set(NULL, PLACE_COLUMN_CATEG_ID, place.categ_id);
-       data.set(NULL, PLACE_COLUMN_CATEG_CONFIDENCE, place.categ_confidence);
+       data.set(NULL, PLACE_COLUMN_CATEG_ID, place.categId);
+       data.set(NULL, PLACE_COLUMN_CATEG_CONFIDENCE, place.categConfidence);
        data.set(NULL, PLACE_COLUMN_NAME, place.name);
 
-       data.set(NULL, PLACE_COLUMN_LOCATION_VALID, place.location_valid);
+       data.set(NULL, PLACE_COLUMN_LOCATION_VALID, place.locationValid);
        data.set(NULL, PLACE_COLUMN_LOCATION_LATITUDE, place.location.latitude);
        data.set(NULL, PLACE_COLUMN_LOCATION_LONGITUDE, place.location.longitude);
 
-       data.set(NULL, PLACE_COLUMN_WIFI_APS, place.wifi_aps);
-       data.set(NULL, PLACE_COLUMN_CREATE_DATE, static_cast<int>(place.create_date));
+       data.set(NULL, PLACE_COLUMN_WIFI_APS, place.wifiAps);
+       data.set(NULL, PLACE_COLUMN_CREATE_DATE, static_cast<int>(place.createDate));
 
-       int64_t row_id;
-       bool ret = db_manager::insert_sync(PLACE_TABLE, data, &row_id);
+       int64_t rowId;
+       bool ret = db_manager::insert_sync(PLACE_TABLE, data, &rowId);
        _D("insert place execute query result: %s", ret ? "SUCCESS" : "FAIL");
 }
 
index 7ad43fbb2359bbb3c3c8148442cf1f682835bd48..510aebebb72e5affe6ff9de2a3e02fc72d6742b8 100644 (file)
@@ -32,9 +32,9 @@ namespace ctx {
                bool __testMode;
 
                double __doubleValueFromJson(Json &row, const char* key);
-               categs_t __visitCategsFromJson(Json &row);
+               Categs __visitCategsFromJson(Json &row);
                Visit __visitFromJson(Json &row);
-               visits_t __visitsFromJsons(std::vector<Json>& records);
+               Visits __visitsFromJsons(std::vector<Json>& records);
                std::shared_ptr<ctx::Place> __placeFromJson(Json &row);
                std::vector<std::shared_ptr<Place>> __placesFromJsons(std::vector<Json>& records);
 
@@ -48,18 +48,18 @@ namespace ctx {
                std::vector<Json> __dbGetPlaces();
                void __dbInsertPlace(const Place &place);
 
-               std::shared_ptr<Place> __placeFromMergedVisits(visits_t &merged_visits);
+               std::shared_ptr<Place> __placeFromMergedVisits(Visits &mergedVisits);
                std::vector<std::shared_ptr<Place>> __detectedPlaces;
-               void __detectedPlacesUpdate(std::vector<std::shared_ptr<Place>> &new_places);
-               void __processVisits(visits_t &visits);
-               static void __mergeLocation(const visits_t &merged_visits, Place &place);
+               void __detectedPlacesUpdate(std::vector<std::shared_ptr<Place>> &newPlaces);
+               void __processVisits(Visits &visits);
+               static void __mergeLocation(const Visits &mergedVisits, Place &place);
                std::shared_ptr<graph::Components> __mergeVisits(const std::vector<Visit> &visits);
 
                bool onTimerExpired(int timerId);
 
        public:
                PlacesDetector(bool testMode = false);
-               static void reduceOutliers(visits_t &visits); // TODO: move to private
+               static void reduceOutliers(Visits &visits); // TODO: move to private
                static void reduceOutliers(std::shared_ptr<graph::Components> &cc); // TODO: move to private
                std::vector<std::shared_ptr<Place>> getPlaces();
 
index c61cb2a818fffbfce2b12177cf510595064c7ab9..5357fa9bd62b30ffea4e0b4695172caa8688d953 100644 (file)
@@ -22,7 +22,7 @@
 #include "../place_recognition_types.h"
 #include "db_mgr.h"
 
-ctx::UserPlaces::UserPlaces(place_recog_mode_e energyMode):
+ctx::UserPlaces::UserPlaces(PlaceRecogMode energyMode):
        __visitDetector(nullptr),
        __placesDetector(nullptr),
        __placesDetectorTimerId(-1)
@@ -114,22 +114,22 @@ ctx::Json ctx::UserPlaces::composeJson(std::vector<std::shared_ptr<Place>> place
 {
        ctx::Json data;
        for (std::shared_ptr<ctx::Place> place : places) {
-               ctx::Json place_j;
-               place_j.set(NULL, PLACE_CATEG_ID, place->categ_id);
-               place_j.set(NULL, PLACE_CATEG_CONFIDENCE, place->categ_confidence);
-               place_j.set(NULL, PLACE_NAME, place->name);
-               if (place->location_valid) {
-                       place_j.set(NULL, PLACE_GEO_LATITUDE, place->location.latitude);
-                       place_j.set(NULL, PLACE_GEO_LONGITUDE, place->location.longitude);
+               ctx::Json placeJson;
+               placeJson.set(NULL, PLACE_CATEG_ID, place->categId);
+               placeJson.set(NULL, PLACE_CATEG_CONFIDENCE, place->categConfidence);
+               placeJson.set(NULL, PLACE_NAME, place->name);
+               if (place->locationValid) {
+                       placeJson.set(NULL, PLACE_GEO_LATITUDE, place->location.latitude);
+                       placeJson.set(NULL, PLACE_GEO_LONGITUDE, place->location.longitude);
                }
-               place_j.set(NULL, PLACE_WIFI_APS, place->wifi_aps);
-               place_j.set(NULL, PLACE_CREATE_DATE, static_cast<int>(place->create_date));
-               data.append(NULL, DATA_READ, place_j);
+               placeJson.set(NULL, PLACE_WIFI_APS, place->wifiAps);
+               placeJson.set(NULL, PLACE_CREATE_DATE, static_cast<int>(place->createDate));
+               data.append(NULL, DATA_READ, placeJson);
        }
        return data;
 }
 
-void ctx::UserPlaces::setMode(place_recog_mode_e energyMode)
+void ctx::UserPlaces::setMode(PlaceRecogMode energyMode)
 {
        if (__visitDetector) {
                __visitDetector->setMode(energyMode);
index d4275cb072d642234413673fb3cf182bcf52555b..1df63887c83947879d564e8019763496f0fc7b89 100644 (file)
@@ -35,10 +35,10 @@ namespace ctx {
                TimerManager __timerManager;
 
        public:
-               UserPlaces(place_recog_mode_e energyMode = PLACE_RECOG_HIGH_ACCURACY_MODE);
+               UserPlaces(PlaceRecogMode energyMode = PLACE_RECOG_HIGH_ACCURACY_MODE);
                ~UserPlaces();
 
-               void setMode(place_recog_mode_e energyMode);
+               void setMode(PlaceRecogMode energyMode);
                std::vector<std::shared_ptr<Place>> getPlaces();
                static Json composeJson(std::vector<std::shared_ptr<Place>> places);
 
index 9fafbc4c7d6ef6bfdca3adf750ddef4e4cc15c97..7efd9481d0d7c568feb22be9dba7eb2d41bfeac9 100644 (file)
@@ -24,8 +24,8 @@
 #include "user_places_params.h"
 #include "debug_utils.h"
 
-#define MAC_STRING_COMPONENTS_SEPARATOR ':'
-#define MAC_SET_STRING_DELIMITER ','
+#define __MAC_STRING_COMPONENTS_SEPARATOR ':'
+#define __MAC_SET_STRING_DELIMITER ','
 
 ctx::Mac::Mac(const std::string& str)
 {
@@ -59,7 +59,7 @@ std::istream& ctx::operator>>(std::istream &input, ctx::Mac &mac)
                        break;
                }
                input >> colon;
-               if (colon != MAC_STRING_COMPONENTS_SEPARATOR) {
+               if (colon != __MAC_STRING_COMPONENTS_SEPARATOR) {
                        throw std::runtime_error("Invalid MAC format");
                }
        }
@@ -77,7 +77,7 @@ std::ostream& ctx::operator<<(std::ostream &output, const ctx::Mac &mac)
                if (i >= Mac::MAC_SIZE) {
                        break;
                }
-               output << MAC_STRING_COMPONENTS_SEPARATOR;
+               output << __MAC_STRING_COMPONENTS_SEPARATOR;
        }
        output << std::dec;
        return output;
@@ -121,7 +121,7 @@ bool ctx::operator<(const Mac &m1, const Mac &m2)
        return false; // they are equal
 }
 
-std::istream& ctx::operator>>(std::istream &input, ctx::mac_set_t &macSet)
+std::istream& ctx::operator>>(std::istream &input, ctx::MacSet &macSet)
 {
        Mac mac;
        char delimeter;
@@ -137,7 +137,7 @@ std::istream& ctx::operator>>(std::istream &input, ctx::mac_set_t &macSet)
                        break;
                }
                delimeter = input.get();
-               if (delimeter != MAC_SET_STRING_DELIMITER) {
+               if (delimeter != __MAC_SET_STRING_DELIMITER) {
                        input.unget();
                        break;
                }
@@ -145,18 +145,18 @@ std::istream& ctx::operator>>(std::istream &input, ctx::mac_set_t &macSet)
        return input;
 }
 
-std::ostream& ctx::operator<<(std::ostream &output, const ctx::mac_set_t &macSet)
+std::ostream& ctx::operator<<(std::ostream &output, const ctx::MacSet &macSet)
 {
-       std::vector<Mac> mac_vec(macSet.size());
-       std::copy(macSet.begin(), macSet.end(), mac_vec.begin());
-       std::sort(mac_vec.begin(), mac_vec.end());
+       std::vector<Mac> macVec(macSet.size());
+       std::copy(macSet.begin(), macSet.end(), macVec.begin());
+       std::sort(macVec.begin(), macVec.end());
 
        bool first = true;
-       for (auto &mac: mac_vec) {
+       for (auto &mac: macVec) {
                if (first) {
                        first = false;
                } else {
-                       output << MAC_SET_STRING_DELIMITER;
+                       output << __MAC_SET_STRING_DELIMITER;
                }
                output << mac;
        }
@@ -182,13 +182,13 @@ void ctx::LocationEvent::log()
 #endif /* TIZEN_ENGINEER_MODE */
 }
 
-void ctx::Visit::set_location(Location location_)
+void ctx::Visit::setLocation(Location location_)
 {
-       location_valid = true;
+       locationValid = true;
        location = location_;
 }
 
-void ctx::Visit::print_short_to_stream(std::ostream &out) const
+void ctx::Visit::printShort2Stream(std::ostream &out) const
 {
        // print only valid visits
        if (interval.end != 0) {
@@ -207,13 +207,13 @@ bool ctx::operator==(const ctx::Visit &v1, const ctx::Visit &v2)
                        && v1.location.latitude == v2.location.latitude
                        && v1.location.longitude == v2.location.longitude
                        && v1.location.accuracy == v2.location.accuracy
-                       && v1.location_valid == v2.location_valid
+                       && v1.locationValid == v2.locationValid
                        && v1.macSet == v2.macSet;
 }
 
-ctx::mac_set_t ctx::mac_set_from_string(const std::string &str)
+ctx::MacSet ctx::macSetFromString(const std::string &str)
 {
-       mac_set_t macSet;
+       MacSet macSet;
        std::stringstream ss;
        ss << str;
        ss >> macSet;
@@ -225,22 +225,22 @@ bool ctx::operator>(const Mac &m1, const Mac &m2)
        return m2 < m1;
 }
 
-std::shared_ptr<ctx::mac_set_t> ctx::mac_set_from_mac_counts(const mac_counts_t &mac_counts)
+std::shared_ptr<ctx::MacSet> ctx::macSetFromMacs2Counts(const Macs2Counts &macs2Counts)
 {
-       std::shared_ptr<mac_set_t> macSet(std::make_shared<mac_set_t>());
-       for (auto &c: mac_counts) {
-               macSet->insert(c.first);
+       std::shared_ptr<MacSet> macSet(std::make_shared<MacSet>());
+       for (auto &macCount: macs2Counts) {
+               macSet->insert(macCount.first);
        }
        return macSet;
 }
 
-std::shared_ptr<ctx::mac_set_t> ctx::mac_sets_union(const std::vector<std::shared_ptr<mac_set_t>> &macSets)
+std::shared_ptr<ctx::MacSet> ctx::macSetsUnion(const std::vector<std::shared_ptr<MacSet>> &macSets)
 {
-       std::shared_ptr<mac_set_t> union_set = std::make_shared<mac_set_t>();
-       for (std::shared_ptr<mac_set_t> macSet : macSets) {
-               union_set->insert(macSet->begin(), macSet->end());
+       std::shared_ptr<MacSet> unionSet = std::make_shared<MacSet>();
+       for (std::shared_ptr<MacSet> macSet : macSets) {
+               unionSet->insert(macSet->begin(), macSet->end());
        }
-       return union_set;
+       return unionSet;
 }
 
 ctx::Interval::Interval(time_t start_, time_t end_) : start(start_), end(end_) {
@@ -249,14 +249,14 @@ ctx::Interval::Interval(time_t start_, time_t end_) : start(start_), end(end_) {
        }
 }
 
-void ctx::Place::print_to_stream(std::ostream &out) const
+void ctx::Place::print2Stream(std::ostream &out) const
 {
        out << "PLACE:" << std::endl;
        out << "__CATEGORY: " << name << std::endl;
-       if (location_valid) {
+       if (locationValid) {
                out << "__LOCATION: lat=" << std::setprecision(GEO_LOCATION_PRECISION + 2) << location.latitude;
                out << ", lon=" << location.longitude << std::setprecision(5) << std::endl;
        }
-       out << "__WIFI:" << wifi_aps << std::endl;
-       out << "__CREATE_DATE: " << DebugUtils::humanReadableDateTime(create_date, "%F %T", 80) << std::endl;
+       out << "__WIFI:" << wifiAps << std::endl;
+       out << "__CREATE_DATE: " << DebugUtils::humanReadableDateTime(createDate, "%F %T", 80) << std::endl;
 }
index a19c015fe8be29f6add2c07e91efb4a73cfc33b2..cdf7be41b3fad5f6c1524ab122f98ddc81925bcf 100644 (file)
@@ -78,22 +78,22 @@ namespace ctx {
        typedef float share_t;
        typedef int count_t;
 
-       typedef std::unordered_map<ctx::Mac, ctx::count_t> mac_counts_t;
-       typedef std::unordered_map<ctx::Mac, ctx::share_t> mac_shares_t;
+       typedef std::unordered_map<ctx::Mac, ctx::count_t> Macs2Counts;
+       typedef std::unordered_map<ctx::Mac, ctx::share_t> Macs2Shares;
 
-       typedef std::unordered_set<ctx::Mac> mac_set_t;
+       typedef std::unordered_set<ctx::Mac> MacSet;
 
-       std::istream &operator>>(std::istream &input, ctx::mac_set_t &macSet);
-       std::ostream &operator<<(std::ostream &output, const ctx::mac_set_t &macSet);
-       ctx::mac_set_t mac_set_from_string(const std::string &str);
+       std::istream &operator>>(std::istream &input, ctx::MacSet &macSet);
+       std::ostream &operator<<(std::ostream &output, const ctx::MacSet &macSet);
+       ctx::MacSet macSetFromString(const std::string &str);
 
-       std::shared_ptr<mac_set_t> mac_sets_union(const std::vector<std::shared_ptr<mac_set_t>> &macSets);
+       std::shared_ptr<MacSet> macSetsUnion(const std::vector<std::shared_ptr<MacSet>> &macSets);
 
        struct Interval {
                time_t start;
                time_t end;
 
-               Interval(time_t start_, time_t end_);
+               Interval(time_t start, time_t end);
        };
 
 }      /* namespace ctx */
@@ -116,7 +116,7 @@ namespace ctx {
        struct Frame {
                Interval interval;
                count_t numberOfTimestamps;
-               mac_counts_t macCountsMap;
+               Macs2Counts macs2Counts;
 
                Frame(Interval interval_) : interval(interval_), numberOfTimestamps(0) {};
        };
@@ -131,7 +131,7 @@ namespace ctx {
                MacEvent(time_t timestamp_, Mac mac_) : timestamp(timestamp_), mac(mac_) {}
        };
 
-       typedef std::map<int, num_t> categs_t; // scores of categories
+       typedef std::map<int, num_t> Categs; // scores of categories
 
        struct Location {
                double latitude;
@@ -161,11 +161,13 @@ namespace ctx {
 #ifdef TIZEN_ENGINEER_MODE
                LocationSource method;
 
-               LocationEvent(double latitude_, double longitude_, double accuracy_, time_t timestamp_, LocationSource method_)
-                       : coordinates(latitude_, longitude_, accuracy_), timestamp(timestamp_), method(method_) {}
+               LocationEvent(double latitude_, double longitude_, double accuracy_, time_t timestamp_, LocationSource method_) :
+                       coordinates(latitude_, longitude_, accuracy_),
+                       timestamp(timestamp_), method(method_) {}
 #else /* TIZEN_ENGINEER_MODE */
-               LocationEvent(double latitude_, double longitude_, double accuracy_, time_t timestamp_)
-                       : coordinates(latitude_, longitude_, accuracy_), timestamp(timestamp_) {}
+               LocationEvent(double latitude_, double longitude_, double accuracy_, time_t timestamp_) :
+                       coordinates(latitude_, longitude_, accuracy_),
+                       timestamp(timestamp_) {}
 #endif /* TIZEN_ENGINEER_MODE */
 
                void log();
@@ -174,41 +176,41 @@ namespace ctx {
 
        struct Visit {
                Interval interval;
-               std::shared_ptr<mac_set_t> macSet;
-               categs_t categs;
-               bool location_valid;
-               Location location; // makes sense if location_valid == true;
+               std::shared_ptr<MacSet> macSet;
+               Categs categs;
+               bool locationValid;
+               Location location; // makes sense if locationValid == true;
 
-               Visit(Interval interval_, std::shared_ptr<mac_set_t> macSet_ = std::make_shared<mac_set_t>(), categs_t categs_ = categs_t()) :
+               Visit(Interval interval_, std::shared_ptr<MacSet> macSet_ = std::make_shared<MacSet>(), Categs categs_ = Categs()) :
                        interval(interval_),
                        macSet(macSet_),
                        categs(categs_),
-                       location_valid(false) {}
-               void set_location(Location location);
-               void print_short_to_stream(std::ostream &out) const;
+                       locationValid(false) {}
+               void setLocation(Location location);
+               void printShort2Stream(std::ostream &out) const;
 
        };      /* struct Visit */
 
        bool operator==(const Visit &v1, const Visit &v2);
-       typedef std::vector<Visit> visits_t;
-       typedef std::vector<MacEvent> mac_events; // used to store current interval logs
+       typedef std::vector<Visit> Visits;
+       typedef std::vector<MacEvent> MacEvents; // used to store current interval logs
 
-       std::shared_ptr<mac_set_t> mac_set_from_mac_counts(const mac_counts_t &macCountsMap);
+       std::shared_ptr<MacSet> macSetFromMacs2Counts(const Macs2Counts &macs2Counts);
 
        typedef float confidence_t;
 
        class Place {
 
        public:
-               PlaceCategId categ_id; // category of a place (work/home/other)
-               confidence_t categ_confidence; // confidence of the above category - between [0,1]
+               PlaceCategId categId; // category of a place (work/home/other)
+               confidence_t categConfidence; // confidence of the above category - between [0,1]
                std::string name; // for now: "work"/"home"/"other"
-               bool location_valid;
-               Location location; // makes sense if location_valid == true;
-               std::string wifi_aps; // WiFi APs MAC addresses separated by ","
-               time_t create_date; // The last update time of this place
+               bool locationValid;
+               Location location; // makes sense if locationValid == true;
+               std::string wifiAps; // WiFi APs MAC addresses separated by ","
+               time_t createDate; // The last update time of this place
 
-               void print_to_stream(std::ostream &out) const;
+               void print2Stream(std::ostream &out) const;
 
        };      /* class Place */
 
index c09dd0195917f36e2cec89c485a184814d8fc480..7c6ab7de2962424b571261ff12683a34306ae6e8 100644 (file)
@@ -314,12 +314,12 @@ ctx::TimeFeatures ctx::VisitCateger::timeFeatures(const time_t &time)
        };
 }
 
-int ctx::VisitCateger::weeksScope(const TimeFeatures &start_f, const Interval &interval)
+int ctx::VisitCateger::weeksScope(const TimeFeatures &startF, const Interval &interval)
 {
-       int duration_minutes = (interval.end - interval.start) / 60;
-       int scope_minutes = start_f.minutesSinceBeginingOfTheWeek + duration_minutes;
-       int weeksScope = scope_minutes / MINUTES_IN_WEEK;
-       if (scope_minutes % MINUTES_IN_WEEK > 0) {
+       int durationMinutes = (interval.end - interval.start) / 60;
+       int scopeMinutes = startF.minutesSinceBeginingOfTheWeek + durationMinutes;
+       int weeksScope = scopeMinutes / __MINUTES_IN_WEEK;
+       if (scopeMinutes % __MINUTES_IN_WEEK > 0) {
                weeksScope++;
        }
        return weeksScope;
@@ -327,10 +327,10 @@ int ctx::VisitCateger::weeksScope(const TimeFeatures &start_f, const Interval &i
 
 ctx::num_t ctx::VisitCateger::__sum(const std::vector<num_t> model, const size_t &from, const size_t &to)
 {
-       size_t to_secure = to;
+       size_t toSecure = to;
        if (to >= model.size()) {
                _E("'to' exceeds model size");
-               to_secure = model.size() - 1;
+               toSecure = model.size() - 1;
        }
 
        if (from > to) {
@@ -338,7 +338,7 @@ ctx::num_t ctx::VisitCateger::__sum(const std::vector<num_t> model, const size_t
        }
 
        num_t result = 0.0;
-       for (size_t i = from; i <= to_secure; i++) {
+       for (size_t i = from; i <= toSecure; i++) {
                result += model[i];
        }
 
@@ -346,20 +346,20 @@ ctx::num_t ctx::VisitCateger::__sum(const std::vector<num_t> model, const size_t
 }
 
 ctx::num_t ctx::VisitCateger::__weekModelMeanValue(PlaceCategId categ, const Interval &interval,
-               const TimeFeatures &start_f, const TimeFeatures &end_f)
+               const TimeFeatures &startF, const TimeFeatures &endF)
 {
        num_t ret = 0.0;
        int minutes = 0;
-       int ws = weeksScope(start_f, interval);
+       int ws = weeksScope(startF, interval);
        for (int week = 1; week <= ws; week++) {
-               size_t start_index = (week == 1)
-                               ? start_f.minutesSinceBeginingOfTheWeek
+               size_t startIndex = (week == 1)
+                               ? startF.minutesSinceBeginingOfTheWeek
                                : 0;
-               size_t end_index = (week == ws)
-                               ? end_f.minutesSinceBeginingOfTheWeek
-                               : MINUTES_IN_WEEK - 1;
-               ret += __sum(prob_features::weekModel[categ], start_index, end_index);
-               minutes += end_index - start_index + 1;
+               size_t endIndex = (week == ws)
+                               ? endF.minutesSinceBeginingOfTheWeek
+                               : __MINUTES_IN_WEEK - 1;
+               ret += __sum(prob_features::weekModel[categ], startIndex, endIndex);
+               minutes += endIndex - startIndex + 1;
        }
        if (minutes > 0) {
                return ret / minutes;
@@ -367,12 +367,11 @@ ctx::num_t ctx::VisitCateger::__weekModelMeanValue(PlaceCategId categ, const Int
        return ret;
 }
 
-ctx::categs_t ctx::VisitCateger::weekModelFeatures(const Interval &interval, const TimeFeatures &start_f,
-               const TimeFeatures &end_f)
+ctx::Categs ctx::VisitCateger::weekModelFeatures(const Interval &interval, const TimeFeatures &startF, const TimeFeatures &endF)
 {
-       ctx::categs_t categs;
+       ctx::Categs categs;
        for (const auto &item : prob_features::weekModel) {
-               categs[item.first] = __weekModelMeanValue(item.first, interval, start_f,        end_f);
+               categs[item.first] = __weekModelMeanValue(item.first, interval, startF, endF);
        }
        _D("categs: H=%.12f, W=%.12f, O=%.12f",
                        categs[PLACE_CATEG_ID_HOME],
@@ -381,20 +380,20 @@ ctx::categs_t ctx::VisitCateger::weekModelFeatures(const Interval &interval, con
        return categs;
 }
 
-std::vector<ctx::num_t> ctx::VisitCateger::intervalFeatures(const Interval &interval)
+ctx::IntervalFeatures ctx::VisitCateger::intervalFeatures(const Interval &interval)
 {
-       num_t duration_minutes = 1.0 * (interval.end - interval.start) / 60;
-       TimeFeatures start_features = timeFeatures(interval.start);
-       TimeFeatures end_features = timeFeatures(interval.end);
-       categs_t week_features = weekModelFeatures(interval, start_features, end_features);
+       num_t durationMinutes = 1.0 * (interval.end - interval.start) / 60;
+       TimeFeatures startFeatures = timeFeatures(interval.start);
+       TimeFeatures endFeatures = timeFeatures(interval.end);
+       Categs weekFeatures = weekModelFeatures(interval, startFeatures, endFeatures);
        return {
-               duration_minutes,
-               (num_t) start_features.minutesSinceMidnight,
-               (num_t) end_features.minutesSinceMidnight,
-               (num_t) start_features.weekday,
-               week_features[PLACE_CATEG_ID_HOME],
-               week_features[PLACE_CATEG_ID_WORK],
-               week_features[PLACE_CATEG_ID_OTHER]
+               durationMinutes,
+               (num_t) startFeatures.minutesSinceMidnight,
+               (num_t) endFeatures.minutesSinceMidnight,
+               (num_t) startFeatures.weekday,
+               weekFeatures[PLACE_CATEG_ID_HOME],
+               weekFeatures[PLACE_CATEG_ID_WORK],
+               weekFeatures[PLACE_CATEG_ID_OTHER]
        };
 }
 
@@ -409,15 +408,15 @@ void ctx::VisitCateger::__normalize(std::vector<ctx::num_t> &features)
 
 void ctx::VisitCateger::categorize(ctx::Visit &visit)
 {
-       std::vector<ctx::num_t> features = intervalFeatures(visit.interval);
+       IntervalFeatures features = intervalFeatures(visit.interval);
        __normalize(features);
 
-       for (auto &model_pair : __models) {
-               int categ_i = model_pair.first;
-               MahalModel model = model_pair.second;
+       for (auto &modelPair : __models) {
+               int categId = modelPair.first;
+               MahalModel model = modelPair.second;
 
-               num_t mahal_dist = model.dist(features);
-               num_t prob = 1 - __chiApprox.value(mahal_dist); // sth like probability but not exactly
-               visit.categs[categ_i] = prob;
+               num_t distance = model.distance(features);
+               num_t probability = 1 - __chiApprox.value(distance); // sth like probability but not exactly
+               visit.categs[categId] = probability;
        }
 }
index d7888bbdafeb64844ec486ed67cb047a719f6782..b9d4940922f5ddcc9731592c91f2e59c29312e9f 100644 (file)
@@ -31,19 +31,21 @@ namespace ctx {
            bool weekend;
        };
 
+       typedef std::vector<num_t> IntervalFeatures;
+
        /*
         * visit categorizer class
         */
        class VisitCateger {
 
        private:
-               const static int MINUTES_IN_WEEK = 60 * 24 * 7;
-               const static std::map<int, MahalModel> __models;
-               const static std::vector<num_t> __featuresMean;
-               const static std::vector<num_t> __featuresStd;
+               static const int __MINUTES_IN_WEEK = 60 * 24 * 7;
+               static const std::map<int, MahalModel> __models;
+               static const std::vector<num_t> __featuresMean;
+               static const std::vector<num_t> __featuresStd;
                static num_t __sum(const std::vector<num_t> model, const size_t &from, const size_t &to);
                static num_t __weekModelMeanValue(PlaceCategId categ, const Interval &interval,
-                               const TimeFeatures &start_f, const TimeFeatures &end_f);
+                               const TimeFeatures &startF, const TimeFeatures &endF);
                static void __normalize(std::vector<num_t> &features);
                static PiecewiseLin __chiApprox; // tabled chi function approximator
 
@@ -56,27 +58,27 @@ namespace ctx {
                 */
                static TimeFeatures timeFeatures(const time_t &time);
 
-               static int weeksScope(const TimeFeatures &start_f, const Interval &interval);
+               static int weeksScope(const TimeFeatures &startF, const Interval &interval);
 
                /**
                 * Function interpret time interval input argument and calculates scores
                 * that argument interval is home, work or other based on whole week model.
                 *
                 * @param  interval  time interval
-                * @param  start_f       start time features
-                * @param  end_f         end time features
-                * @return categs_t  score that argument interval is home, work or other
+                * @param  start       start time features
+                * @param  endF      end time features
+                * @return Categs    score that argument interval is home, work or other
                 */
-               static categs_t weekModelFeatures(const Interval &interval, const TimeFeatures &start_f,
-                               const TimeFeatures &end_f);
+               static Categs weekModelFeatures(const Interval &interval, const TimeFeatures &startF,
+                               const TimeFeatures &endF);
 
                /**
                 * Function interpret time interval input argument,
                 *
-                * @param  interval            time interval
-                * @return std::vector<num_t>  vector with interpretations of input time interval
+                * @param  interval          time interval
+                * @return IntervalFeatures  vector with interpretations of input time interval
                 */
-               static std::vector<num_t> intervalFeatures(const Interval &interval);
+               static IntervalFeatures intervalFeatures(const Interval &interval);
 
                /**
                 * Function categorize visit based on visits time interval and fill its categories values.
index d0ee631d9a221b13aec8d8cf6557fa3af7e676fa..57383cafd04340a5ae8c1539ed3c31088aede5d6 100644 (file)
@@ -30,7 +30,7 @@
 #include "debug_utils.h"
 
 #ifdef TIZEN_ENGINEER_MODE
-#define VISIT_TABLE_COLUMNS \
+#define __VISIT_TABLE_COLUMNS \
        VISIT_COLUMN_WIFI_APS " TEXT, "\
        VISIT_COLUMN_START_TIME " timestamp, "\
        VISIT_COLUMN_END_TIME " timestamp, "\
@@ -43,7 +43,7 @@
        VISIT_COLUMN_CATEG_WORK " REAL, "\
        VISIT_COLUMN_CATEG_OTHER " REAL"
 #else /* TIZEN_ENGINEER_MODE */
-#define VISIT_TABLE_COLUMNS \
+#define __VISIT_TABLE_COLUMNS \
        VISIT_COLUMN_WIFI_APS " TEXT, "\
        VISIT_COLUMN_START_TIME " timestamp, "\
        VISIT_COLUMN_END_TIME " timestamp, "\
        VISIT_COLUMN_CATEG_OTHER " REAL"
 #endif /* TIZEN_ENGINEER_MODE */
 
-ctx::VisitDetector::VisitDetector(time_t t_start_scan, place_recog_mode_e energyMode, bool testMode) :
+ctx::VisitDetector::VisitDetector(time_t startScan, PlaceRecogMode energyMode, bool testMode) :
        __testMode(testMode),
        __locationLogger(this, testMode),
        __wifiLogger(this, energyMode, testMode),
-       __currentInterval(t_start_scan, t_start_scan + VISIT_DETECTOR_PERIOD_SECONDS_HIGH_ACCURACY),
+       __currentInterval(startScan, startScan + VISIT_DETECTOR_PERIOD_SECONDS_HIGH_ACCURACY),
        __stableCounter(0),
        __tolerance(VISIT_DETECTOR_TOLERANCE_DEPTH),
        __entranceToPlace(false),
@@ -68,12 +68,12 @@ ctx::VisitDetector::VisitDetector(time_t t_start_scan, place_recog_mode_e energy
        __departureTime(0)
 {
        __setPeriod(energyMode);
-       __currentInterval = Interval(t_start_scan, t_start_scan + __periodSeconds);
-       __currentLogger = std::make_shared<mac_events>();
-       __stayMacs = std::make_shared<mac_set_t>();
+       __currentInterval = Interval(startScan, startScan + __periodSeconds);
+       __currentMacEvents = std::make_shared<MacEvents>();
+       __stayMacs = std::make_shared<MacSet>();
 
        if (__testMode) {
-               __detectedVisits = std::make_shared<ctx::visits_t>();
+               __detectedVisits = std::make_shared<ctx::Visits>();
                return;
        }
 
@@ -100,28 +100,28 @@ void ctx::VisitDetector::onWifiScan(ctx::MacEvent e)
                        __processCurrentLogger();
                        __shiftCurrentInterval();
                }
-               __currentLogger->push_back(e);
+               __currentMacEvents->push_back(e);
        }
 }
 
 void ctx::VisitDetector::__processCurrentLogger()
 {
        _D("");
-       std::shared_ptr<ctx::Frame> frame = __makeFrame(__currentLogger, __currentInterval);
+       std::shared_ptr<ctx::Frame> frame = __makeFrame(__currentMacEvents, __currentInterval);
        __detectEntranceOrDeparture(frame);
-       __currentLogger->clear();
+       __currentMacEvents->clear();
 }
 
-std::shared_ptr<ctx::Frame> ctx::VisitDetector::__makeFrame(std::shared_ptr<ctx::mac_events> logger, ctx::Interval interval)
+std::shared_ptr<ctx::Frame> ctx::VisitDetector::__makeFrame(std::shared_ptr<ctx::MacEvents> logger, ctx::Interval interval)
 {
        std::set<time_t> timestamps;
        std::shared_ptr<Frame> frame = std::make_shared<Frame>(interval);
        for (auto log : *logger) {
                timestamps.insert(log.timestamp);
-               if (frame->macCountsMap.find(log.mac) == frame->macCountsMap.end()) {
-                       frame->macCountsMap[log.mac] = 1;
+               if (frame->macs2Counts.find(log.mac) == frame->macs2Counts.end()) {
+                       frame->macs2Counts[log.mac] = 1;
                } else {
-                       frame->macCountsMap[log.mac] += 1;
+                       frame->macs2Counts[log.mac] += 1;
                }
        }
        frame->numberOfTimestamps = timestamps.size();
@@ -139,20 +139,20 @@ void ctx::VisitDetector::__detectEntranceOrDeparture(std::shared_ptr<ctx::Frame>
        __entranceToPlace ? __detectDeparture(frame) : __detectEntrance(frame);
 }
 
-bool ctx::VisitDetector::__isDisjoint(const ctx::mac_counts_t &macCountsMap, const ctx::mac_set_t &macSet)
+bool ctx::VisitDetector::__isDisjoint(const ctx::Macs2Counts &macs2Counts, const ctx::MacSet &macSet)
 {
        for (auto &mac : macSet) {
-               if (macCountsMap.find(mac) != macCountsMap.end()) {
+               if (macs2Counts.find(mac) != macs2Counts.end()) {
                        return false;
                }
        }
        return true;
 }
 
-bool ctx::VisitDetector::__protrudesFrom(const ctx::mac_counts_t &macCountsMap, const ctx::mac_set_t &macSet)
+bool ctx::VisitDetector::__protrudesFrom(const ctx::Macs2Counts &macs2Counts, const ctx::MacSet &macSet)
 {
-       for (auto &m : macCountsMap) {
-               if (macSet.find(m.first) == macSet.end()) {
+       for (auto &macCount : macs2Counts) {
+               if (macSet.find(macCount.first) == macSet.end()) {
                        return true;
                }
        }
@@ -167,8 +167,8 @@ void ctx::VisitDetector::__detectDeparture(std::shared_ptr<ctx::Frame> frame)
        } else { // __tolerance < VISIT_DETECTOR_TOLERANCE_DEPTH
                __bufferedFrames.push_back(frame);
        }
-       if (__isDisjoint(frame->macCountsMap, *__representativesMacs)) {
-               if (frame->macCountsMap.empty() || __protrudesFrom(frame->macCountsMap, *__stayMacs)) {
+       if (__isDisjoint(frame->macs2Counts, *__representativesMacs)) {
+               if (frame->macs2Counts.empty() || __protrudesFrom(frame->macs2Counts, *__stayMacs)) {
                        __tolerance--;
                } else { // no new macs
                        __bufferedFrames.clear();
@@ -230,15 +230,15 @@ void ctx::VisitDetector::__putLocationToVisit(ctx::Visit &visit)
        // TODO: remove small accuracy locations from vectors?
        std::vector<double> latitudes;
        std::vector<double> longitudes;
-       visit.location_valid = false;
+       visit.locationValid = false;
        for (LocationEvent location : __locationEvents) {
                if (location.timestamp >= __entranceTime && location.timestamp <= __departureTime) {
                        latitudes.push_back(location.coordinates.latitude);
                        longitudes.push_back(location.coordinates.longitude);
-                       visit.location_valid = true;
+                       visit.locationValid = true;
                }
        }
-       if (visit.location_valid) {
+       if (visit.locationValid) {
                visit.location.latitude = median(latitudes);
                visit.location.longitude = median(longitudes);
                _D("visit location set: lat=%.8f, lon=%.8f", visit.location.latitude, visit.location.longitude);
@@ -262,29 +262,29 @@ void ctx::VisitDetector::__processBuffer(std::shared_ptr<ctx::Frame> frame)
        }
 }
 
-void ctx::VisitDetector::__detectEntrance(std::shared_ptr<ctx::Frame> current_frame)
+void ctx::VisitDetector::__detectEntrance(std::shared_ptr<ctx::Frame> currentFrame)
 {
-       if (current_frame->macCountsMap.empty() || __historyFrames.empty()) {
-               __resetHistory(current_frame);
+       if (currentFrame->macs2Counts.empty() || __historyFrames.empty()) {
+               __resetHistory(currentFrame);
                return;
        }
 
        if (__stableCounter == 0) {
-               std::shared_ptr<Frame> oldest_history_frame = __historyFrames[0];
-               __stayMacs = mac_set_from_mac_counts(oldest_history_frame->macCountsMap);
+               std::shared_ptr<Frame> oldestHistoryFrame = __historyFrames[0];
+               __stayMacs = macSetFromMacs2Counts(oldestHistoryFrame->macs2Counts);
        }
 
-       std::shared_ptr<mac_set_t> current_beacons = mac_set_from_mac_counts(current_frame->macCountsMap);
+       std::shared_ptr<MacSet> currentBeacons = macSetFromMacs2Counts(currentFrame->macs2Counts);
 
-       if (similarity::overlapBiggerOverSmaller(*current_beacons, *__stayMacs) > VISIT_DETECTOR_OVERLAP) {
+       if (similarity::overlapBiggerOverSmaller(*currentBeacons, *__stayMacs) > VISIT_DETECTOR_OVERLAP) {
                __stableCounter++;
-               __historyFrames.push_back(current_frame);
+               __historyFrames.push_back(currentFrame);
 
                if (__stableCounter == VISIT_DETECTOR_STABLE_DEPTH) { // entrance detected
                        __visitStartDetected();
                }
        } else {
-               __resetHistory(current_frame);
+               __resetHistory(currentFrame);
        }
        return;
 }
@@ -301,82 +301,81 @@ void ctx::VisitDetector::__resetHistory(std::shared_ptr<Frame> frame)
        __historyFrames.push_back(frame);
 }
 
-std::shared_ptr<ctx::mac_set_t> ctx::VisitDetector::__selectRepresentatives(const std::vector<std::shared_ptr<Frame>> &frames)
+std::shared_ptr<ctx::MacSet> ctx::VisitDetector::__selectRepresentatives(const std::vector<std::shared_ptr<Frame>> &frames)
 {
-       mac_counts_t repr_counts;
-       count_t all_count = 0;
+       Macs2Counts reprs2Counts;
+       count_t allCount = 0;
 
        for (auto frame : frames) {
-               all_count += frame->numberOfTimestamps;
-               for (auto &c : frame->macCountsMap) {
-                       repr_counts[c.first] += c.second;
+               allCount += frame->numberOfTimestamps;
+               for (auto &c : frame->macs2Counts) {
+                       reprs2Counts[c.first] += c.second;
                }
        }
 
-       std::shared_ptr<mac_shares_t> repr_shares = __macSharesFromCounts(repr_counts, all_count);
+       std::shared_ptr<Macs2Shares> reprs2Shares = __macSharesFromCounts(reprs2Counts, allCount);
 
-       share_t max_share = __calcMaxShare(*repr_shares);
-       share_t threshold = max_share < VISIT_DETECTOR_REP_THRESHOLD ?
-               max_share : VISIT_DETECTOR_REP_THRESHOLD;
+       share_t maxShare = __calcMaxShare(*reprs2Shares);
+       share_t threshold = maxShare < VISIT_DETECTOR_REP_THRESHOLD ? maxShare : VISIT_DETECTOR_REP_THRESHOLD;
 
-       std::shared_ptr<mac_set_t> repr_mac_set = __macSetOfGreaterOrEqualShare(*repr_shares, threshold);
+       std::shared_ptr<MacSet> reprsMacSet = __macSetOfGreaterOrEqualShare(*reprs2Shares, threshold);
 
-       return repr_mac_set;
+       return reprsMacSet;
 }
 
-ctx::share_t ctx::VisitDetector::__calcMaxShare(const ctx::mac_shares_t &mac_shares)
+ctx::share_t ctx::VisitDetector::__calcMaxShare(const ctx::Macs2Shares &macs2Shares)
 {
-       ctx::share_t max_value = 0.0;
-       for (auto &ms : mac_shares) {
-               if (ms.second > max_value) {
-                       max_value = ms.second;
+       ctx::share_t maxShare = 0.0;
+       for (auto &macShare : macs2Shares) {
+               if (macShare.second > maxShare) {
+                       maxShare = macShare.second;
                }
        }
-       return max_value;
+       return maxShare;
 }
 
-std::shared_ptr<ctx::mac_set_t> ctx::VisitDetector::__macSetOfGreaterOrEqualShare(const ctx::mac_shares_t &mac_shares, ctx::share_t threshold)
+std::shared_ptr<ctx::MacSet> ctx::VisitDetector::__macSetOfGreaterOrEqualShare(const ctx::Macs2Shares &macs2Shares, ctx::share_t threshold)
 {
-       std::shared_ptr<mac_set_t> macSet = std::make_shared<mac_set_t>();
-       for (auto &ms : mac_shares) {
-               if (ms.second >= threshold) {
-                       macSet->insert(ms.first);
+       std::shared_ptr<MacSet> macSet = std::make_shared<MacSet>();
+       for (auto &macShare : macs2Shares) {
+               if (macShare.second >= threshold) {
+                       macSet->insert(macShare.first);
                }
        }
        return macSet;
 }
 
-std::shared_ptr<ctx::mac_shares_t> ctx::VisitDetector::__macSharesFromCounts(ctx::mac_counts_t const &macCountsMap, ctx::count_t denominator)
+std::shared_ptr<ctx::Macs2Shares> ctx::VisitDetector::__macSharesFromCounts(ctx::Macs2Counts const &macs2Counts, ctx::count_t denominator)
 {
-       std::shared_ptr<mac_shares_t> mac_shares(std::make_shared<mac_shares_t>());
-       for (auto mac_count : macCountsMap) {
-               (*mac_shares)[mac_count.first] = (share_t) mac_count.second / denominator;
+       std::shared_ptr<Macs2Shares> macs2Shares(std::make_shared<Macs2Shares>());
+       for (auto macCount : macs2Counts) {
+               (*macs2Shares)[macCount.first] = (share_t) macCount.second / denominator;
        }
-       return mac_shares;
+       return macs2Shares;
 }
 
-std::shared_ptr<ctx::visits_t> ctx::VisitDetector::getVisits()
+std::shared_ptr<ctx::Visits> ctx::VisitDetector::getVisits()
 {
        return __detectedVisits;
 }
 
 void ctx::VisitDetector::__dbCreateTable()
 {
-       bool ret = db_manager::create_table(0, VISIT_TABLE, VISIT_TABLE_COLUMNS);
+       bool ret = db_manager::create_table(0, VISIT_TABLE, __VISIT_TABLE_COLUMNS);
        _D("db: visit Table Creation Result: %s", ret ? "SUCCESS" : "FAIL");
 }
 
-void ctx::VisitDetector::__putVisitCategToJson(const char* key, const categs_t &categs, int categ_type, Json &data)
+void ctx::VisitDetector::__putVisitCategToJson(const char* key, const Categs &categs, int categType, Json &data)
 {
-       auto categ_p = categs.find(categ_type);
-       if (categ_p == categs.end()) {
-               _E("json_put_visit no type %d in categs", categ_type);
+       auto categ = categs.find(categType);
+       if (categ == categs.end()) {
+               _E("json_put_visit no type %d in categs", categType);
        } else {
-               data.set(NULL, key, categ_p->second);
+               data.set(NULL, key, categ->second);
        }
 }
 
-void ctx::VisitDetector::__putVisitCategsToJson(const categs_t &categs, Json &data)
+void ctx::VisitDetector::__putVisitCategsToJson(const Categs &categs, Json &data)
 {
        __putVisitCategToJson(VISIT_COLUMN_CATEG_HOME, categs, PLACE_CATEG_ID_HOME, data);
        __putVisitCategToJson(VISIT_COLUMN_CATEG_WORK, categs, PLACE_CATEG_ID_WORK, data);
@@ -385,13 +384,13 @@ void ctx::VisitDetector::__putVisitCategsToJson(const categs_t &categs, Json &da
 
 int ctx::VisitDetector::__dbInsertVisit(Visit visit)
 {
-       std::stringstream macs_ss;
-       macs_ss << *visit.macSet;
+       std::stringstream ss;
+       ss << *visit.macSet;
 
        Json data;
-       data.set(NULL, VISIT_COLUMN_WIFI_APS, macs_ss.str().c_str());
+       data.set(NULL, VISIT_COLUMN_WIFI_APS, ss.str().c_str());
 
-       data.set(NULL, VISIT_COLUMN_LOCATION_VALID, visit.location_valid);
+       data.set(NULL, VISIT_COLUMN_LOCATION_VALID, visit.locationValid);
        data.set(NULL, VISIT_COLUMN_LOCATION_LATITUDE, visit.location.latitude);
        data.set(NULL, VISIT_COLUMN_LOCATION_LONGITUDE, visit.location.longitude);
 
@@ -399,32 +398,32 @@ int ctx::VisitDetector::__dbInsertVisit(Visit visit)
        data.set(NULL, VISIT_COLUMN_END_TIME, static_cast<int>(visit.interval.end));
 
 #ifdef TIZEN_ENGINEER_MODE
-       std::string start_time_human = DebugUtils::humanReadableDateTime(visit.interval.start, "%F %T", 80);
-       std::string end_time_human = DebugUtils::humanReadableDateTime(visit.interval.end, "%F %T", 80);
-       data.set(NULL, VISIT_COLUMN_START_TIME_HUMAN, start_time_human.c_str());
-       data.set(NULL, VISIT_COLUMN_END_TIME_HUMAN, end_time_human.c_str());
+       std::string startTimeHuman = DebugUtils::humanReadableDateTime(visit.interval.start, "%F %T", 80);
+       std::string endTimeHuman = DebugUtils::humanReadableDateTime(visit.interval.end, "%F %T", 80);
+       data.set(NULL, VISIT_COLUMN_START_TIME_HUMAN, startTimeHuman.c_str());
+       data.set(NULL, VISIT_COLUMN_END_TIME_HUMAN, endTimeHuman.c_str());
        _D("db: visit table insert interval: (%d, %d): (%s, %s)",
-                       visit.interval.start, visit.interval.end, start_time_human.c_str(), end_time_human.c_str());
+                       visit.interval.start, visit.interval.end, startTimeHuman.c_str(), endTimeHuman.c_str());
 #else
        _D("db: visit table insert interval: (%d, %d)", visit.interval.start, visit.interval.end);
 #endif /* TIZEN_ENGINEER_MODE */
 
        __putVisitCategsToJson(visit.categs, data);
 
-       int64_t row_id;
-       bool ret = db_manager::insert_sync(VISIT_TABLE, data, &row_id);
+       int64_t rowId;
+       bool ret = db_manager::insert_sync(VISIT_TABLE, data, &rowId);
        _D("db: visit table insert result: %s", ret ? "SUCCESS" : "FAIL");
        return ret;
 }
 
-void ctx::VisitDetector::onNewLocation(LocationEvent location_event)
+void ctx::VisitDetector::onNewLocation(LocationEvent locationEvent)
 {
        _D("");
-       location_event.log();
-       __locationEvents.push_back(location_event);
+       locationEvent.log();
+       __locationEvents.push_back(locationEvent);
 };
 
-void ctx::VisitDetector::__setPeriod(place_recog_mode_e energyMode)
+void ctx::VisitDetector::__setPeriod(PlaceRecogMode energyMode)
 {
        switch (energyMode) {
        case PLACE_RECOG_LOW_POWER_MODE:
@@ -438,7 +437,7 @@ void ctx::VisitDetector::__setPeriod(place_recog_mode_e energyMode)
        }
 }
 
-void ctx::VisitDetector::setMode(place_recog_mode_e energyMode)
+void ctx::VisitDetector::setMode(PlaceRecogMode energyMode)
 {
        _D("");
        __setPeriod(energyMode);
index a4c9b342555c16de73570d92a3ebb8ff8c4e120c..757774e0fb7225f9407b128753c0da7567d07112 100644 (file)
@@ -36,11 +36,11 @@ namespace ctx {
 
        private:
                bool __testMode;
-               std::shared_ptr<visits_t> __detectedVisits; // only used in test mode
+               std::shared_ptr<Visits> __detectedVisits; // only used in test mode
                LocationLogger __locationLogger;
                WifiLogger __wifiLogger;
                std::vector<IVisitListener*> __listeners;
-               std::shared_ptr<mac_events> __currentLogger;
+               std::shared_ptr<MacEvents> __currentMacEvents;
                Interval __currentInterval;
                std::vector<LocationEvent> __locationEvents;
                std::vector<std::shared_ptr<Frame>> __historyFrames;  // python: history_scans  + history_times
@@ -51,8 +51,8 @@ namespace ctx {
                int __periodSeconds;
 
                // fields that  are used only in case of entrance detection
-               std::shared_ptr<mac_set_t> __representativesMacs; // macs that represent the current place
-               std::shared_ptr<mac_set_t> __stayMacs; // macs that can appear in the current place
+               std::shared_ptr<MacSet> __representativesMacs; // macs that represent the current place
+               std::shared_ptr<MacSet> __stayMacs; // macs that can appear in the current place
                time_t __entranceTime;
                time_t __departureTime;
 
@@ -62,37 +62,37 @@ namespace ctx {
                void __detectEntrance(std::shared_ptr<Frame> frame);
                void __detectDeparture(std::shared_ptr<Frame> frame);
                void __processBuffer(std::shared_ptr<Frame> frame); // python: buffer_analysing
-               std::shared_ptr<Frame> __makeFrame(std::shared_ptr<mac_events> mac_events, Interval interval);  // python: scans2fingerprint
+               std::shared_ptr<Frame> __makeFrame(std::shared_ptr<MacEvents> macEvents, Interval interval);  // python: scans2fingerprint
                void __resetHistory();
                void __resetHistory(std::shared_ptr<Frame> frame);
                void __visitStartDetected();
                void __visitEndDetected();
                void __putLocationToVisit(Visit &visit);
-               std::shared_ptr<mac_set_t> __selectRepresentatives(const std::vector<std::shared_ptr<Frame>> &frames);
-               std::shared_ptr<mac_set_t> __macSetOfGreaterOrEqualShare(const mac_shares_t &mac_shares, share_t threshold);
-               std::shared_ptr<mac_shares_t> __macSharesFromCounts(mac_counts_t const &mac_counts, count_t denominator); // python: response_rate
-               share_t __calcMaxShare(const mac_shares_t &mac_shares);
-               bool __isDisjoint(const mac_counts_t &mac_counts, const mac_set_t &macSet);
-               bool __protrudesFrom(const mac_counts_t &mac_counts, const mac_set_t &macSet);
-               void __setPeriod(place_recog_mode_e mode);
+               std::shared_ptr<MacSet> __selectRepresentatives(const std::vector<std::shared_ptr<Frame>> &frames);
+               std::shared_ptr<MacSet> __macSetOfGreaterOrEqualShare(const Macs2Shares &macs2Shares, share_t threshold);
+               std::shared_ptr<Macs2Shares> __macSharesFromCounts(Macs2Counts const &macs2Counts, count_t denominator); // python: response_rate
+               share_t __calcMaxShare(const Macs2Shares &macs2Shares);
+               bool __isDisjoint(const Macs2Counts &macs2Counts, const MacSet &macSet);
+               bool __protrudesFrom(const Macs2Counts &macs2Counts, const MacSet &macSet);
+               void __setPeriod(PlaceRecogMode mode);
                void __processCurrentLogger();
 
                /* DATABASE */
                void __dbCreateTable();
                int __dbInsertVisit(Visit visit);
-               void __putVisitCategToJson(const char* key, const categs_t &categs, int categ_type, Json &data);
-               void __putVisitCategsToJson(const categs_t &categs, Json &data);
+               void __putVisitCategToJson(const char* key, const Categs &categs, int categType, Json &data);
+               void __putVisitCategsToJson(const Categs &categs, Json &data);
 
                /* INPUT */
                void onWifiScan(MacEvent event);
                void onNewLocation(LocationEvent location);
 
        public:
-               VisitDetector(time_t t_start_scan, place_recog_mode_e energyMode = PLACE_RECOG_HIGH_ACCURACY_MODE, bool testMode = false);
+               VisitDetector(time_t startScan, PlaceRecogMode energyMode = PLACE_RECOG_HIGH_ACCURACY_MODE, bool testMode = false);
                ~VisitDetector();
 
-               std::shared_ptr<visits_t> getVisits(); // only used in test mode
-               void setMode(place_recog_mode_e energyMode);
+               std::shared_ptr<Visits> getVisits(); // only used in test mode
+               void setMode(PlaceRecogMode energyMode);
 
        };      /* class VisitDetector */
 
index 8f91c22fd982f0f77fcd88b34e0480155a94f888..3b883d302b1c97283f2412cc3f75ac1f59ba3b6c 100644 (file)
@@ -25,7 +25,7 @@ namespace ctx {
 
        public:
                virtual ~IWifiListener() {};
-               virtual void onWifiScan(ctx::MacEvent e) = 0;
+               virtual void onWifiScan(ctx::MacEvent macEvent) = 0;
 
        };      /* IWifiListener */
 
index 29dabd4596e3b50f40d8ba818b643cf9e2adc1f9..4c3742af1ae0121c371af46782d3f783f034c205 100644 (file)
 #include <sstream>
 #include "debug_utils.h"
 
-#define WIFI_CREATE_TABLE_COLUMNS \
+#define __WIFI_CREATE_TABLE_COLUMNS \
        WIFI_COLUMN_TIMESTAMP " timestamp NOT NULL, "\
        WIFI_COLUMN_BSSID " TEXT NOT NULL"
 
-#define _WIFI_ERROR_LOG(error) { \
+#define __WIFI_ERROR_LOG(error) { \
        if (error != WIFI_ERROR_NONE) { \
                _E("ERROR == %s", __wifiError2Str(error)); \
        } else { \
@@ -35,7 +35,7 @@
 
 int ctx::WifiLogger::__dbCreateTable()
 {
-       bool ret = db_manager::create_table(0, WIFI_TABLE_NAME, WIFI_CREATE_TABLE_COLUMNS, NULL, NULL);
+       bool ret = db_manager::create_table(0, WIFI_TABLE_NAME, __WIFI_CREATE_TABLE_COLUMNS, NULL, NULL);
        _D("Table Creation Request: %s", ret ? "SUCCESS" : "FAIL");
        return ret;
 }
@@ -64,7 +64,7 @@ int ctx::WifiLogger::__dbInsertLogs()
        return 0;
 }
 
-ctx::WifiLogger::WifiLogger(IWifiListener * listener, place_recog_mode_e energyMode, bool testMode) :
+ctx::WifiLogger::WifiLogger(IWifiListener * listener, PlaceRecogMode energyMode, bool testMode) :
        __timerOn(false),
        __intervalMinutes(WIFI_LOGGER_INTERVAL_MINUTES_HIGH_ACCURACY),
        __testMode(testMode),
@@ -107,9 +107,9 @@ ctx::WifiLogger::~WifiLogger()
        __wifiDeinitializeRequest();
 }
 
-void ctx::WifiLogger::__wifiDeviceStateChangedCb(wifi_device_state_e state, void *user_data)
+void ctx::WifiLogger::__wifiDeviceStateChangedCb(wifi_device_state_e state, void *userData)
 {
-       ctx::WifiLogger* wifiLogger = (ctx::WifiLogger *)user_data;
+       ctx::WifiLogger* wifiLogger = (ctx::WifiLogger *)userData;
        switch (state) {
        case WIFI_DEVICE_STATE_DEACTIVATED:
                _D("WIFI setting OFF");
@@ -128,9 +128,9 @@ void ctx::WifiLogger::__wifiDeviceStateChangedCb(wifi_device_state_e state, void
        }
 }
 
-void ctx::WifiLogger::__wifiConnectionStateChangedCb(wifi_connection_state_e state, wifi_ap_h ap, void *user_data)
+void ctx::WifiLogger::__wifiConnectionStateChangedCb(wifi_connection_state_e state, wifi_ap_h ap, void *userData)
 {
-       ctx::WifiLogger* wifiLogger = (ctx::WifiLogger *)user_data;
+       ctx::WifiLogger* wifiLogger = (ctx::WifiLogger *)userData;
        switch (state) {
        case WIFI_CONNECTION_STATE_CONNECTED:
                _D("connected to AP");
@@ -145,9 +145,9 @@ void ctx::WifiLogger::__wifiConnectionStateChangedCb(wifi_connection_state_e sta
        // TODO: Check if AP bssid (MAC Address) will be helpful somehow in LOW_POWER mode
 }
 
-bool ctx::WifiLogger::__wifiFoundApCb(wifi_ap_h ap, void *user_data)
+bool ctx::WifiLogger::__wifiFoundApCb(wifi_ap_h ap, void *userData)
 {
-       ctx::WifiLogger* wifiLogger = (ctx::WifiLogger *)user_data;
+       ctx::WifiLogger* wifiLogger = (ctx::WifiLogger *)userData;
 
        char *bssid = NULL;
        int ret = __wifiApGetBssidRequest(ap, &bssid);
@@ -215,9 +215,9 @@ const char* ctx::WifiLogger::__wifiError2Str(int error)
        }
 }
 
-void ctx::WifiLogger::__wifiScanFinishedCb(wifi_error_e error_code, void *user_data)
+void ctx::WifiLogger::__wifiScanFinishedCb(wifi_error_e errorCode, void *userData)
 {
-       ctx::WifiLogger* wifiLogger = (ctx::WifiLogger *)user_data;
+       ctx::WifiLogger* wifiLogger = (ctx::WifiLogger *)userData;
 
        time_t now = time(nullptr);
 #ifdef TIZEN_ENGINEER_MODE
@@ -225,17 +225,17 @@ void ctx::WifiLogger::__wifiScanFinishedCb(wifi_error_e error_code, void *user_d
        if (wifiLogger->__lastScanTime > 0) {
                seconds = difftime(now, wifiLogger->__lastScanTime);
        }
-       std::string time_str = DebugUtils::humanReadableDateTime(now, "%T", 9);
+       std::string timeStr = DebugUtils::humanReadableDateTime(now, "%T", 9);
        _D("__connectedToWifiAp = %d, __duringVisit = %d, __lastScansPool.size() = %d -> scan %s (from last : %.1fs)",
                        static_cast<int>(wifiLogger->__connectedToWifiAp),
                        static_cast<int>(wifiLogger->__duringVisit),
                        wifiLogger->__lastScansPool.size(),
-                       time_str.c_str(),
+                       timeStr.c_str(),
                        seconds);
 #endif /* TIZEN_ENGINEER_MODE */
        wifiLogger->__lastScanTime = now;
 
-       int ret = __wifiForeachFoundApsRequest(user_data);
+       int ret = __wifiForeachFoundApsRequest(userData);
        if (ret != WIFI_ERROR_NONE) {
                return;
        }
@@ -246,69 +246,69 @@ void ctx::WifiLogger::__wifiScanFinishedCb(wifi_error_e error_code, void *user_d
 
 bool ctx::WifiLogger::__checkWifiIsActivated()
 {
-       bool wifi_activated = true;
-       int ret = wifi_is_activated(&wifi_activated);
-       _WIFI_ERROR_LOG(ret);
-       _D("Wi-Fi is %s", wifi_activated ? "ON" : "OFF");
-       return wifi_activated;
+       bool wifiActivated = true;
+       int ret = wifi_is_activated(&wifiActivated);
+       __WIFI_ERROR_LOG(ret);
+       _D("Wi-Fi is %s", wifiActivated ? "ON" : "OFF");
+       return wifiActivated;
 }
 
 void ctx::WifiLogger::__wifiScanRequest()
 {
        int ret = wifi_scan(__wifiScanFinishedCb, this);
-       _WIFI_ERROR_LOG(ret);
+       __WIFI_ERROR_LOG(ret);
 }
 
-int ctx::WifiLogger::__wifiForeachFoundApsRequest(void *user_data)
+int ctx::WifiLogger::__wifiForeachFoundApsRequest(void *userData)
 {
-       int ret = wifi_foreach_found_aps(__wifiFoundApCb, user_data);
-       _WIFI_ERROR_LOG(ret);
+       int ret = wifi_foreach_found_aps(__wifiFoundApCb, userData);
+       __WIFI_ERROR_LOG(ret);
        return ret;
 }
 
 wifi_connection_state_e ctx::WifiLogger::__wifiGetConnectionStateRequest()
 {
-       wifi_connection_state_e connection_state;
-       int ret = wifi_get_connection_state(&connection_state);
-       _WIFI_ERROR_LOG(ret);
-       return connection_state;
+       wifi_connection_state_e connectionState;
+       int ret = wifi_get_connection_state(&connectionState);
+       __WIFI_ERROR_LOG(ret);
+       return connectionState;
 }
 
 void ctx::WifiLogger::__wifiSetBackgroundScanCbRequest()
 {
        int ret = wifi_set_background_scan_cb(__wifiScanFinishedCb, this);
-       _WIFI_ERROR_LOG(ret);
+       __WIFI_ERROR_LOG(ret);
 }
 
 void ctx::WifiLogger::__wifiSetDeviceStateChangedCbRequest()
 {
        int ret = wifi_set_device_state_changed_cb(__wifiDeviceStateChangedCb, this);
-       _WIFI_ERROR_LOG(ret);
+       __WIFI_ERROR_LOG(ret);
 }
 
 void ctx::WifiLogger::__wifiSetConnectionStateChangedCbRequest()
 {
        int ret = wifi_set_connection_state_changed_cb(__wifiConnectionStateChangedCb, this);
-       _WIFI_ERROR_LOG(ret);
+       __WIFI_ERROR_LOG(ret);
 }
 
 int ctx::WifiLogger::__wifiApGetBssidRequest(wifi_ap_h ap, char **bssid)
 {
        int ret = wifi_ap_get_bssid(ap, bssid);
-       _WIFI_ERROR_LOG(ret);
+       __WIFI_ERROR_LOG(ret);
        return ret;
 }
 
 void ctx::WifiLogger::__wifiInitializeRequest()
 {
        int ret = wifi_initialize();
-       _WIFI_ERROR_LOG(ret);
+       __WIFI_ERROR_LOG(ret);
 }
 
 void ctx::WifiLogger::__wifiDeinitializeRequest()
 {
        int ret = wifi_deinitialize();
-       _WIFI_ERROR_LOG(ret);
+       __WIFI_ERROR_LOG(ret);
 }
 
 bool ctx::WifiLogger::__checkTimerId(int id)
@@ -443,7 +443,7 @@ void ctx::WifiLogger::onVisitEnd()
        __lastScansPool.clear();
 }
 
-void ctx::WifiLogger::__setInterval(place_recog_mode_e energyMode)
+void ctx::WifiLogger::__setInterval(PlaceRecogMode energyMode)
 {
        switch (energyMode) {
        case PLACE_RECOG_LOW_POWER_MODE:
@@ -463,7 +463,7 @@ void ctx::WifiLogger::__timerRestart()
        __timerStart(__intervalMinutes);
 }
 
-void ctx::WifiLogger::setMode(place_recog_mode_e energyMode)
+void ctx::WifiLogger::setMode(PlaceRecogMode energyMode)
 {
        _D("");
        __setInterval(energyMode);
index 029eee14da314f952e8e9a33a80c18171641ad22..9938a2c709d4c54f53c55af286a467d5e5b6df70 100644 (file)
@@ -51,13 +51,13 @@ namespace ctx {
 
        public:
                WifiLogger(IWifiListener * listener = nullptr,
-                               place_recog_mode_e mode = PLACE_RECOG_HIGH_ACCURACY_MODE,
+                               PlaceRecogMode energyMode = PLACE_RECOG_HIGH_ACCURACY_MODE,
                                bool testMode = false);
                ~WifiLogger();
 
                void startLogging();
                void stopLogging();
-               void setMode(place_recog_mode_e energyMode);
+               void setMode(PlaceRecogMode energyMode);
 
        private:
                /* INPUT */
@@ -71,7 +71,7 @@ namespace ctx {
                int __timerId;
                int __intervalMinutes;
                TimerManager __timerManager;
-               void __setInterval(place_recog_mode_e energyMode);
+               void __setInterval(PlaceRecogMode energyMode);
                bool __checkTimerId(int id);
                bool __checkTimerTime(time_t now);
                void __timerStart(time_t minutes);
@@ -87,17 +87,17 @@ namespace ctx {
                void __wifiSetConnectionStateChangedCbRequest();
                static bool __checkWifiIsActivated();
                void __wifiScanRequest();
-               static int __wifiForeachFoundApsRequest(void *user_data);
+               static int __wifiForeachFoundApsRequest(void *userData);
                static wifi_connection_state_e __wifiGetConnectionStateRequest();
                static int __wifiApGetBssidRequest(wifi_ap_h ap, char **bssid);
                void __wifiInitializeRequest();
                void __wifiDeinitializeRequest();
 
                /* SYSTEM CAPI CALLBACKS */
-               static void __wifiDeviceStateChangedCb(wifi_device_state_e state, void *user_data);
-               static void __wifiConnectionStateChangedCb(wifi_connection_state_e state, wifi_ap_h ap, void *user_data);
-               static bool __wifiFoundApCb(wifi_ap_h ap, void *user_data);
-               static void __wifiScanFinishedCb(wifi_error_e error_code, void *user_data);
+               static void __wifiDeviceStateChangedCb(wifi_device_state_e state, void *userData);
+               static void __wifiConnectionStateChangedCb(wifi_connection_state_e state, wifi_ap_h ap, void *userData);
+               static bool __wifiFoundApCb(wifi_ap_h ap, void *userData);
+               static void __wifiScanFinishedCb(wifi_error_e errorCode, void *userData);
 
                bool __testMode;
                IWifiListener * const __listener;