Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvng <viktor.govako@gmail.com>2012-07-13 00:28:42 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:40:57 +0300
commit01857d535e997b23c901abfc1dbbf87e811b1e4f (patch)
tree75bc8d98205cf696112e49d23c8c3f903d4996be /indexer
parentc360cb50628b4d031ff8b0637b22ec3e23bb96d5 (diff)
Minor changes.
Diffstat (limited to 'indexer')
-rw-r--r--indexer/index.hpp23
-rw-r--r--indexer/mwm_set.cpp17
-rw-r--r--indexer/mwm_set.hpp21
3 files changed, 35 insertions, 26 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<MwmId>(-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<MwmInfo> m_info;