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

emitter.hpp « search - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: eb51542932981cadc946795185e59d60cea1487c (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
#pragma once

#include "search/result.hpp"
#include "search/search_params.hpp"

#include "base/logging.hpp"

namespace search
{
class Emitter
{
public:
  inline void Init(SearchParams::TOnResults onResults)
  {
    m_onResults = onResults;
    m_results.Clear();
  }

  inline bool AddResult(Result && res) { return m_results.AddResult(move(res)); }
  inline void AddResultNoChecks(Result && res) { m_results.AddResultNoChecks(move(res)); }

  inline void Emit()
  {
    if (m_onResults)
      m_onResults(m_results);
    else
      LOG(LERROR, ("OnResults is not set."));
  }

  inline Results const & GetResults() const { return m_results; }

  inline void Finish(bool cancelled)
  {
    if (m_onResults)
      m_onResults(Results::GetEndMarker(cancelled));
    else
      LOG(LERROR, ("OnResults is not set."));
  }

private:
  SearchParams::TOnResults m_onResults;
  Results m_results;
};
}  // namespace search