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: c1e57648f58f8b5c0edffec7336d0d072ddbc278 (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
#pragma once

#include "../geometry/point2d.hpp"

#include "../std/function.hpp"
#include "../std/string.hpp"


namespace search
{
  class Results;
  typedef function<void (Results const &)> SearchCallbackT;

  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; }
    //@}

    /// @name Search modes.
    //@{
    enum SearchModeT
    {
      AROUND_POSITION = 1,
      IN_VIEWPORT = 2,
      SEARCH_WORLD = 4,
      SEARCH_ADDRESS = 8,
      ALL = AROUND_POSITION | IN_VIEWPORT | SEARCH_WORLD | SEARCH_ADDRESS
    };

    void SetSearchMode(int mode) { m_searchMode = mode; }
    bool NeedSearch(SearchModeT mode) const { return ((m_searchMode & mode) != 0); }
    //@}

    void SetPosition(double lat, double lon);
    bool IsValidPosition() const { return m_validPos; }

    /// @param[in] language can be "fr", "en-US", "ru_RU" etc.
    void SetInputLanguage(string const & language);
    bool IsLanguageValid() const;

    bool IsEqualCommon(SearchParams const & rhs) const;

  public:
    SearchCallbackT m_callback;

    string m_query;
    /// Can be -1 (@see StringUtf8Multilang::UNSUPPORTED_LANGUAGE_CODE),
    /// in the case when input language is unknown.
    int8_t m_inputLanguageCode;

    double m_lat, m_lon;

    friend string DebugPrint(SearchParams const & params);

  private:
    int m_searchMode;
    bool m_forceSearch, m_validPos;
  };

} // namespace search