From: Marcin Masternak Date: Wed, 26 Oct 2016 17:29:07 +0000 (+0200) Subject: [my-place] Make PlacesDetector pure static. X-Git-Tag: submit/tizen/20161031.062309^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5259bd5ad85d39ef5d214a9e14abeb1e3cdb231c;p=platform%2Fcore%2Fcontext%2Fcontext-provider.git [my-place] Make PlacesDetector pure static. Change-Id: Iaaef19e42b8af8480acae24f1dd397ae7ac16ed6 Signed-off-by: Marcin Masternak --- diff --git a/src/my-place/place/PlacesDetector.cpp b/src/my-place/place/PlacesDetector.cpp index 298506d..5ecd6eb 100644 --- a/src/my-place/place/PlacesDetector.cpp +++ b/src/my-place/place/PlacesDetector.cpp @@ -61,15 +61,10 @@ PLACE_COLUMN_WIFI_APS " STRING, "\ PLACE_COLUMN_CREATE_DATE " timestamp" -bool ctx::PlacesDetector::onTimerExpired(int timerId) { - _D(""); - detectPlaces(); - return true; -} - void ctx::PlacesDetector::detectPlaces() { _D(""); + __dbCreateTable(); __dbDeletePlaces(); __dbDeleteOldEntries(); std::vector records = __dbGetVisits(); @@ -168,7 +163,7 @@ void ctx::PlacesDetector::__reduceOutliers(ctx::Visits &visits) _D("Visits number from %d to %d (to short and to long reduction)", size, newSize); } -std::vector> ctx::PlacesDetector::__processVisits(ctx::Visits &visits) +std::vector> ctx::PlacesDetector::__processVisits(ctx::Visits &visits, bool testMode) { #ifdef TIZEN_ENGINEER_MODE std::vector placesVisits; // TODO: remove from final solution. @@ -181,7 +176,7 @@ std::vector> ctx::PlacesDetector::__processVisits(ct for (std::shared_ptr component : *components) { // Small places outliers reduction - if (!__testMode && component->size() < PLACES_DETECTOR_MIN_VISITS_PER_BIG_PLACE) + if (!testMode && component->size() < PLACES_DETECTOR_MIN_VISITS_PER_BIG_PLACE) continue; std::shared_ptr merged = std::make_shared(); for (graph::Node i : *component) { @@ -191,7 +186,7 @@ std::vector> ctx::PlacesDetector::__processVisits(ct if (place->categId == PLACE_CATEG_ID_NONE) continue; newDetectedPlaces.push_back(place); - if (!__testMode) + if (!testMode) __dbInsertPlace(*place); #ifdef TIZEN_ENGINEER_MODE @@ -342,14 +337,6 @@ void ctx::PlacesDetector::__dbDeleteOlderWifiAPsThan(time_t threshold) _D("deleting Wifi APs older than: %d, result: %s", threshold, ret ? "SUCCESS" : "FAIL"); } -ctx::PlacesDetector::PlacesDetector(bool testMode): - __testMode(testMode) -{ - if (testMode) - return; - __dbCreateTable(); -} - void ctx::PlacesDetector::__dbCreateTable() { DatabaseManager dbManager; @@ -385,7 +372,5 @@ void ctx::PlacesDetector::__dbInsertPlace(const Place &place) extern "C" SO_EXPORT void detectPlaces() { - _D(""); - ctx::PlacesDetector placesDetector; - placesDetector.detectPlaces(); + ctx::PlacesDetector::detectPlaces(); } diff --git a/src/my-place/place/PlacesDetector.h b/src/my-place/place/PlacesDetector.h index 81c6a44..ad07355 100644 --- a/src/my-place/place/PlacesDetector.h +++ b/src/my-place/place/PlacesDetector.h @@ -19,46 +19,42 @@ #include #include -#include #include #include #include "Graph.h" namespace ctx { - class PlacesDetector : public ITimerListener { + class PlacesDetector { private: - bool __testMode; - - double __doubleValueFromJson(Json &row, const char* key); - Categs __visitCategsFromJson(Json &row); - void __visitLocationFromJson(Json &row, ctx::Visit &visit); - Visit __visitFromJson(Json &row); - Visits __visitsFromJsons(std::vector& records); - - std::shared_ptr __graphFromVisits(const std::vector &visits); - - void __dbCreateTable(); - void __dbDeletePlaces(); - void __dbDeleteOldEntries(); - void __dbDeleteOlderVisitsThan(time_t threshold); - void __dbDeleteOlderWifiAPsThan(time_t threshold); - std::vector __dbGetVisits(); - void __dbInsertPlace(const Place &place); - - std::shared_ptr __placeFromMergedVisits(Visits &mergedVisits); - std::vector> __processVisits(Visits &visits); + static double __doubleValueFromJson(Json &row, const char* key); + static Categs __visitCategsFromJson(Json &row); + static void __visitLocationFromJson(Json &row, ctx::Visit &visit); + static Visit __visitFromJson(Json &row); + static Visits __visitsFromJsons(std::vector& records); + + static std::shared_ptr __graphFromVisits(const std::vector &visits); + + static void __dbCreateTable(); + static void __dbDeletePlaces(); + static void __dbDeleteOldEntries(); + static void __dbDeleteOlderVisitsThan(time_t threshold); + static void __dbDeleteOlderWifiAPsThan(time_t threshold); + static std::vector __dbGetVisits(); + static void __dbInsertPlace(const Place &place); + + static std::shared_ptr __placeFromMergedVisits(Visits &mergedVisits); + static std::vector> __processVisits(Visits &visits, bool testMode = false); static void __mergeLocation(const Visits &mergedVisits, Place &place); - std::shared_ptr __mergeVisits(const std::vector &visits); + static std::shared_ptr __mergeVisits(const std::vector &visits); static void __reduceOutliers(Visits &visits); static void __reduceOutliers(std::shared_ptr &cc); - bool onTimerExpired(int timerId); + PlacesDetector(); public: - PlacesDetector(bool testMode = false); - void detectPlaces(); + static void detectPlaces(); }; /* class PlacesDetector */