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

params.hpp « search - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 211ffb6c17e47d592cc01b8fba9ababd58032bb1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#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;

  using TOnStarted = function<void()>;
  using TOnResults = function<void (Results const &)>;

  class SearchParams
  {
  public:
    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(); }

  public:
    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