#pragma once #include "indexer/ftypes_mapping.hpp" #include "storage/index.hpp" #include "base/macros.hpp" #include #include #include #include namespace feature { class TypesHolder; } namespace ads { class ContainerBase { public: virtual ~ContainerBase() = default; virtual bool HasBanner(feature::TypesHolder const & types, storage::TCountryId const & countryId, std::string const & userLanguage) const = 0; virtual std::string GetBannerId(feature::TypesHolder const & types, storage::TCountryId 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::TCountryId const & countryId, std::string const & userLanguage) const override; std::string GetBannerId(feature::TypesHolder const & types, storage::TCountryId 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> && types, std::string const & id); void AppendExcludedTypes(std::initializer_list> && types); void AppendSupportedCountries(std::initializer_list const & countries); void AppendSupportedUserLanguages(std::initializer_list const & languages); private: ftypes::HashMapMatcher m_typesToBanners; ftypes::HashSetMatcher m_excludedTypes; // All countries are supported when empty. std::unordered_set m_supportedCountries; // It supplements |m_supportedCountries|. If a country isn't supported // we check user's language. std::unordered_set m_supportedUserLanguages; DISALLOW_COPY(Container); }; } // namespace ads