| 85 | } |
| 86 | |
| 87 | Key RulesHolder::AddRule(int scale, TypeT type, BaseRule * p) |
| 88 | { |
| 89 | ASSERT(0 <= scale && scale <= scales::GetUpperStyleScale(), (scale)); |
| 90 | ASSERT(0 <= type && type < count_of_rules, ()); |
| 91 | |
| 92 | m_dRules.push_back(p); |
| 93 | auto const index = m_dRules.size() - 1; |
| 94 | Key const k(scale, type, index); |
| 95 | |
| 96 | ASSERT(Find(k) == p, (index)); |
| 97 | return k; |
| 98 | } |
| 99 | |
| 100 | BaseRule const * RulesHolder::Find(Key const & k) const |
| 101 | { |
| 102 | ASSERT_LESS(k.m_index, m_dRules.size(), ()); |
| 103 | return m_dRules[k.m_index]; |
| 104 | } |
| 105 | |
| 106 | uint32_t RulesHolder::GetBgColor(int scale) const |
| 107 | { |
| 108 | ASSERT_LESS(scale, static_cast<int>(m_bgColors.size()), ()); |
| 109 | ASSERT_GREATER_OR_EQUAL(scale, 0, ()); |
| 110 | return m_bgColors[scale]; |
| 111 | } |
| 112 | |
| 113 | uint32_t RulesHolder::GetColor(std::string const & name) const |
| 114 | { |
| 115 | auto const it = m_colors.find(name); |
| 116 | if (it == m_colors.end()) |
| 117 | { |
| 118 | LOG(LWARNING, ("Requested color '" + name + "' is not found")); |
| 119 | return 0; |
| 120 | } |
| 121 | return it->second; |
| 122 | } |
| 123 | |
| 124 | namespace |
| 125 | { |
| 126 | RulesHolder & rules(MapStyle mapStyle) |
| 127 | { |
| 128 | static RulesHolder h[MapStyleCount]; |
| 129 | return h[mapStyle]; |
| 130 | } |
| 131 | } // namespace |
| 132 | |
| 133 | RulesHolder & rules() |
| 134 | { |
| 135 | return rules(GetStyleReader().GetCurrentStyle()); |
| 136 | } |
| 137 | |
| 138 | namespace |
| 139 | { |
| 140 | namespace proto_rules |
| 141 | { |
| 142 | class Line : public BaseRule |
| 143 | { |
| 144 | LineRuleProto m_line; |
no test coverage detected