Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuri Gorshenin <y@maps.me>2017-06-19 15:25:00 +0300
committerYuri Gorshenin <mipt.vi002@gmail.com>2017-07-05 16:41:38 +0300
commit2abc1da6f13ef3c3e875dfc9f218b8274a732cba (patch)
treec1eebc489b26d7174371f0e200e8a74369aa4e9e
parent790817bde6afe92bcd4fe867622474514ee490b0 (diff)
[ugc] UGC Api prototype.
-rw-r--r--CMakeLists.txt1
-rw-r--r--map/framework.cpp8
-rw-r--r--map/framework.hpp7
-rw-r--r--map/map_tests/CMakeLists.txt1
-rw-r--r--qt/CMakeLists.txt1
-rw-r--r--search/search_quality/assessment_tool/CMakeLists.txt1
-rw-r--r--storage/storage_integration_tests/CMakeLists.txt1
-rw-r--r--storage/storage_tests/CMakeLists.txt1
-rw-r--r--ugc/CMakeLists.txt9
-rw-r--r--ugc/api.cpp34
-rw-r--r--ugc/api.hpp30
11 files changed, 94 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 21d3505f37..2e3eae78a7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -322,6 +322,7 @@ add_subdirectory(tracking)
add_subdirectory(traffic)
add_subdirectory(partners_api)
add_subdirectory(local_ads)
+add_subdirectory(ugc)
if (PLATFORM_DESKTOP)
add_subdirectory(openlr)
diff --git a/map/framework.cpp b/map/framework.cpp
index 0bc20b3c52..540fc334e4 100644
--- a/map/framework.cpp
+++ b/map/framework.cpp
@@ -363,6 +363,7 @@ void Framework::Migrate(bool keepDownloaded)
m_model.Clear();
GetStorage().Migrate(keepDownloaded ? existedCountries : TCountriesVec());
InitCountryInfoGetter();
+ InitUGC();
InitSearchEngine();
InitCityFinder();
InitTaxiEngine();
@@ -1453,6 +1454,13 @@ void Framework::InitCountryInfoGetter()
m_infoGetter->InitAffiliationsInfo(&m_storage.GetAffiliations());
}
+void Framework::InitUGC()
+{
+ ASSERT(!m_ugcApi.get(), ("InitUGC() must be called only once."));
+
+ m_ugcApi = make_unique<ugc::Api>(m_model.GetIndex());
+}
+
void Framework::InitSearchEngine()
{
ASSERT(!m_searchEngine.get(), ("InitSearchEngine() must be called only once."));
diff --git a/map/framework.hpp b/map/framework.hpp
index 23048ff924..d25135df7f 100644
--- a/map/framework.hpp
+++ b/map/framework.hpp
@@ -21,6 +21,8 @@
#include "drape/oglcontextfactory.hpp"
+#include "ugc/api.hpp"
+
#include "indexer/data_header.hpp"
#include "indexer/index_helpers.hpp"
#include "indexer/map_style.hpp"
@@ -156,6 +158,8 @@ protected:
// search::Engine and, therefore, destroyed after search::Engine.
unique_ptr<storage::CountryInfoGetter> m_infoGetter;
+ unique_ptr<ugc::Api> m_ugcApi;
+
unique_ptr<search::Engine> m_searchEngine;
search::QuerySaver m_searchQuerySaver;
@@ -306,6 +310,8 @@ public:
Index const & GetIndex() const { return m_model.GetIndex(); }
+ ugc::Api & GetUGCApi() { return *m_ugcApi; }
+
search::Engine & GetSearchEngine() { return *m_searchEngine; }
search::Engine const & GetSearchEngine() const { return *m_searchEngine; }
@@ -524,6 +530,7 @@ private:
};
void InitCountryInfoGetter();
+ void InitUGC();
void InitSearchEngine();
DisplacementModeManager m_displacementModeManager;
diff --git a/map/map_tests/CMakeLists.txt b/map/map_tests/CMakeLists.txt
index b4d3696837..692c7535c7 100644
--- a/map/map_tests/CMakeLists.txt
+++ b/map/map_tests/CMakeLists.txt
@@ -32,6 +32,7 @@ omim_link_libraries(
storage
tracking
drape
+ ugc
indexer
partners_api
local_ads
diff --git a/qt/CMakeLists.txt b/qt/CMakeLists.txt
index e997164c96..37195fb95c 100644
--- a/qt/CMakeLists.txt
+++ b/qt/CMakeLists.txt
@@ -85,6 +85,7 @@ omim_link_libraries(
tracking
traffic
routing_common
+ ugc
indexer
drape
partners_api
diff --git a/search/search_quality/assessment_tool/CMakeLists.txt b/search/search_quality/assessment_tool/CMakeLists.txt
index ea3cc2aedd..072c0352b7 100644
--- a/search/search_quality/assessment_tool/CMakeLists.txt
+++ b/search/search_quality/assessment_tool/CMakeLists.txt
@@ -45,6 +45,7 @@ omim_link_libraries(
tracking
traffic
routing_common
+ ugc
indexer
drape
partners_api
diff --git a/storage/storage_integration_tests/CMakeLists.txt b/storage/storage_integration_tests/CMakeLists.txt
index 3d83d1ca61..50e68d1a05 100644
--- a/storage/storage_integration_tests/CMakeLists.txt
+++ b/storage/storage_integration_tests/CMakeLists.txt
@@ -27,6 +27,7 @@ omim_link_libraries(
storage
tracking
traffic
+ ugc
indexer
drape
partners_api
diff --git a/storage/storage_tests/CMakeLists.txt b/storage/storage_tests/CMakeLists.txt
index 015d07b4df..3c4c029a28 100644
--- a/storage/storage_tests/CMakeLists.txt
+++ b/storage/storage_tests/CMakeLists.txt
@@ -33,6 +33,7 @@ omim_link_libraries(
search
routing
routing_common
+ ugc
indexer
platform_tests_support
osrm
diff --git a/ugc/CMakeLists.txt b/ugc/CMakeLists.txt
new file mode 100644
index 0000000000..20baffbe60
--- /dev/null
+++ b/ugc/CMakeLists.txt
@@ -0,0 +1,9 @@
+project(ugc)
+
+set(
+ SRC
+ api.cpp
+ api.hpp
+)
+
+add_library(${PROJECT_NAME} ${SRC})
diff --git a/ugc/api.cpp b/ugc/api.cpp
new file mode 100644
index 0000000000..12ffd23e15
--- /dev/null
+++ b/ugc/api.cpp
@@ -0,0 +1,34 @@
+#include "ugc/api.hpp"
+
+#include "indexer/feature_decl.hpp"
+
+#include "platform/platform.hpp"
+
+using namespace std;
+
+namespace ugc
+{
+Api::Api(Index const & index) : m_index(index) {}
+
+void Api::GetStaticUGC(FeatureID const & id, Callback callback)
+{
+ m_thread.Push([=]() { GetStaticUGCImpl(id, callback); });
+}
+
+void Api::GetDynamicUGC(FeatureID const & id, Callback callback)
+{
+ m_thread.Push([=]() { GetDynamicUGCImpl(id, callback); });
+}
+
+void Api::GetStaticUGCImpl(FeatureID const & /* id */, Callback callback)
+{
+ // TODO (@y, @mgsergio): retrieve static UGC
+ GetPlatform().RunOnGuiThread(callback);
+}
+
+void Api::GetDynamicUGCImpl(FeatureID const & /* id */, Callback callback)
+{
+ // TODO (@y, @mgsergio): retrieve dynamic UGC
+ GetPlatform().RunOnGuiThread(callback);
+}
+} // namespace ugc
diff --git a/ugc/api.hpp b/ugc/api.hpp
new file mode 100644
index 0000000000..8b13853eae
--- /dev/null
+++ b/ugc/api.hpp
@@ -0,0 +1,30 @@
+#pragma once
+
+#include "base/worker_thread.hpp"
+
+#include <functional>
+
+class Index;
+struct FeatureID;
+
+namespace ugc
+{
+class Api
+{
+public:
+ // TODO (@y, @mgsergio): replace void() by void(UGC const &).
+ using Callback = std::function<void()>;
+
+ explicit Api(Index const & index);
+
+ void GetStaticUGC(FeatureID const & id, Callback callback);
+ void GetDynamicUGC(FeatureID const & id, Callback callback);
+
+private:
+ void GetStaticUGCImpl(FeatureID const & id, Callback callback);
+ void GetDynamicUGCImpl(FeatureID const & id, Callback callback);
+
+ Index const & m_index;
+ base::WorkerThread m_thread;
+};
+} // namespace ugc