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

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

#include "indexer/ftypes_mapping.hpp"

#include "storage/storage_defines.hpp"

#include "base/macros.hpp"

#include <cstdint>
#include <initializer_list>
#include <string>
#include <unordered_set>

namespace feature
{
class TypesHolder;
}

namespace ads
{
class ContainerBase
{
public:
  virtual ~ContainerBase() = default;
  virtual bool HasBanner(feature::TypesHolder const & types, storage::CountryId const & countryId,
                         std::string const & userLanguage) const = 0;
  virtual std::string GetBannerId(feature::TypesHolder const & types,
                                  storage::CountryId const & countryId,
                                  std::string const & userLanguage) const = 0;
  virtual std::string GetBannerIdForOtherTypes() const = 0;
  virtual bool HasSearchBanner() const = 0;
  virtual std::string GetSearchBannerId() const = 0;
};

// Class which matches feature types and banner ids.
class Container : public ContainerBase
{
public:
  Container();

  // ContainerBase overrides:
  bool HasBanner(feature::TypesHolder const & types, storage::CountryId const & countryId,
                 std::string const & userLanguage) const override;
  std::string GetBannerId(feature::TypesHolder const & types, storage::CountryId const & countryId,
                          std::string const & userLanguage) const override;
  std::string GetBannerIdForOtherTypes() const override;
  bool HasSearchBanner() const override;
  std::string GetSearchBannerId() const override;

protected:
  void AppendEntry(std::initializer_list<std::initializer_list<char const *>> && types,
                   std::string const & id);
  void AppendExcludedTypes(std::initializer_list<std::initializer_list<char const *>> && types);
  void AppendSupportedCountries(std::initializer_list<storage::CountryId> const & countries);
  void AppendSupportedUserLanguages(std::initializer_list<std::string> const & languages);

private:
  ftypes::HashMapMatcher<uint32_t, std::string> m_typesToBanners;
  ftypes::HashSetMatcher<uint32_t> m_excludedTypes;
  // All countries are supported when empty.
  std::unordered_set<storage::CountryId> m_supportedCountries;
  // It supplements |m_supportedCountries|. If a country isn't supported
  // we check user's language.
  std::unordered_set<int8_t> m_supportedUserLanguages;

  DISALLOW_COPY(Container);
};
}  // namespace ads