Repo created
This commit is contained in:
parent
4af19165ec
commit
68073add76
12458 changed files with 12350765 additions and 2 deletions
96
libs/search/categories_cache.hpp
Normal file
96
libs/search/categories_cache.hpp
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
#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
|
||||
Loading…
Add table
Add a link
Reference in a new issue