diff options
author | ygorshenin <mipt.vi002@gmail.com> | 2016-05-31 14:39:48 +0300 |
---|---|---|
committer | ygorshenin <mipt.vi002@gmail.com> | 2016-05-31 14:39:48 +0300 |
commit | 59f40d7669598a229ffa4f6269e17234f9af9506 (patch) | |
tree | 9ed19ec401f41a11243a170e433c6d5222760624 /search/processor.hpp | |
parent | d7d2388c454b4046b2053273c29690e75e45468c (diff) | |
parent | 4cb85be42ae4b832e7bc67090cca871a577ebf6b (diff) |
Merge pull request #3362 from mpimenov/processor_v2
[search] Merged Processor and ProcessorV2.
Diffstat (limited to 'search/processor.hpp')
-rw-r--r-- | search/processor.hpp | 81 |
1 files changed, 28 insertions, 53 deletions
diff --git a/search/processor.hpp b/search/processor.hpp index e3febba23c..514b2e1994 100644 --- a/search/processor.hpp +++ b/search/processor.hpp @@ -50,6 +50,12 @@ namespace search struct Locality; struct Region; struct QueryParams; +class ReverseGeocoder; + +namespace v2 +{ +class Geocoder; +} // namespace search::v2 namespace impl { @@ -79,49 +85,44 @@ public: /// @param[in] forceUpdate Pass true (default) to recache feature's ids even /// if viewport is a part of the old cached rect. void SetViewport(m2::RectD const & viewport, bool forceUpdate); - + void SetPreferredLocale(string const & locale); + void SetInputLocale(string const & locale); + void SetQuery(string const & query); // TODO (@y): this function must be removed. void SetRankPivot(m2::PointD const & pivot); - inline string const & GetPivotRegion() const { return m_region; } - inline void SetPosition(m2::PointD const & position) { m_position = position; } - inline m2::PointD const & GetPosition() const { return m_position; } - inline void SetMode(Mode mode) { m_mode = mode; } inline void SetSearchInWorld(bool b) { m_worldSearch = b; } inline void SetSuggestsEnabled(bool enabled) { m_suggestsEnabled = enabled; } + inline void SetPosition(m2::PointD const & position) { m_position = position; } + + inline string const & GetPivotRegion() const { return m_region; } + inline m2::PointD const & GetPosition() const { return m_position; } /// Suggestions language code, not the same as we use in mwm data int8_t m_inputLocaleCode, m_currentLocaleCode; - void SetPreferredLocale(string const & locale); - void SetInputLocale(string const & locale); - - void SetQuery(string const & query); inline bool IsEmptyQuery() const { return (m_prefix.empty() && m_tokens.empty()); } - /// @name Different search functions. + /// @name Various search functions. //@{ - virtual void Search(Results & results, size_t limit) = 0; - virtual void SearchViewportPoints(Results & results) = 0; + void Search(Results & results, size_t limit); + void SearchViewportPoints(Results & results); // Tries to generate a (lat, lon) result from |m_query|. void SearchCoordinates(Results & res) const; //@} - // Get scale level to make geometry index query for current viewport. - virtual int GetQueryIndexScale(m2::RectD const & viewport) const; - - virtual void ClearCaches(); - struct CancelException { }; - /// @name This stuff is public for implementation classes in processor.cpp - /// Do not use it in client code. - //@{ + void InitParams(QueryParams & params); + + void ClearCaches(); - void InitParams(bool localitySearch, QueryParams & params); + // my::Cancellable overrides: + void Reset() override; + void Cancel() override; protected: enum ViewportID @@ -161,16 +162,8 @@ protected: void MakePreResult2(v2::Geocoder::Params const & params, vector<T> & cont, vector<FeatureID> & streets); - /// @param allMWMs Deprecated, need to support old search algorithm. - /// @param oldHouseSearch Deprecated, need to support old search algorithm. - //@{ - void FlushHouses(Results & res, bool allMWMs, vector<FeatureID> const & streets); - - void FlushResults(v2::Geocoder::Params const & params, Results & res, bool allMWMs, - size_t resCount, bool oldHouseSearch); - void FlushViewportResults(v2::Geocoder::Params const & params, Results & res, - bool oldHouseSearch); - //@} + void FlushResults(v2::Geocoder::Params const & params, Results & res, size_t resCount); + void FlushViewportResults(v2::Geocoder::Params const & params, Results & res); void RemoveStringPrefix(string const & str, string & res) const; void GetSuggestion(string const & name, string & suggest) const; @@ -221,30 +214,12 @@ protected: bool m_supportOldFormat; - template <class TParam> - class TCompare - { - using TFunction = function<bool(TParam const &, TParam const &)>; - TFunction m_fn; - - public: - TCompare() : m_fn(0) {} - explicit TCompare(TFunction const & fn) : m_fn(fn) {} - - template <class T> - bool operator()(T const & v1, T const & v2) const - { - return m_fn(v1, v2); - } - }; - - using TQueueCompare = TCompare<impl::PreResult1>; - using TQueue = my::limited_priority_queue<impl::PreResult1, TQueueCompare>; - protected: - PreRanker m_preRanker; bool m_viewportSearch; bool m_keepHouseNumberInQuery; - search::ReverseGeocoder const m_reverseGeocoder; + + PreRanker m_preRanker; + v2::Geocoder m_geocoder; + ReverseGeocoder const m_reverseGeocoder; }; } // namespace search |