From e3b5e4575e74a97c00d4ae9abe53c7447f74d13b Mon Sep 17 00:00:00 2001 From: Yuri Gorshenin Date: Tue, 20 Sep 2016 14:48:47 +0300 Subject: [PATCH] [indexer] Extensions to FeaturesVector. --- indexer/features_vector.cpp | 4 ++++ indexer/features_vector.hpp | 2 ++ indexer/index.cpp | 9 +++++++++ indexer/index.hpp | 2 ++ 4 files changed, 17 insertions(+) diff --git a/indexer/features_vector.cpp b/indexer/features_vector.cpp index 06954a254b..30662819bd 100644 --- a/indexer/features_vector.cpp +++ b/indexer/features_vector.cpp @@ -14,6 +14,10 @@ void FeaturesVector::GetByIndex(uint32_t index, FeatureType & ft) const ft.Deserialize(m_LoadInfo.GetLoader(), &m_buffer[offset]); } +size_t FeaturesVector::GetNumFeatures() const +{ + return m_table ? m_table->size() : 0; +} FeaturesVectorTest::FeaturesVectorTest(string const & filePath) : FeaturesVectorTest((FilesContainerR(filePath, READER_CHUNK_LOG_SIZE, READER_CHUNK_LOG_COUNT))) diff --git a/indexer/features_vector.hpp b/indexer/features_vector.hpp index 6daf2eb093..d19b772fcf 100644 --- a/indexer/features_vector.hpp +++ b/indexer/features_vector.hpp @@ -22,6 +22,8 @@ public: void GetByIndex(uint32_t index, FeatureType & ft) const; + size_t GetNumFeatures() const; + template void ForEach(ToDo && toDo) const { uint32_t index = 0; diff --git a/indexer/index.cpp b/indexer/index.cpp index 6811333464..5f642f40f3 100644 --- a/indexer/index.cpp +++ b/indexer/index.cpp @@ -135,3 +135,12 @@ bool Index::FeaturesLoaderGuard::GetOriginalFeatureByIndex(uint32_t index, Featu ft.SetID(FeatureID(m_handle.GetId(), index)); return true; } + +size_t Index::FeaturesLoaderGuard::GetNumFeatures() const +{ + if (!m_handle.IsAlive()) + return 0; + + ASSERT(m_vector.get(), ()); + return m_vector->GetNumFeatures(); +} diff --git a/indexer/index.hpp b/indexer/index.hpp index 91351a9c6f..b593e25b2f 100644 --- a/indexer/index.hpp +++ b/indexer/index.hpp @@ -285,6 +285,8 @@ public: /// Editor core only method, to get 'untouched', original version of feature. WARN_UNUSED_RESULT bool GetOriginalFeatureByIndex(uint32_t index, FeatureType & ft) const; + size_t GetNumFeatures() const; + private: MwmHandle m_handle; unique_ptr m_vector;