diff options
Diffstat (limited to 'indexer')
-rw-r--r-- | indexer/index.cpp | 38 | ||||
-rw-r--r-- | indexer/index.hpp | 26 | ||||
-rw-r--r-- | indexer/mwm_set.cpp | 7 | ||||
-rw-r--r-- | indexer/mwm_set.hpp | 1 |
4 files changed, 54 insertions, 18 deletions
diff --git a/indexer/index.cpp b/indexer/index.cpp index cd6989798d..ec00db4d9d 100644 --- a/indexer/index.cpp +++ b/indexer/index.cpp @@ -2,16 +2,43 @@ #include "data_header.hpp" #include "../platform/platform.hpp" +#include "../platform/file_name_utils.hpp" #include "../coding/internal/file_data.hpp" +////////////////////////////////////////////////////////////////////////////////// +// MwmValue implementation +////////////////////////////////////////////////////////////////////////////////// + MwmValue::MwmValue(string const & name) - : m_cont(GetPlatform().GetReader(name)), m_name(name) + : m_cont(GetPlatform().GetReader(name)) { m_factory.Load(m_cont); } +string MwmValue::GetFileName() const +{ + string s = m_cont.GetFileName(); + pl::GetNameFromURLRequest(s); + pl::GetNameWithoutExt(s); + return s; +} + +////////////////////////////////////////////////////////////////////////////////// +// Index::MwmLock implementation +////////////////////////////////////////////////////////////////////////////////// + +string Index::MwmLock::GetFileName() const +{ + MwmValue * p = GetValue(); + return (p ? p->GetFileName() : string()); +} + +////////////////////////////////////////////////////////////////////////////////// +// Index implementation +////////////////////////////////////////////////////////////////////////////////// + int Index::GetInfo(string const & name, MwmInfo & info) const { MwmValue value(name); @@ -121,6 +148,10 @@ void Index::UpdateMwmInfo(MwmId id) } } +////////////////////////////////////////////////////////////////////////////////// +// Index::FeaturesLoaderGuard implementation +////////////////////////////////////////////////////////////////////////////////// + Index::FeaturesLoaderGuard::FeaturesLoaderGuard(Index const & parent, MwmId id) : m_lock(parent, id), /// @note This guard is suitable when mwm is loaded @@ -128,6 +159,11 @@ Index::FeaturesLoaderGuard::FeaturesLoaderGuard(Index const & parent, MwmId id) { } +bool Index::FeaturesLoaderGuard::IsWorld() const +{ + return (m_lock.GetValue()->GetHeader().GetType() == feature::DataHeader::world); +} + void Index::FeaturesLoaderGuard::GetFeature(uint32_t offset, FeatureType & ft) { m_vector.Get(offset, ft); diff --git a/indexer/index.hpp b/indexer/index.hpp index 669624f6e9..40a5423b07 100644 --- a/indexer/index.hpp +++ b/indexer/index.hpp @@ -18,17 +18,17 @@ class MwmValue : public MwmSet::MwmValueBase { public: FilesContainerR m_cont; - string m_name; IndexFactory m_factory; explicit MwmValue(string const & name); - inline feature::DataHeader const & GetHeader() const - { - return m_factory.GetHeader(); - } + inline feature::DataHeader const & GetHeader() const { return m_factory.GetHeader(); } + + /// @return MWM file name without extension. + string GetFileName() const; }; + class Index : public MwmSet { protected: @@ -43,17 +43,19 @@ public: class MwmLock : public MwmSet::MwmLock { + typedef MwmSet::MwmLock BaseT; public: MwmLock(Index const & index, MwmId mwmId) - : MwmSet::MwmLock(const_cast<Index &>(index), mwmId) {} + : BaseT(const_cast<Index &>(index), mwmId) {} inline MwmValue * GetValue() const { - return static_cast<MwmValue *>(MwmSet::MwmLock::GetValue()); + return static_cast<MwmValue *>(BaseT::GetValue()); } - inline FilesContainerR const & GetContainer() const { return GetValue()->m_cont; } - inline feature::DataHeader const & GetHeader() const { return GetValue()->GetHeader(); } + /// @return MWM file name without extension. + /// If value is 0, an empty string returned. + string GetFileName() const; }; bool DeleteMap(string const & fileName); @@ -82,8 +84,14 @@ public: { MwmLock m_lock; FeaturesVector m_vector; + public: FeaturesLoaderGuard(Index const & parent, MwmId id); + + inline MwmSet::MwmId GetID() const { return m_lock.GetID(); } + inline string GetFileName() const { return m_lock.GetFileName(); } + + bool IsWorld() const; void GetFeature(uint32_t offset, FeatureType & ft); }; diff --git a/indexer/mwm_set.cpp b/indexer/mwm_set.cpp index 12d34e5dc5..9477616b4a 100644 --- a/indexer/mwm_set.cpp +++ b/indexer/mwm_set.cpp @@ -106,13 +106,6 @@ MwmSet::MwmId MwmSet::GetIdByName(string const & name) return INVALID_MWM_ID; } -string MwmSet::MwmLock::GetCountryName() const -{ - string const & src = m_mwmSet.m_name[m_id]; - ASSERT ( !src.empty(), () ); - return src.substr(0, src.size() - strlen(DATA_FILE_EXTENSION)); -} - int MwmSet::Add(string const & fileName, m2::RectD & rect) { threads::MutexGuard mutexGuard(m_lock); diff --git a/indexer/mwm_set.hpp b/indexer/mwm_set.hpp index 8e7124fd2b..f7ae576c11 100644 --- a/indexer/mwm_set.hpp +++ b/indexer/mwm_set.hpp @@ -62,7 +62,6 @@ public: ~MwmLock(); inline MwmValueBase * GetValue() const { return m_pValue; } - string GetCountryName() const; inline MwmId GetID() const { return m_id; } private: |