From ffa964b5a8ac2dc8de4a1b4987834767f47122e6 Mon Sep 17 00:00:00 2001 From: Constantin Shalnev Date: Thu, 14 Jan 2016 16:14:46 +0300 Subject: [PATCH] Added multiple versions of classificators and rule holders --- indexer/classificator.cpp | 13 +++++++++++-- indexer/classificator.hpp | 16 +++++++++------- indexer/drawing_rules.cpp | 12 ++++++++++-- indexer/drawing_rules.hpp | 2 ++ 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/indexer/classificator.cpp b/indexer/classificator.cpp index 8f4ad4dc77..dffebd5610 100644 --- a/indexer/classificator.cpp +++ b/indexer/classificator.cpp @@ -1,5 +1,6 @@ #include "indexer/classificator.hpp" #include "indexer/tree_structure.hpp" +#include "indexer/map_style_reader.hpp" #include "base/macros.hpp" #include "base/logging.hpp" @@ -119,10 +120,18 @@ void ClassifObject::ConcatChildNames(string & s) const // Classificator implementation ///////////////////////////////////////////////////////////////////////////////////////// +Classificator & classif(MapStyle mapStyle) +{ + int const index = static_cast(mapStyle); + ASSERT_GREATER_OR_EQUAL(index, 0, ()); + ASSERT_LESS(index, MapStyleCount, ()); + static Classificator c[MapStyleCount]; + return c[index]; +} + Classificator & classif() { - static Classificator c; - return c; + return classif(GetStyleReader().GetCurrentStyle()); } namespace ftype diff --git a/indexer/classificator.hpp b/indexer/classificator.hpp index 4ec893c923..4d94df78ca 100644 --- a/indexer/classificator.hpp +++ b/indexer/classificator.hpp @@ -1,16 +1,17 @@ #pragma once + #include "indexer/drawing_rule_def.hpp" -#include "indexer/types_mapping.hpp" -#include "indexer/scales.hpp" #include "indexer/feature_decl.hpp" +#include "indexer/map_style.hpp" +#include "indexer/scales.hpp" +#include "indexer/types_mapping.hpp" -#include "std/vector.hpp" -#include "std/string.hpp" -#include "std/iostream.hpp" #include "std/bitset.hpp" -#include "std/noncopyable.hpp" #include "std/initializer_list.hpp" - +#include "std/iostream.hpp" +#include "std/noncopyable.hpp" +#include "std/string.hpp" +#include "std/vector.hpp" class ClassifObject; @@ -222,4 +223,5 @@ public: string GetReadableObjectName(uint32_t type) const; }; +Classificator & classif(MapStyle mapStyle); Classificator & classif(); diff --git a/indexer/drawing_rules.cpp b/indexer/drawing_rules.cpp index 08dd783c5b..8b81b75b07 100644 --- a/indexer/drawing_rules.cpp +++ b/indexer/drawing_rules.cpp @@ -185,10 +185,18 @@ void RulesHolder::ResizeCaches(size_t s) ForEachRule(bind(&BaseRule::CheckCacheSize, _4, s)); } +RulesHolder & rules(MapStyle mapStyle) +{ + int const index = static_cast(mapStyle); + ASSERT_GREATER_OR_EQUAL(index, 0, ()); + ASSERT_LESS(index, MapStyleCount, ()); + static RulesHolder h[MapStyleCount]; + return h[index]; +} + RulesHolder & rules() { - static RulesHolder holder; - return holder; + return rules(GetStyleReader().GetCurrentStyle()); } namespace diff --git a/indexer/drawing_rules.hpp b/indexer/drawing_rules.hpp index 144c5cf47a..27fcabf70a 100644 --- a/indexer/drawing_rules.hpp +++ b/indexer/drawing_rules.hpp @@ -2,6 +2,7 @@ #include "indexer/drawing_rule_def.hpp" #include "indexer/drules_selector.hpp" +#include "indexer/map_style.hpp" #include "base/base.hpp" #include "base/buffer_vector.hpp" @@ -121,6 +122,7 @@ namespace drule void InitBackgroundColors(ContainerProto const & cp); }; + RulesHolder & rules(MapStyle mapStyle); RulesHolder & rules(); void LoadRules();