diff --git a/map/framework.cpp b/map/framework.cpp index 2207c8ee9f..3ad2c9f633 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -81,6 +81,7 @@ #include "geometry/angles.hpp" #include "geometry/any_rect2d.hpp" #include "geometry/distance_on_sphere.hpp" +#include "geometry/latlon.hpp" #include "geometry/rect2d.hpp" #include "geometry/tree4d.hpp" #include "geometry/triangle2d.hpp" @@ -1656,7 +1657,7 @@ void Framework::SetCurrentPositionIfPossible(search::SearchParams & params) double lat; double lon; if (GetCurrentPosition(lat, lon)) - params.SetPosition(lat, lon); + params.SetPosition(ms::LatLon(lat, lon)); } bool Framework::QueryMayBeSkipped(SearchIntent const & intent, search::SearchParams const & params, diff --git a/search/downloader_search_callback.hpp b/search/downloader_search_callback.hpp index d716ba200d..05d584a99b 100644 --- a/search/downloader_search_callback.hpp +++ b/search/downloader_search_callback.hpp @@ -25,7 +25,7 @@ public: public: virtual ~Delegate() = default; - virtual void RunUITask(function fn) = 0; + virtual void RunUITask(std::function fn) = 0; }; DownloaderSearchCallback(Delegate & delegate, Index const & index, diff --git a/search/emitter.hpp b/search/emitter.hpp index dc4d239d4a..9d19fb96cd 100644 --- a/search/emitter.hpp +++ b/search/emitter.hpp @@ -10,7 +10,7 @@ namespace search class Emitter { public: - inline void Init(SearchParams::TOnResults onResults) + inline void Init(SearchParams::OnResults onResults) { m_onResults = onResults; m_results.Clear(); @@ -39,7 +39,7 @@ public: } private: - SearchParams::TOnResults m_onResults; + SearchParams::OnResults m_onResults; Results m_results; }; } // namespace search diff --git a/search/everywhere_search_params.hpp b/search/everywhere_search_params.hpp index 1eaa264cd1..ae2db980e4 100644 --- a/search/everywhere_search_params.hpp +++ b/search/everywhere_search_params.hpp @@ -4,20 +4,21 @@ #include "search/result.hpp" #include "search/search_params.hpp" -#include "std/functional.hpp" -#include "std/string.hpp" -#include "std/vector.hpp" +#include +#include +#include +#include namespace search { struct EverywhereSearchParams { using OnResults = - function const & isLocalAdsCustomer)>; + std::function const & isLocalAdsCustomer)>; - string m_query; - string m_inputLocale; - shared_ptr m_hotelsFilter; + std::string m_query; + std::string m_inputLocale; + std::shared_ptr m_hotelsFilter; OnResults m_onResults; }; diff --git a/search/processor.hpp b/search/processor.hpp index f7f8360caa..63ece13107 100644 --- a/search/processor.hpp +++ b/search/processor.hpp @@ -91,7 +91,7 @@ public: { m_minDistanceOnMapBetweenResults = distance; } - inline void SetOnResults(SearchParams::TOnResults const & onResults) { m_onResults = onResults; } + inline void SetOnResults(SearchParams::OnResults const & onResults) { m_onResults = onResults; } inline string const & GetPivotRegion() const { return m_region; } inline m2::PointD const & GetPosition() const { return m_position; } @@ -167,7 +167,7 @@ protected: bool m_suggestsEnabled; shared_ptr m_hotelsFilter; bool m_cianMode = false; - SearchParams::TOnResults m_onResults; + SearchParams::OnResults m_onResults; /// @name Get ranking params. //@{ diff --git a/search/search_params.cpp b/search/search_params.cpp index 855b2e514b..961333dc5f 100644 --- a/search/search_params.cpp +++ b/search/search_params.cpp @@ -6,38 +6,38 @@ #include "base/assert.hpp" +#include + +using namespace std; + namespace search { -void SearchParams::SetPosition(double lat, double lon) -{ - m_lat = lat; - m_lon = lon; - m_validPos = true; -} - m2::PointD SearchParams::GetPositionMercator() const { ASSERT(IsValidPosition(), ()); - return MercatorBounds::FromLatLon(m_lat, m_lon); + return MercatorBounds::FromLatLon(*m_position); } ms::LatLon SearchParams::GetPositionLatLon() const { ASSERT(IsValidPosition(), ()); - return ms::LatLon(m_lat, m_lon); + return *m_position; } bool SearchParams::IsEqualCommon(SearchParams const & rhs) const { return m_query == rhs.m_query && m_inputLocale == rhs.m_inputLocale && - m_validPos == rhs.m_validPos && m_mode == rhs.m_mode; + IsValidPosition() == rhs.IsValidPosition() && m_mode == rhs.m_mode; } string DebugPrint(SearchParams const & params) { - ostringstream ss; - ss << "{ SearchParams: Query = " << params.m_query << ", Locale = " << params.m_inputLocale - << ", Mode = " << DebugPrint(params.m_mode) << " }"; - return ss.str(); + ostringstream os; + os << "SearchParams ["; + os << "query: " << params.m_query << ", "; + os << "locale: " << params.m_inputLocale << ", "; + os << "mode: " << DebugPrint(params.m_mode); + os << "]"; + return os.str(); } } // namespace search diff --git a/search/search_params.hpp b/search/search_params.hpp index d45cc63e95..ed9e01c047 100644 --- a/search/search_params.hpp +++ b/search/search_params.hpp @@ -7,32 +7,37 @@ #include "geometry/point2d.hpp" #include "geometry/rect2d.hpp" -#include "std/function.hpp" -#include "std/string.hpp" +#include +#include +#include + +#include namespace search { class Results; -class SearchParams +struct SearchParams { -public: - using TOnStarted = function; - using TOnResults = function; + using OnStarted = function; + using OnResults = function; - void SetPosition(double lat, double lon); + void SetPosition(ms::LatLon const & position) { m_position = position; } + bool IsValidPosition() const { return static_cast(m_position); } m2::PointD GetPositionMercator() const; ms::LatLon GetPositionLatLon() const; - inline bool IsValidPosition() const { return m_validPos; } bool IsEqualCommon(SearchParams const & rhs) const; - inline void Clear() { m_query.clear(); } - TOnStarted m_onStarted; - TOnResults m_onResults; + void Clear() { m_query.clear(); } - string m_query; - string m_inputLocale; + OnStarted m_onStarted; + OnResults m_onResults; + + std::string m_query; + std::string m_inputLocale; + + boost::optional m_position; // A minimum distance between search results in meters, needed for // pre-ranking of viewport search results. @@ -42,15 +47,9 @@ public: bool m_forceSearch = false; bool m_suggestsEnabled = true; - shared_ptr m_hotelsFilter; + std::shared_ptr m_hotelsFilter; bool m_cianMode = false; - - friend string DebugPrint(SearchParams const & params); - -private: - double m_lat = 0.0; - double m_lon = 0.0; - - bool m_validPos = false; }; + +std::string DebugPrint(SearchParams const & params); } // namespace search diff --git a/search/search_quality/sample.cpp b/search/search_quality/sample.cpp index 51f1c51692..afc36f916b 100644 --- a/search/search_quality/sample.cpp +++ b/search/search_quality/sample.cpp @@ -192,10 +192,7 @@ void Sample::FillSearchParams(search::SearchParams & params) const params.m_inputLocale = m_locale; params.m_mode = Mode::Everywhere; if (m_posAvailable) - { - auto const latLon = MercatorBounds::ToLatLon(m_pos); - params.SetPosition(latLon.lat, latLon.lon); - } + params.SetPosition(MercatorBounds::ToLatLon(m_pos)); params.m_suggestsEnabled = false; } diff --git a/search/search_quality/sample.hpp b/search/search_quality/sample.hpp index 94cfcdceae..a2a7db4a84 100644 --- a/search/search_quality/sample.hpp +++ b/search/search_quality/sample.hpp @@ -14,7 +14,7 @@ class FeatureType; namespace search { -class SearchParams; +struct SearchParams; struct Sample { diff --git a/search/search_tests_support/test_search_engine.hpp b/search/search_tests_support/test_search_engine.hpp index c67c252001..c312df6185 100644 --- a/search/search_tests_support/test_search_engine.hpp +++ b/search/search_tests_support/test_search_engine.hpp @@ -19,7 +19,7 @@ class CountryInfoGetter; namespace search { -class SearchParams; +struct SearchParams; namespace tests_support { diff --git a/search/search_tests_support/test_search_request.cpp b/search/search_tests_support/test_search_request.cpp index 27a7192a7b..6ed463cb26 100644 --- a/search/search_tests_support/test_search_request.cpp +++ b/search/search_tests_support/test_search_request.cpp @@ -30,8 +30,8 @@ TestSearchRequest::TestSearchRequest(TestSearchEngine & engine, SearchParams par TestSearchRequest::TestSearchRequest(TestSearchEngine & engine, string const & query, string const & locale, Mode mode, m2::RectD const & viewport, - SearchParams::TOnStarted onStarted, - SearchParams::TOnResults onResults) + SearchParams::OnStarted onStarted, + SearchParams::OnResults onResults) : m_engine(engine), m_viewport(viewport) { m_params.m_query = query; @@ -99,7 +99,7 @@ void TestSearchRequest::OnResults(search::Results const & results) } } -void TestSearchRequest::SetCustomOnResults(SearchParams::TOnResults const & onResults) +void TestSearchRequest::SetCustomOnResults(SearchParams::OnResults const & onResults) { m_params.m_onResults = onResults; } diff --git a/search/search_tests_support/test_search_request.hpp b/search/search_tests_support/test_search_request.hpp index 39f40ae9e0..84209169ea 100644 --- a/search/search_tests_support/test_search_request.hpp +++ b/search/search_tests_support/test_search_request.hpp @@ -37,8 +37,8 @@ public: protected: TestSearchRequest(TestSearchEngine & engine, string const & query, string const & locale, - Mode mode, m2::RectD const & viewport, SearchParams::TOnStarted onStarted, - SearchParams::TOnResults onResults); + Mode mode, m2::RectD const & viewport, SearchParams::OnStarted onStarted, + SearchParams::OnResults onResults); // Initiates the search. void Start(); @@ -52,7 +52,7 @@ protected: void OnResults(search::Results const & results); // Overrides the default onResults callback. - void SetCustomOnResults(SearchParams::TOnResults const & onResults); + void SetCustomOnResults(SearchParams::OnResults const & onResults); condition_variable m_cv; mutable mutex m_mu; diff --git a/search/viewport_search_callback.cpp b/search/viewport_search_callback.cpp index 988a68116f..37dcc3d592 100644 --- a/search/viewport_search_callback.cpp +++ b/search/viewport_search_callback.cpp @@ -6,7 +6,7 @@ namespace search { -ViewportSearchCallback::ViewportSearchCallback(Delegate & delegate, TOnResults onResults) +ViewportSearchCallback::ViewportSearchCallback(Delegate & delegate, OnResults onResults) : m_delegate(delegate) , m_onResults(move(onResults)) , m_hotelsModeSet(false) diff --git a/search/viewport_search_callback.hpp b/search/viewport_search_callback.hpp index 61919f5894..8689efbde4 100644 --- a/search/viewport_search_callback.hpp +++ b/search/viewport_search_callback.hpp @@ -3,7 +3,7 @@ #include "search/hotels_classifier.hpp" #include "search/search_params.hpp" -#include "std/function.hpp" +#include namespace search { @@ -20,22 +20,22 @@ public: public: virtual ~Delegate() = default; - virtual void RunUITask(function fn) = 0; + virtual void RunUITask(std::function fn) = 0; virtual void SetHotelDisplacementMode() = 0; virtual bool IsViewportSearchActive() const = 0; virtual void ShowViewportSearchResults(Results const & results) = 0; virtual void ClearViewportSearchResults() = 0; }; - using TOnResults = SearchParams::TOnResults; + using OnResults = SearchParams::OnResults; - ViewportSearchCallback(Delegate & delegate, TOnResults onResults); + ViewportSearchCallback(Delegate & delegate, OnResults onResults); void operator()(Results const & results); private: Delegate & m_delegate; - TOnResults m_onResults; + OnResults m_onResults; bool m_hotelsModeSet; bool m_firstCall; diff --git a/search/viewport_search_params.hpp b/search/viewport_search_params.hpp index 2b34ca8dd0..0e0c6986bf 100644 --- a/search/viewport_search_params.hpp +++ b/search/viewport_search_params.hpp @@ -2,9 +2,9 @@ #include "search/hotels_filter.hpp" -#include "std/function.hpp" -#include "std/shared_ptr.hpp" -#include "std/string.hpp" +#include +#include +#include namespace search { @@ -12,14 +12,14 @@ class Results; struct ViewportSearchParams { - using TOnStarted = function; - using TOnCompleted = function; + using OnStarted = std::function; + using OnCompleted = std::function; - string m_query; - string m_inputLocale; - shared_ptr m_hotelsFilter; + std::string m_query; + std::string m_inputLocale; + std::shared_ptr m_hotelsFilter; - TOnStarted m_onStarted; - TOnCompleted m_onCompleted; + OnStarted m_onStarted; + OnCompleted m_onCompleted; }; } // namespace search diff --git a/storage/downloader_search_params.hpp b/storage/downloader_search_params.hpp index 1b7d4cc981..2312b9033b 100644 --- a/storage/downloader_search_params.hpp +++ b/storage/downloader_search_params.hpp @@ -2,9 +2,9 @@ #include "storage/index.hpp" -#include "std/function.hpp" -#include "std/string.hpp" -#include "std/vector.hpp" +#include +#include +#include namespace storage { @@ -30,15 +30,15 @@ struct DownloaderSearchResult TCountryId m_countryId; /// \brief |m_matchedName| is a name of found feature in case of searching in World.mwm /// and is a local name of mwm (group or leaf) in case of searching in country tree. - string m_matchedName; + std::string m_matchedName; }; struct DownloaderSearchResults { DownloaderSearchResults() : m_endMarker(false) {} - vector m_results; - string m_query; + std::vector m_results; + std::string m_query; /// \brief |m_endMarker| == true if it's the last call of TOnResults callback for the search. /// Otherwise |m_endMarker| == false. bool m_endMarker; @@ -46,14 +46,14 @@ struct DownloaderSearchResults struct DownloaderSearchParams { - using TOnResults = function; + using OnResults = std::function; - TOnResults m_onResults; - string m_query; - string m_inputLocale; + OnResults m_onResults; + std::string m_query; + std::string m_inputLocale; }; -inline string DebugPrint(DownloaderSearchResult const & r) +inline std::string DebugPrint(DownloaderSearchResult const & r) { return "(" + r.m_countryId + " " + r.m_matchedName + ")"; }