Files
comaps/search/categories_cache.hpp
Konstantin Pastbin e3e4a1985a Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run:
  git remote add om-historic [om-historic.git repo url]
  git fetch --tags om-historic
  git replace squashed-history historic-commits
2025-05-08 21:10:51 +07:00

98 lines
2.1 KiB
C++

#pragma once
#include "search/categories_set.hpp"
#include "search/cbv.hpp"
#include "indexer/mwm_set.hpp"
#include "base/cancellable.hpp"
#include <map>
#include <vector>
namespace search
{
class MwmContext;
class CategoriesCache
{
public:
template <typename TypesSource>
CategoriesCache(TypesSource const & source, base::Cancellable const & cancellable)
: m_cancellable(cancellable)
{
source.ForEachType([this](uint32_t type) { m_categories.Add(type); });
}
CategoriesCache(std::vector<uint32_t> const & types, base::Cancellable const & cancellable)
: m_cancellable(cancellable)
{
for (uint32_t type : types)
m_categories.Add(type);
}
virtual ~CategoriesCache() = default;
CBV Get(MwmContext const & context);
inline void Clear() { m_cache.clear(); }
private:
CBV Load(MwmContext const & context) const;
CategoriesSet m_categories;
base::Cancellable const & m_cancellable;
std::map<MwmSet::MwmId, CBV> m_cache;
};
class StreetsCache : public CategoriesCache
{
public:
StreetsCache(base::Cancellable const & cancellable);
};
class SuburbsCache : public CategoriesCache
{
public:
SuburbsCache(base::Cancellable const & cancellable);
};
class VillagesCache : public CategoriesCache
{
public:
VillagesCache(base::Cancellable const & cancellable);
};
class CountriesCache : public CategoriesCache
{
public:
CountriesCache(base::Cancellable const & cancellable);
};
class StatesCache : public CategoriesCache
{
public:
StatesCache(base::Cancellable const & cancellable);
};
// Used for cities/towns/villages from world. Currently we do not have villages in World.mwm but
// it may be good to put some important villages to it: mountain/beach resorts.
class CitiesTownsOrVillagesCache : public CategoriesCache
{
public:
CitiesTownsOrVillagesCache(base::Cancellable const & cancellable);
};
class HotelsCache : public CategoriesCache
{
public:
HotelsCache(base::Cancellable const & cancellable);
};
class FoodCache : public CategoriesCache
{
public:
FoodCache(base::Cancellable const & cancellable);
};
} // namespace search