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

booking_filter_processor.hpp « map - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0b0a91aa35c4ea57ec471cc40da4ccd9d32d03fa (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
72
73
74
75
#pragma once

#include "map/booking_filter.hpp"
#include "map/booking_filter_params.hpp"

#include "indexer/feature_decl.hpp"

#include "platform/safe_callback.hpp"

#include "base/macros.hpp"

#include <unordered_map>
#include <vector>

class DataSourceBase;

namespace search
{
class Results;
}

namespace booking
{
class Api;

namespace filter
{

struct CachedResult
{
  CachedResult(Type type, std::vector<FeatureID> && featuresSorted)
    : m_type(type)
    , m_featuresSorted(featuresSorted)
  {
  }

  Type m_type;
  std::vector<FeatureID> m_featuresSorted;
};

using CachedResults = std::vector<CachedResult>;

using FillSearchMarksCallback =
    platform::SafeCallback<void(CachedResults results)>;

class FilterProcessor : public FilterBase::Delegate
{
public:
  FilterProcessor(DataSourceBase const & dataSource, booking::Api const & api);

  void ApplyFilters(search::Results const & results, TasksInternal && tasks,
                    ApplicationMode const mode);

  void OnParamsUpdated(Type const type, std::shared_ptr<ParamsBase> const & params);

  void GetFeaturesFromCache(Types const & types, search::Results const & results,
                            FillSearchMarksCallback const & callback);

  // FilterInterface::Delegate overrides:
  DataSourceBase const & GetDataSource() const override;
  Api const & GetApi() const override;

private:
  void ApplyConsecutively(search::Results const & results, TasksInternal & tasks);
  void ApplyIndependently(search::Results const & results, TasksInternal const & tasks);

  DataSourceBase const & m_dataSource;
  Api const & m_api;

  std::unordered_map<Type, FilterPtr> m_filters;

  DISALLOW_COPY_AND_MOVE(FilterProcessor);
};
}  // namespace filter
}  // namespace booking