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>2016-08-03 13:53:12 +0300
committerYuri Gorshenin <y@maps.me>2016-08-12 18:35:01 +0300
commitb72a10679c823feab5a1789deaabd05618f050ed (patch)
tree86f8167b3ac2af31f506121dcc6dd4918dd9bec5 /search/search_params.hpp
parentca03f82cad913422aaf67fb97b85c5fc542c0f07 (diff)
[search] Refactored search API.
Diffstat (limited to 'search/search_params.hpp')
-rw-r--r--search/search_params.hpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/search/search_params.hpp b/search/search_params.hpp
new file mode 100644
index 0000000000..d3de882ee9
--- /dev/null
+++ b/search/search_params.hpp
@@ -0,0 +1,61 @@
+#pragma once
+
+#include "search/mode.hpp"
+
+#include "geometry/point2d.hpp"
+#include "geometry/rect2d.hpp"
+
+#include "std/function.hpp"
+#include "std/string.hpp"
+
+namespace search
+{
+class Results;
+
+class SearchParams
+{
+public:
+ using TOnStarted = function<void()>;
+ using TOnResults = function<void(Results const &)>;
+
+ SearchParams();
+
+ /// @name Force run search without comparing with previous search params.
+ //@{
+ void SetForceSearch(bool b) { m_forceSearch = b; }
+ bool IsForceSearch() const { return m_forceSearch; }
+ //@}
+
+ inline void SetMode(Mode mode) { m_mode = mode; }
+ inline Mode GetMode() const { return m_mode; }
+ void SetPosition(double lat, double lon);
+ inline bool IsValidPosition() const { return m_validPos; }
+ inline bool IsSearchAroundPosition() const { return (m_searchRadiusM > 0 && IsValidPosition()); }
+ inline void SetSearchRadiusMeters(double radiusM) { m_searchRadiusM = radiusM; }
+ bool GetSearchRect(m2::RectD & rect) const;
+
+ /// @param[in] locale can be "fr", "en-US", "ru_RU" etc.
+ inline void SetInputLocale(string const & locale) { m_inputLocale = locale; }
+ inline void SetSuggestsEnabled(bool enabled) { m_suggestsEnabled = enabled; }
+ inline bool GetSuggestsEnabled() const { return m_suggestsEnabled; }
+ bool IsEqualCommon(SearchParams const & rhs) const;
+
+ inline void Clear() { m_query.clear(); }
+ TOnStarted m_onStarted;
+ TOnResults m_onResults;
+
+ string m_query;
+ string m_inputLocale;
+
+ double m_lat, m_lon;
+
+ friend string DebugPrint(SearchParams const & params);
+
+private:
+ double m_searchRadiusM;
+ Mode m_mode;
+ bool m_forceSearch;
+ bool m_validPos;
+ bool m_suggestsEnabled;
+};
+} // namespace search