From 01857d535e997b23c901abfc1dbbf87e811b1e4f Mon Sep 17 00:00:00 2001 From: vng Date: Thu, 12 Jul 2012 13:28:42 -0700 Subject: Minor changes. --- indexer/index.hpp | 23 +++++++++++------------ indexer/mwm_set.cpp | 17 ++++++++++++----- indexer/mwm_set.hpp | 21 ++++++++++++--------- map/feature_vec_model.cpp | 7 ++++--- map/feature_vec_model.hpp | 2 +- map/framework.cpp | 4 ++-- map/framework.hpp | 25 ++++++------------------- search/feature_offset_match.hpp | 2 +- 8 files changed, 49 insertions(+), 52 deletions(-) diff --git a/indexer/index.hpp b/indexer/index.hpp index 90cd3f0d1e..ff3afbd85f 100644 --- a/indexer/index.hpp +++ b/indexer/index.hpp @@ -5,7 +5,6 @@ #include "features_vector.hpp" #include "scale_index.hpp" #include "mwm_set.hpp" -#include "scales.hpp" #include "../coding/file_container.hpp" @@ -150,19 +149,19 @@ private: if ((mwm[id].m_minScale <= scale && scale <= mwm[id].m_maxScale) && rect.IsIntersect(mwm[id].m_limitRect)) { - /// @todo It's better to avoid hacks with scale comparison. - - if (mwm[id].IsCountry()) + switch (mwm[id].GetType()) { - // process countries first + case MwmInfo::COUNTRY: ProcessMwm(f, id, cov, scale); - } - else - { - if (mwm[id].m_maxScale == scales::GetUpperScale()) - worldID[0] = id; // store WorldCoasts to process - else - worldID[1] = id; // store World to process + break; + + case MwmInfo::COASTS: + worldID[0] = id; + break; + + case MwmInfo::WORLD: + worldID[1] = id; + break; } } } diff --git a/indexer/mwm_set.cpp b/indexer/mwm_set.cpp index dec88bf5df..32dc71e1d8 100644 --- a/indexer/mwm_set.cpp +++ b/indexer/mwm_set.cpp @@ -1,4 +1,5 @@ #include "mwm_set.hpp" +#include "scales.hpp" #include "../../defines.hpp" @@ -16,6 +17,15 @@ MwmInfo::MwmInfo() : m_lockCount(0), m_status(STATUS_REMOVED) // Apply STATUS_ACTIVE before adding to maps container. } +MwmInfo::MwmTypeT MwmInfo::GetType() const +{ + if (m_minScale > 0) return COUNTRY; + if (m_maxScale == scales::GetUpperWorldScale()) return WORLD; + ASSERT_EQUAL(m_maxScale, scales::GetUpperScale(), ()); + return COASTS; +} + + MwmSet::MwmLock::MwmLock(MwmSet & mwmSet, MwmId mwmId) : m_mwmSet(mwmSet), m_id(mwmId), m_pValue(mwmSet.LockValue(mwmId)) { @@ -170,16 +180,13 @@ bool MwmSet::RemoveImpl(string const & fileName) return ret; } -void MwmSet::RemoveAllCountries() +void MwmSet::RemoveAll() { threads::MutexGuard mutexGuard(m_lock); UNUSED_VALUE(mutexGuard); for (MwmId i = 0; i < m_info.size(); ++i) - { - if (m_info[i].IsCountry()) - (void)RemoveImpl(i); - } + (void)RemoveImpl(i); // do not call ClearCache - it's under mutex lock ClearCacheImpl(m_cache.begin(), m_cache.end()); diff --git a/indexer/mwm_set.hpp b/indexer/mwm_set.hpp index 5bde1d3ae3..0a362d7ab0 100644 --- a/indexer/mwm_set.hpp +++ b/indexer/mwm_set.hpp @@ -23,12 +23,14 @@ public: { return (m_status == STATUS_ACTIVE || m_status == STATUS_UPDATE); } - inline bool IsCountry() const { return (m_minScale > 0); } inline bool IsActive() const { return (m_status == STATUS_ACTIVE); } + enum MwmTypeT { COUNTRY, WORLD, COASTS }; + MwmTypeT GetType() const; + enum Status { - STATUS_ACTIVE = 0, + STATUS_ACTIVE, STATUS_TO_REMOVE, STATUS_REMOVED, STATUS_UPDATE @@ -94,8 +96,7 @@ protected: public: void Remove(string const & fileName); - /// Remove all except world boundle mwm's. - void RemoveAllCountries(); + void RemoveAll(); //@} /// @param[in] file File name without extension. @@ -121,10 +122,12 @@ private: MwmValueBase * LockValue(MwmId id); void UnlockValue(MwmId id, MwmValueBase * p); - // Find first removed mwm or add a new one. + /// Find first removed mwm or add a new one. + /// @precondition This function is always called under mutex m_lock. MwmId GetFreeId(); - // Do the cleaning for [beg, end) without acquiring the mutex. + /// Do the cleaning for [beg, end) without acquiring the mutex. + /// @precondition This function is always called under mutex m_lock. void ClearCacheImpl(CacheType::iterator beg, CacheType::iterator end); CacheType m_cache; @@ -134,14 +137,14 @@ protected: static const MwmId INVALID_MWM_ID = static_cast(-1); /// Find mwm with a given name. - /// @note This function is always called under mutex m_lock. + /// @precondition This function is always called under mutex m_lock. MwmId GetIdByName(string const & name); - /// @note This function is always called under mutex m_lock. + /// @precondition This function is always called under mutex m_lock. void ClearCache(MwmId id); /// Update given MwmInfo. - /// @note This function is always called under mutex m_lock. + /// @precondition This function is always called under mutex m_lock. virtual void UpdateMwmInfo(MwmId id); vector m_info; diff --git a/map/feature_vec_model.cpp b/map/feature_vec_model.cpp index 9dd8e52455..4c6c97bc13 100644 --- a/map/feature_vec_model.cpp +++ b/map/feature_vec_model.cpp @@ -68,9 +68,9 @@ bool FeaturesFetcher::UpdateMap(string const & file, m2::RectD & rect) return m_multiIndex.UpdateMap(file, rect); } -void FeaturesFetcher::RemoveAllCountries() +void FeaturesFetcher::RemoveAll() { - m_multiIndex.RemoveAllCountries(); + m_multiIndex.RemoveAll(); } //void FeaturesFetcher::Clean() @@ -91,7 +91,8 @@ bool FeaturesFetcher::IsLoaded(m2::PointD const & pt) const m_multiIndex.GetMwmInfo(info); for (size_t i = 0; i < info.size(); ++i) - if (info[i].IsExist() && info[i].IsCountry() && + if (info[i].IsExist() && + info[i].GetType() == MwmInfo::COUNTRY && info[i].m_limitRect.IsPointInside(pt)) { return true; diff --git a/map/feature_vec_model.hpp b/map/feature_vec_model.hpp index 7232cf83de..479a4619a5 100644 --- a/map/feature_vec_model.hpp +++ b/map/feature_vec_model.hpp @@ -38,7 +38,7 @@ namespace model /// @return MWM format version for file or -1 if error and map was not added int AddMap(string const & file); void RemoveMap(string const & file); - void RemoveAllCountries(); + void RemoveAll(); bool DeleteMap(string const & file); bool UpdateMap(string const & file, m2::RectD & rect); diff --git a/map/framework.cpp b/map/framework.cpp index 0bc52d0cd4..1da28321f2 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -295,7 +295,7 @@ void Framework::AddLocalMaps() void Framework::RemoveLocalMaps() { - m_model.RemoveAllCountries(); + m_model.RemoveAll(); } void Framework::AddBookmark(string const & category, Bookmark const & bm) @@ -552,7 +552,7 @@ void Framework::DrawModel(shared_ptr const & e, Invalidate(); } -bool Framework::IsCountryLoaded(m2::PointD const & pt) +bool Framework::IsCountryLoaded(m2::PointD const & pt) const { // Correct, but slow version (check country polygon). string const fName = GetSearchEngine()->GetCountryFile(pt); diff --git a/map/framework.hpp b/map/framework.hpp index 518edc27cc..00386421d7 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -1,7 +1,6 @@ #pragma once #include "events.hpp" -//#include "drawer_yg.hpp" #include "render_policy.hpp" #include "information_display.hpp" #include "window_handle.hpp" @@ -16,30 +15,16 @@ #include "../storage/storage.hpp" -//#include "../indexer/mercator.hpp" -//#include "../indexer/data_header.hpp" -//#include "../indexer/scales.hpp" - -//#include "../platform/platform.hpp" #include "../platform/location.hpp" #include "../yg/defines.hpp" #include "../yg/screen.hpp" #include "../yg/color.hpp" -//#include "../yg/render_state.hpp" -//#include "../yg/skin.hpp" -//#include "../yg/resource_manager.hpp" -//#include "../yg/overlay.hpp" - -//#include "../coding/file_reader.hpp" -//#include "../coding/file_writer.hpp" #include "../geometry/rect2d.hpp" #include "../geometry/screenbase.hpp" #include "../base/logging.hpp" -//#include "../base/mutex.hpp" -//#include "../base/timer.hpp" #include "../base/strings_bundle.hpp" #include "../std/vector.hpp" @@ -50,8 +35,6 @@ //#define DRAW_TOUCH_POINTS -//class DrawerYG; -//class RenderPolicy; namespace search { class Result; } namespace gui { class Controller; } @@ -60,7 +43,6 @@ class CountryStatusDisplay; class Framework { protected: - StringsBundle m_stringsBundle; mutable scoped_ptr m_pSearchEngine; @@ -136,8 +118,13 @@ public: void AddMap(string const & file); void RemoveMap(string const & datFile); + + /// @name Process storage connecting/disconnecting. + //@{ void AddLocalMaps(); void RemoveLocalMaps(); + //@} + /// @return File names without path. void GetLocalMaps(vector & outMaps) const; @@ -338,5 +325,5 @@ public: } private: - bool IsCountryLoaded(m2::PointD const & pt); + bool IsCountryLoaded(m2::PointD const & pt) const; }; diff --git a/search/feature_offset_match.hpp b/search/feature_offset_match.hpp index 5fd2ea09d1..a0a183c631 100644 --- a/search/feature_offset_match.hpp +++ b/search/feature_offset_match.hpp @@ -147,7 +147,7 @@ void PrefixMatchInTrie(TrieIterator const & trieRoot, f(pIter->m_value[i]); for (size_t i = 0; i < pIter->m_edge.size(); ++i) - trieQueue.push(pIter->GoToEdge(i)); + trieQueue.push(pIter->GoToEdge(i)); } } -- cgit v1.2.3