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

everywhere_search_callback.cpp « map - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fa524c8a853696174f01c9346974ef8954e4c5de (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
#include "map/everywhere_search_callback.hpp"

#include <cstddef>
#include <utility>

namespace search
{
EverywhereSearchCallback::EverywhereSearchCallback(
    Delegate & hotelsDelegate, ProductInfo::Delegate & productInfoDelegate,
    booking::filter::Tasks const & bookingFilterTasks, EverywhereSearchParams::OnResults onResults)
  : m_hotelsDelegate(hotelsDelegate)
  , m_productInfoDelegate(productInfoDelegate)
  , m_onResults(std::move(onResults))
  , m_bookingFilterTasks(bookingFilterTasks)
{
}

void EverywhereSearchCallback::operator()(Results const & results)
{
  auto const prevSize = m_productInfo.size();
  ASSERT_LESS_OR_EQUAL(prevSize, results.GetCount(), ());

  LOG(LINFO, ("Emitted", results.GetCount() - prevSize, "search results."));

  for (size_t i = prevSize; i < results.GetCount(); ++i)
  {
    m_productInfo.push_back(m_productInfoDelegate.GetProductInfo(results[i]));
  }

  if (results.IsEndedNormal() && results.GetType() == Results::Type::Hotels &&
      !m_bookingFilterTasks.IsEmpty())
  {
    m_hotelsDelegate.FilterResultsForHotelsQuery(m_bookingFilterTasks, results,
                                                 false /* inViewport */);
  }

  ASSERT_EQUAL(m_productInfo.size(), results.GetCount(), ());
  m_onResults(results, m_productInfo);
}
}  // namespace search