diff options
author | Yuri Gorshenin <y@maps.me> | 2016-06-03 00:29:19 +0300 |
---|---|---|
committer | Yuri Gorshenin <y@maps.me> | 2016-06-03 16:26:12 +0300 |
commit | 85ee45b48220988cb098e20268000d361434c4e2 (patch) | |
tree | 9f03f1c87d5c2fbae98821efde4029b7a6e17e15 /indexer/index.cpp | |
parent | 573021d80952bb9b82af4bac6b03622c7231b936 (diff) |
Review fixes.
Diffstat (limited to 'indexer/index.cpp')
-rw-r--r-- | indexer/index.cpp | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/indexer/index.cpp b/indexer/index.cpp index 516e460196..830faa1adf 100644 --- a/indexer/index.cpp +++ b/indexer/index.cpp @@ -20,14 +20,23 @@ MwmValue::MwmValue(LocalCountryFile const & localFile) : m_cont(platform::GetCountryReader(localFile, MapOptions::Map)), m_file(localFile) { m_factory.Load(m_cont); +} +void MwmValue::SetTable(MwmInfoEx & info) +{ auto const version = GetHeader().GetFormat(); if (version < version::Format::v5) - ; - else if (version == version::Format::v5) - m_table = feature::FeaturesOffsetsTable::CreateIfNotExistsAndLoad(m_file, m_cont); - else - m_table = feature::FeaturesOffsetsTable::Load(m_cont); + return; + + m_table = info.m_table.lock(); + if (!m_table) + { + if (version == version::Format::v5) + m_table = feature::FeaturesOffsetsTable::CreateIfNotExistsAndLoad(m_file, m_cont); + else + m_table = feature::FeaturesOffsetsTable::Load(m_cont); + info.m_table = m_table; + } } ////////////////////////////////////////////////////////////////////////////////// @@ -42,7 +51,7 @@ unique_ptr<MwmInfo> Index::CreateInfo(platform::LocalCountryFile const & localFi if (!h.IsMWMSuitable()) return nullptr; - auto info = make_unique<MwmInfo>(); + auto info = make_unique<MwmInfoEx>(); info->m_limitRect = h.GetBounds(); pair<int, int> const scaleR = h.GetScaleRange(); @@ -50,7 +59,7 @@ unique_ptr<MwmInfo> Index::CreateInfo(platform::LocalCountryFile const & localFi info->m_maxScale = static_cast<uint8_t>(scaleR.second); info->m_version = value.GetMwmVersion(); - return info; + return unique_ptr<MwmInfo>(move(info)); } unique_ptr<MwmSet::MwmValueBase> Index::CreateValue(MwmInfo & info) const @@ -58,6 +67,7 @@ unique_ptr<MwmSet::MwmValueBase> Index::CreateValue(MwmInfo & info) const // Create a section with rank table if it does not exist. platform::LocalCountryFile const & localFile = info.GetLocalFile(); unique_ptr<MwmValue> p(new MwmValue(localFile)); + p->SetTable(dynamic_cast<MwmInfoEx &>(info)); ASSERT(p->GetHeader().IsMWMSuitable(), ()); return unique_ptr<MwmSet::MwmValueBase>(move(p)); } @@ -75,10 +85,8 @@ bool Index::DeregisterMap(CountryFile const & countryFile) { return Deregister(c Index::FeaturesLoaderGuard::FeaturesLoaderGuard(Index const & parent, MwmId const & id) : m_handle(parent.GetMwmHandleById(id)) - , - /// @note This guard is suitable when mwm is loaded - m_vector(m_handle.GetValue<MwmValue>()->m_cont, m_handle.GetValue<MwmValue>()->GetHeader(), - m_handle.GetValue<MwmValue>()->m_table.get()) + , m_vector(m_handle.GetValue<MwmValue>()->m_cont, m_handle.GetValue<MwmValue>()->GetHeader(), + m_handle.GetValue<MwmValue>()->m_table.get()) { } |