MCPcopy Create free account
hub / github.com/comaps/comaps / operator()

Method operator()

libs/map/viewport_search_callback.cpp:19–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17}
18
19void ViewportSearchCallback::operator()(Results const & results)
20{
21 ASSERT_LESS_OR_EQUAL(m_lastResultsSize, results.GetCount(), ());
22
23 // We need to clear old results and show a new bunch of results when
24 // the search is completed normally (note that there may be empty
25 // set of results), or when the search is not completed and there is
26 // something in results.
27 //
28 // We don't need to clear old results or show current results if the
29 // search is cancelled, because:
30 //
31 // * current request is cancelled because of the next
32 // search-in-viewport request - in this case it is the
33 // responsibility of the next search request to clean up old results
34 // and there is no need to clean up current results. We don't want
35 // to show blinking results.
36 //
37 // * search in viewport may be cancelled completely - it is the
38 // responsibility of the user of this class to handle this case and
39 // clean up results.
40
41 auto & delegate = m_delegate;
42 m_delegate.RunUITask([&delegate, results, onResults = m_onResults, firstCall = m_firstCall,
43 lastResultsSize = m_lastResultsSize]() mutable
44 {
45 if (delegate.IsViewportSearchActive() &&
46 (results.IsEndedNormal() || (!results.IsEndMarker() && results.GetCount() != 0)))
47 {
48 /// @todo This code relies on fact that results order is *NOT* changing with every new batch.
49 /// I can't say for sure is it true or not, but very optimistic :)
50 /// Much easier to clear previous marks and make new ones.
51 delegate.ShowViewportSearchResults(results.begin() + lastResultsSize, results.end(), firstCall);
52 }
53
54 if (results.IsEndMarker() && onResults)
55 onResults(std::move(results));
56 });
57
58 m_lastResultsSize = results.GetCount();
59 m_firstCall = false;
60}
61} // namespace search

Callers

nothing calls this directly

Calls 8

IsEndedNormalMethod · 0.80
IsEndMarkerMethod · 0.80
GetCountMethod · 0.45
RunUITaskMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected