diff --git a/android/jni/com/mapswithme/maps/SearchEngine.cpp b/android/jni/com/mapswithme/maps/SearchEngine.cpp index b435c5ca27..6edb18ea13 100644 --- a/android/jni/com/mapswithme/maps/SearchEngine.cpp +++ b/android/jni/com/mapswithme/maps/SearchEngine.cpp @@ -425,7 +425,7 @@ void OnBookmarksSearchResults(search::BookmarksSearchParams::Results const & res env->CallVoidMethod(g_javaListener, method, jResults.get(), static_cast(timestamp)); } -void OnBookingFilterAvailabilityResults(std::shared_ptr const & apiParams, +void OnBookingFilterAvailabilityResults(shared_ptr const & apiParams, vector const & featuresSorted) { auto const it = g_lastBookingFilterTasks.Find(booking::filter::Type::Availability); @@ -437,7 +437,7 @@ void OnBookingFilterAvailabilityResults(std::shared_ptr con if (!it->m_filterParams.m_apiParams->Equals(*apiParams)) return; - ASSERT(std::is_sorted(featuresSorted.cbegin(), featuresSorted.cend()), ()); + ASSERT(is_sorted(featuresSorted.cbegin(), featuresSorted.cend()), ()); JNIEnv * env = jni::GetEnv(); jni::TScopedLocalObjectArrayRef jResults(env, @@ -446,7 +446,7 @@ void OnBookingFilterAvailabilityResults(std::shared_ptr con static_cast(booking::filter::Type::Availability), jResults.get()); } -void OnBookingFilterDealsResults(std::shared_ptr const & apiParams, +void OnBookingFilterDealsResults(shared_ptr const & apiParams, vector const & featuresSorted) { auto const it = g_lastBookingFilterTasks.Find(booking::filter::Type::Deals); @@ -455,10 +455,10 @@ void OnBookingFilterDealsResults(std::shared_ptr const & ap return; // Ignore obsolete booking filter results. - if (!it->m_filterParams.m_apiParams->Equals(*(apiParams))) + if (!it->m_filterParams.m_apiParams->Equals(*apiParams)) return; - ASSERT(std::is_sorted(featuresSorted.cbegin(), featuresSorted.cend()), ()); + ASSERT(is_sorted(featuresSorted.cbegin(), featuresSorted.cend()), ()); JNIEnv * env = jni::GetEnv(); jni::TScopedLocalObjectArrayRef jResults(env, @@ -504,7 +504,7 @@ public: jobjectArray const jrooms = static_cast(env->GetObjectField(bookingFilterParams, m_roomsId)); - ASSERT(jrooms, ("Rooms musn't be non-null!")); + ASSERT(jrooms, ("Rooms must be non-null!")); auto const length = static_cast(env->GetArrayLength(jrooms)); result.m_rooms.resize(length); @@ -551,7 +551,7 @@ public: if (!availabilityParams.IsEmpty()) { - booking::filter::Params p(std::make_shared(availabilityParams), + booking::filter::Params p(make_shared(availabilityParams), bind(&::OnBookingFilterAvailabilityResults, _1, _2)); tasks.EmplaceBack(booking::filter::Type::Availability, move(p)); @@ -561,7 +561,7 @@ public: if (!dealsParams.IsEmpty()) { - booking::filter::Params p(std::make_shared(dealsParams), + booking::filter::Params p(make_shared(dealsParams), bind(&::OnBookingFilterDealsResults, _1, _2)); tasks.EmplaceBack(booking::filter::Type::Deals, move(p)); diff --git a/android/jni/com/mapswithme/maps/SearchEngine.hpp b/android/jni/com/mapswithme/maps/SearchEngine.hpp index 521b510324..968aa0a9a6 100644 --- a/android/jni/com/mapswithme/maps/SearchEngine.hpp +++ b/android/jni/com/mapswithme/maps/SearchEngine.hpp @@ -3,6 +3,7 @@ #include "com/mapswithme/core/jni_helper.hpp" #include "map/everywhere_search_callback.hpp" + #include "search/result.hpp" #include diff --git a/iphone/Maps/Core/Search/MWMSearch.mm b/iphone/Maps/Core/Search/MWMSearch.mm index 5ec7016554..179b92732c 100644 --- a/iphone/Maps/Core/Search/MWMSearch.mm +++ b/iphone/Maps/Core/Search/MWMSearch.mm @@ -169,8 +169,8 @@ using Observers = NSHashTable; dp.m_dealsOnly = true; booking::filter::Params dealsParams(std::make_shared(dp), {}); - tasks.EmplaceBack(booking::filter::Type::Availability, move(availabilityParams)); - tasks.EmplaceBack(booking::filter::Type::Deals, move(dealsParams)); + tasks.EmplaceBack(booking::filter::Type::Availability, std::move(availabilityParams)); + tasks.EmplaceBack(booking::filter::Type::Deals, std::move(dealsParams)); } m_viewportParams.m_bookingFilterTasks = tasks; diff --git a/iphone/Maps/UI/Search/TableView/MWMSearchCommonCell.h b/iphone/Maps/UI/Search/TableView/MWMSearchCommonCell.h index ce3a71db31..61d3728c8b 100644 --- a/iphone/Maps/UI/Search/TableView/MWMSearchCommonCell.h +++ b/iphone/Maps/UI/Search/TableView/MWMSearchCommonCell.h @@ -1,6 +1,7 @@ #import "MWMSearchCell.h" #include "map/everywhere_search_callback.hpp" + #include "search/result.hpp" @interface MWMSearchCommonCell : MWMSearchCell diff --git a/map/booking_filter_params.hpp b/map/booking_filter_params.hpp index 8b317db885..a8630ab7be 100644 --- a/map/booking_filter_params.hpp +++ b/map/booking_filter_params.hpp @@ -7,6 +7,7 @@ #include "indexer/feature_decl.hpp" +#include #include #include #include @@ -68,13 +69,13 @@ struct TaskImpl using Task = TaskImpl; using TaskInternal = TaskImpl; -enum ApplyMode +enum ApplicationMode { /// Apply filters independently on provided list of search results. - /// Every filter will be applied on own copy of search results. + /// Every filter will be applied on its own copy of search results. Independent, /// Apply each filter one by one on provided list of search results. - /// All filters will be applied on joint copy of search results. + /// All filters will be applied on the same copy of search results. Consecutive }; @@ -86,7 +87,7 @@ public: using ConstIter = std::vector::const_iterator; TasksImpl() = default; - explicit TasksImpl(ApplyMode const mode) : m_applyMode(mode) {} + explicit TasksImpl(ApplicationMode const mode) : m_applyMode(mode) {} Iter begin() { return m_tasks.begin(); } Iter end() { return m_tasks.end(); } @@ -95,7 +96,7 @@ public: Iter Find(Type const type) { - return find_if(m_tasks.begin(), m_tasks.end(),[type](Task const & task) + return std::find_if(m_tasks.begin(), m_tasks.end(),[type](Task const & task) { return task.m_type == type; }); @@ -103,7 +104,7 @@ public: ConstIter Find(Type const type) const { - return find_if(m_tasks.cbegin(), m_tasks.cend(),[type](Task const & task) + return std::find_if(m_tasks.cbegin(), m_tasks.cend(),[type](Task const & task) { return task.m_type == type; }); @@ -120,14 +121,14 @@ public: m_tasks.emplace_back(std::forward(args)...); } - ApplyMode GetMode() const + ApplicationMode GetMode() const { return m_applyMode; } private: std::vector m_tasks; - ApplyMode m_applyMode = ApplyMode::Independent; + ApplicationMode m_applyMode = ApplicationMode::Independent; }; using Tasks = TasksImpl; diff --git a/map/booking_filter_processor.cpp b/map/booking_filter_processor.cpp index 58d21821b0..4cfe8a3c0d 100644 --- a/map/booking_filter_processor.cpp +++ b/map/booking_filter_processor.cpp @@ -16,7 +16,7 @@ FilterProcessor::FilterProcessor(Index const & index, booking::Api const & api) } void FilterProcessor::ApplyFilters(search::Results const & results, TasksInternal && tasks, - ApplyMode const mode) + ApplicationMode const mode) { GetPlatform().RunTask(Platform::Thread::File, [this, results, tasks = std::move(tasks), mode]() mutable { diff --git a/map/booking_filter_processor.hpp b/map/booking_filter_processor.hpp index 8bb6ac1477..e95faf4559 100644 --- a/map/booking_filter_processor.hpp +++ b/map/booking_filter_processor.hpp @@ -48,7 +48,8 @@ class FilterProcessor : public FilterBase::Delegate public: FilterProcessor(Index const & index, booking::Api const & api); - void ApplyFilters(search::Results const & results, TasksInternal && tasks, ApplyMode const mode); + void ApplyFilters(search::Results const & results, TasksInternal && tasks, + ApplicationMode const mode); void OnParamsUpdated(Type const type, std::shared_ptr const & params); @@ -62,6 +63,7 @@ public: private: void ApplyConsecutively(search::Results const & results, TasksInternal & tasks); void ApplyIndependently(search::Results const & results, TasksInternal const & tasks); + Index const & m_index; Api const & m_api; diff --git a/map/everywhere_search_callback.cpp b/map/everywhere_search_callback.cpp index 61c9c097bd..b25ebebaa7 100644 --- a/map/everywhere_search_callback.cpp +++ b/map/everywhere_search_callback.cpp @@ -1,4 +1,4 @@ -#include "everywhere_search_callback.hpp" +#include "map/everywhere_search_callback.hpp" #include #include diff --git a/map/framework.cpp b/map/framework.cpp index 4f5b070564..9d6110c242 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -1559,12 +1559,13 @@ size_t Framework::ShowSearchResults(search::Results const & results) void Framework::FillSearchResultsMarks(bool clear, search::Results const & results) { - FillSearchResultsMarks(clear, results.begin(), results.end()); + FillSearchResultsMarks(results.begin(), results.end(), clear, + Framework::SearchMarkPostProcessing()); } -void Framework::FillSearchResultsMarks(bool clear, search::Results::ConstIter begin, - search::Results::ConstIter end, - SearchMarkPostProcessing fn /* = nullptr */) +void Framework::FillSearchResultsMarks(search::Results::ConstIter begin, + search::Results::ConstIter end, bool clear, + SearchMarkPostProcessing fn) { auto editSession = GetBookmarkManager().GetEditSession(); if (clear) @@ -3125,15 +3126,16 @@ void Framework::SetSearchDisplacementModeEnabled(bool enabled) SetDisplacementMode(DisplacementModeManager::SLOT_INTERACTIVE_SEARCH, enabled /* show */); } -void Framework::ShowViewportSearchResults(bool clear, search::Results::ConstIter begin, - search::Results::ConstIter end) +void Framework::ShowViewportSearchResults(search::Results::ConstIter begin, + search::Results::ConstIter end, bool clear) { - FillSearchResultsMarks(clear, begin, end); + FillSearchResultsMarks(begin, end, clear, + Framework::SearchMarkPostProcessing()); } -void Framework::ShowViewportSearchResults(bool clear, booking::filter::Types types, - search::Results::ConstIter begin, - search::Results::ConstIter end) +void Framework::ShowViewportSearchResults(search::Results::ConstIter begin, + search::Results::ConstIter end, bool clear, + booking::filter::Types types) { using booking::filter::Type; using booking::filter::CachedResults; @@ -3165,7 +3167,8 @@ void Framework::ShowViewportSearchResults(bool clear, booking::filter::Types typ } }; - FillSearchResultsMarks(clear, results.begin(), results.end(), postProcessing); + FillSearchResultsMarks(results.begin(), results.end(), clear, + postProcessing); }; m_bookingFilterProcessor.GetFeaturesFromCache(types, results, fillCallback); @@ -3462,10 +3465,10 @@ void Framework::FilterResultsForHotelsQuery(booking::filter::Tasks const & filte } }; - tasksInternal.emplace_back(type, move(paramsInternal)); + tasksInternal.emplace_back(type, std::move(paramsInternal)); } - m_bookingFilterProcessor.ApplyFilters(results, move(tasksInternal), filterTasks.GetMode()); + m_bookingFilterProcessor.ApplyFilters(results, std::move(tasksInternal), filterTasks.GetMode()); } void Framework::OnBookingFilterParamsUpdate(booking::filter::Tasks const & filterTasks) diff --git a/map/framework.hpp b/map/framework.hpp index 2f43d3e131..5bd31099a2 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -342,11 +342,11 @@ public: // SearchAPI::Delegate overrides: void RunUITask(function fn) override; void SetSearchDisplacementModeEnabled(bool enabled) override; - void ShowViewportSearchResults(bool clear, search::Results::ConstIter begin, - search::Results::ConstIter end) override; - void ShowViewportSearchResults(bool clear, booking::filter::Types types, - search::Results::ConstIter begin, - search::Results::ConstIter end) override; + void ShowViewportSearchResults(search::Results::ConstIter begin, + search::Results::ConstIter end, bool clear) override; + void ShowViewportSearchResults(search::Results::ConstIter begin, + search::Results::ConstIter end, bool clear, + booking::filter::Types types) override; void ClearViewportSearchResults() override; boost::optional GetCurrentPosition() const override; bool ParseSearchQueryCommand(search::SearchParams const & params) override; @@ -552,8 +552,8 @@ public: using SearchMarkPostProcessing = function; void FillSearchResultsMarks(bool clear, search::Results const & results); - void FillSearchResultsMarks(bool clear, search::Results::ConstIter begin, - search::Results::ConstIter end, SearchMarkPostProcessing fn = nullptr); + void FillSearchResultsMarks(search::Results::ConstIter begin, search::Results::ConstIter end, + bool clear, SearchMarkPostProcessing fn = nullptr); list const & GetLastSearchQueries() const { return m_searchQuerySaver.Get(); } void SaveSearchQuery(TSearchRequest const & query) { m_searchQuerySaver.Add(query); } void ClearSearchHistory() { m_searchQuerySaver.Clear(); } diff --git a/map/map_integration_tests/interactive_search_test.cpp b/map/map_integration_tests/interactive_search_test.cpp index a92e7e9497..5803383dc2 100644 --- a/map/map_integration_tests/interactive_search_test.cpp +++ b/map/map_integration_tests/interactive_search_test.cpp @@ -1,12 +1,12 @@ #include "testing/testing.hpp" +#include "map/viewport_search_callback.hpp" + #include "search/mode.hpp" #include "search/search_tests_support/helpers.hpp" #include "search/search_tests_support/test_results_matching.hpp" #include "search/search_tests_support/test_search_request.hpp" -#include "map/viewport_search_callback.hpp" - #include "base/macros.hpp" #include @@ -41,16 +41,16 @@ public: bool IsViewportSearchActive() const override { return true; } - void ShowViewportSearchResults(bool clear, Results::ConstIter begin, - Results::ConstIter end) override + void ShowViewportSearchResults(Results::ConstIter begin, Results::ConstIter end, + bool clear) override { if (clear) m_stats.m_numShownResults = 0; m_stats.m_numShownResults += distance(begin, end); } - void ShowViewportSearchResults(bool clear, booking::filter::Types types, - Results::ConstIter begin, Results::ConstIter end) override + void ShowViewportSearchResults(Results::ConstIter begin, Results::ConstIter end, + bool clear, booking::filter::Types types) override { } diff --git a/map/map_tests/booking_filter_test.cpp b/map/map_tests/booking_filter_test.cpp index 2e4e1ac02b..1b03251172 100644 --- a/map/map_tests/booking_filter_test.cpp +++ b/map/map_tests/booking_filter_test.cpp @@ -203,7 +203,7 @@ UNIT_CLASS_TEST(TestMwmEnvironment, BookingFilter_ProcessorSmoke) FilterProcessor processor(GetIndex(), GetApi()); auto tasksCopy = tasks; - processor.ApplyFilters(results, std::move(tasksCopy), ApplyMode::Independent); + processor.ApplyFilters(results, std::move(tasksCopy), ApplicationMode::Independent); testing::Wait(); @@ -224,7 +224,7 @@ UNIT_CLASS_TEST(TestMwmEnvironment, BookingFilter_ProcessorSmoke) TEST_EQUAL(dealsResults[i].GetFeatureID(), expectedDealsResults[i].GetFeatureID(), ()); } - processor.ApplyFilters(results, std::move(tasks), ApplyMode::Consecutive); + processor.ApplyFilters(results, std::move(tasks), ApplicationMode::Consecutive); testing::Wait(); diff --git a/map/search_api.cpp b/map/search_api.cpp index 774eb89c02..6b40fe0212 100644 --- a/map/search_api.cpp +++ b/map/search_api.cpp @@ -337,16 +337,16 @@ bool SearchAPI::IsViewportSearchActive() const return !m_searchIntents[static_cast(Mode::Viewport)].m_params.m_query.empty(); } -void SearchAPI::ShowViewportSearchResults(bool clear, Results::ConstIter begin, - Results::ConstIter end) +void SearchAPI::ShowViewportSearchResults(Results::ConstIter begin, Results::ConstIter end, + bool clear) { - return m_delegate.ShowViewportSearchResults(clear, begin, end); + return m_delegate.ShowViewportSearchResults(begin, end, clear); } -void SearchAPI::ShowViewportSearchResults(bool clear, booking::filter::Types types, - Results::ConstIter begin, Results::ConstIter end) +void SearchAPI::ShowViewportSearchResults(Results::ConstIter begin, Results::ConstIter end, + bool clear, booking::filter::Types types) { - return m_delegate.ShowViewportSearchResults(clear, types, begin, end); + return m_delegate.ShowViewportSearchResults(begin, end, clear, types); } ProductInfo SearchAPI::GetProductInfo(Result const & result) const diff --git a/map/search_api.hpp b/map/search_api.hpp index 96a02d280e..5a7f7354c6 100644 --- a/map/search_api.hpp +++ b/map/search_api.hpp @@ -53,14 +53,14 @@ public: virtual void SetSearchDisplacementModeEnabled(bool /* enabled */) {} - virtual void ShowViewportSearchResults(bool clear, search::Results::ConstIter begin, - search::Results::ConstIter end) + virtual void ShowViewportSearchResults(search::Results::ConstIter begin, + search::Results::ConstIter end, bool clear) { } - virtual void ShowViewportSearchResults(bool clear, booking::filter::Types types, - search::Results::ConstIter begin, - search::Results::ConstIter end) + virtual void ShowViewportSearchResults(search::Results::ConstIter begin, + search::Results::ConstIter end, bool clear, + booking::filter::Types types) { } @@ -124,11 +124,11 @@ public: void RunUITask(std::function fn) override; void SetHotelDisplacementMode() override; bool IsViewportSearchActive() const override; - void ShowViewportSearchResults(bool clear, search::Results::ConstIter begin, - search::Results::ConstIter end) override; - void ShowViewportSearchResults(bool clear, booking::filter::Types types, - search::Results::ConstIter begin, - search::Results::ConstIter end) override; + void ShowViewportSearchResults(search::Results::ConstIter begin, + search::Results::ConstIter end, bool clear) override; + void ShowViewportSearchResults(search::Results::ConstIter begin, + search::Results::ConstIter end, bool clear, + booking::filter::Types types) override; search::ProductInfo GetProductInfo(search::Result const & result) const override; void FilterResultsForHotelsQuery(booking::filter::Tasks const & filterTasks, search::Results const & results, bool inViewport) override; diff --git a/map/viewport_search_callback.cpp b/map/viewport_search_callback.cpp index 76d3ca6fcc..b850c41f8f 100644 --- a/map/viewport_search_callback.cpp +++ b/map/viewport_search_callback.cpp @@ -17,10 +17,10 @@ booking::filter::Types FillBookingFilterTypes(search::Results const & results, { case Type::Deals: if (results.GetType() == search::Results::Type::Hotels) - types.push_back(Type::Deals); + types.emplace_back(Type::Deals); break; case Type::Availability: - types.push_back(Type::Availability); + types.emplace_back(Type::Availability); break; } } @@ -80,13 +80,13 @@ void ViewportSearchCallback::operator()(Results const & results) if (types.empty()) { - delegate.ShowViewportSearchResults(firstCall, results.begin() + lastResultsSize, - results.end()); + delegate.ShowViewportSearchResults(results.begin() + lastResultsSize, results.end(), + firstCall); } else { - delegate.ShowViewportSearchResults(firstCall, types, results.begin() + lastResultsSize, - results.end()); + delegate.ShowViewportSearchResults(results.begin() + lastResultsSize, results.end(), + firstCall, types); } }); } diff --git a/map/viewport_search_callback.hpp b/map/viewport_search_callback.hpp index f7fbe8dadd..1603df3193 100644 --- a/map/viewport_search_callback.hpp +++ b/map/viewport_search_callback.hpp @@ -24,10 +24,10 @@ public: virtual void RunUITask(std::function fn) = 0; virtual void SetHotelDisplacementMode() = 0; virtual bool IsViewportSearchActive() const = 0; - virtual void ShowViewportSearchResults(bool clear, Results::ConstIter begin, - Results::ConstIter end) = 0; - virtual void ShowViewportSearchResults(bool clear, booking::filter::Types types, - Results::ConstIter begin, Results::ConstIter end) = 0; + virtual void ShowViewportSearchResults(Results::ConstIter begin, Results::ConstIter end, + bool clear) = 0; + virtual void ShowViewportSearchResults(Results::ConstIter begin, Results::ConstIter end, + bool clear, booking::filter::Types types) = 0; virtual void FilterResultsForHotelsQuery(booking::filter::Tasks const & filterTasks, search::Results const & results, bool inViewport) = 0; }; diff --git a/search/hotels_classifier.cpp b/search/hotels_classifier.cpp index 4fb309ec5a..5e9f924725 100644 --- a/search/hotels_classifier.cpp +++ b/search/hotels_classifier.cpp @@ -10,7 +10,7 @@ namespace search bool HotelsClassifier::IsHotelResults(Results const & results) { HotelsClassifier classifier; - for ( auto const & r : results) + for (auto const & r : results) classifier.Add(r); return classifier.IsHotelResults(); @@ -18,7 +18,9 @@ bool HotelsClassifier::IsHotelResults(Results const & results) void HotelsClassifier::Add(Result const & result) { - m_numHotels += result.m_metadata.m_isHotel; + if (result.m_metadata.m_isHotel) + ++m_numHotels; + ++m_numResults; } diff --git a/search/result.hpp b/search/result.hpp index 049964d93d..f8b06190bd 100644 --- a/search/result.hpp +++ b/search/result.hpp @@ -1,4 +1,5 @@ #pragma once + #include "search/bookmarks/results.hpp" #include "search/hotels_classifier.hpp" #include "search/ranking_info.hpp" diff --git a/search/search_quality/assessment_tool/sample_view.cpp b/search/search_quality/assessment_tool/sample_view.cpp index bf738a00ca..a7dba75347 100644 --- a/search/search_quality/assessment_tool/sample_view.cpp +++ b/search/search_quality/assessment_tool/sample_view.cpp @@ -259,7 +259,8 @@ void SampleView::ShowNonFoundResults(std::vector const & void SampleView::ShowFoundResultsMarks(search::Results::ConstIter begin, search::Results::ConstIter end) { - m_framework.FillSearchResultsMarks(false /* clear */, begin, end); + m_framework.FillSearchResultsMarks(begin, end, false, + Framework::SearchMarkPostProcessing()); } void SampleView::ShowNonFoundResultsMarks(std::vector const & results,