From 6a36f14b7840432142b81806648cf62a7ac88b5d Mon Sep 17 00:00:00 2001 From: Marcin Masternak Date: Fri, 27 May 2016 19:35:38 +0200 Subject: [PATCH] [my-place] Hide internal UserPlaces engine methods. Change-Id: I63af99deaf288ebb3e8afb362e9c86ea36cf3f98 Signed-off-by: Marcin Masternak --- src/my-place/place_recognition.cpp | 3 +-- src/my-place/user_places/user_places.cpp | 23 +++++++++++++++-------- src/my-place/user_places/user_places.h | 5 +++-- 3 files changed, 19 insertions(+), 12 deletions(-) mode change 100644 => 100755 src/my-place/user_places/user_places.cpp diff --git a/src/my-place/place_recognition.cpp b/src/my-place/place_recognition.cpp index a26eda5..ba9e4d1 100644 --- a/src/my-place/place_recognition.cpp +++ b/src/my-place/place_recognition.cpp @@ -42,8 +42,7 @@ int ctx::PlaceRecognitionProvider::read(ctx::Json option, ctx::Json* requestResu _I(BLUE("Read")); _J("Option", option); - std::vector> places = __engine.getPlaces(); - Json dataRead = UserPlaces::composeJson(places); + Json dataRead = __engine.getPlaces(); /* * The below function needs to be called once. diff --git a/src/my-place/user_places/user_places.cpp b/src/my-place/user_places/user_places.cpp old mode 100644 new mode 100755 index bdd1bc6..ccbce92 --- a/src/my-place/user_places/user_places.cpp +++ b/src/my-place/user_places/user_places.cpp @@ -68,7 +68,7 @@ ctx::UserPlaces::~UserPlaces() } }; -std::vector> ctx::UserPlaces::getPlaces() +std::vector> ctx::UserPlaces::__getPlaces() { if (__placesDetector) { return __placesDetector->getPlaces(); @@ -77,6 +77,13 @@ std::vector> ctx::UserPlaces::getPlaces() } } +ctx::Json ctx::UserPlaces::getPlaces() +{ + std::vector> places = __getPlaces(); + Json dataRead = UserPlaces::__composeJson(places); + return dataRead; +} + /* * Example JSON output: * ------------------------------------------------ @@ -109,21 +116,21 @@ std::vector> ctx::UserPlaces::getPlaces() * ] * } */ -ctx::Json ctx::UserPlaces::composeJson(std::vector> places) +ctx::Json ctx::UserPlaces::__composeJson(std::vector> places) { ctx::Json data; for (std::shared_ptr place : places) { ctx::Json placeJson; - placeJson.set(NULL, PLACE_CATEG_ID, place->categId); - placeJson.set(NULL, PLACE_CATEG_CONFIDENCE, place->categConfidence); + placeJson.set(NULL, PLACE_CATEG_ID, static_cast(place->categId)); + placeJson.set(NULL, PLACE_CATEG_CONFIDENCE, static_cast(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); + placeJson.set(NULL, PLACE_GEO_LATITUDE, static_cast(place->location.latitude)); + placeJson.set(NULL, PLACE_GEO_LONGITUDE, static_cast(place->location.longitude)); } placeJson.set(NULL, PLACE_WIFI_APS, place->wifiAps); - placeJson.set(NULL, PLACE_CREATE_DATE, static_cast(place->createDate)); - data.append(NULL, DATA_READ, placeJson); + placeJson.set(NULL, PLACE_CREATE_DATE, static_cast(place->createDate)); + data.append(NULL, PLACE_DATA_READ, placeJson); } return data; } diff --git a/src/my-place/user_places/user_places.h b/src/my-place/user_places/user_places.h index 6eaa1d7..5d9b181 100644 --- a/src/my-place/user_places/user_places.h +++ b/src/my-place/user_places/user_places.h @@ -33,14 +33,15 @@ namespace ctx { PlacesDetector *__placesDetector; int __placesDetectorTimerId; TimerManager __timerManager; + std::vector> __getPlaces(); + static Json __composeJson(std::vector> places); public: UserPlaces(PlaceRecogMode energyMode = PLACE_RECOG_HIGH_ACCURACY_MODE); ~UserPlaces(); void setMode(PlaceRecogMode energyMode); - std::vector> getPlaces(); - static Json composeJson(std::vector> places); + ctx::Json getPlaces(); }; /* class UserPlaces */ -- 2.34.1