本文整理汇总了C++中shared_ptr::Attach方法的典型用法代码示例。如果您正苦于以下问题:C++ shared_ptr::Attach方法的具体用法?C++ shared_ptr::Attach怎么用?C++ shared_ptr::Attach使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shared_ptr
的用法示例。
在下文中一共展示了shared_ptr::Attach方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoSearch
void Engine::DoSearch(SearchParams const & params, m2::RectD const & viewport,
shared_ptr<ProcessorHandle> handle, Processor & processor)
{
bool const viewportSearch = params.m_mode == Mode::Viewport;
processor.Reset();
processor.Init(viewportSearch);
handle->Attach(processor);
MY_SCOPE_GUARD(detach, [&handle]
{
handle->Detach();
});
// Early exit when query processing is cancelled.
if (processor.IsCancelled())
{
Results results;
results.SetEndMarker(true /* isCancelled */);
params.m_onResults(results);
return;
}
processor.Search(params, viewport);
}
示例2: DoSearch
void Engine::DoSearch(SearchParams const & params, m2::RectD const & viewport,
shared_ptr<QueryHandle> handle, Query & processor)
{
bool const viewportSearch = params.GetMode() == Mode::Viewport;
// Initialize query processor.
processor.Init(viewportSearch);
handle->Attach(processor);
MY_SCOPE_GUARD(detach, [&handle] { handle->Detach(); });
// Early exit when query processing is cancelled.
if (processor.IsCancelled())
{
params.m_onResults(Results::GetEndMarker(true /* isCancelled */));
return;
}
SetRankPivot(params, viewport, viewportSearch, processor);
if (params.IsValidPosition())
processor.SetPosition(MercatorBounds::FromLatLon(params.m_lat, params.m_lon));
else
processor.SetPosition(viewport.Center());
processor.SetMode(params.GetMode());
processor.SetSuggestsEnabled(params.GetSuggestsEnabled());
// This flag is needed for consistency with old search algorithm
// only. It will be gone when we remove old search code.
processor.SetSearchInWorld(true);
processor.SetInputLocale(params.m_inputLocale);
ASSERT(!params.m_query.empty(), ());
processor.SetQuery(params.m_query);
Results res;
processor.SearchCoordinates(res);
try
{
if (params.m_onStarted)
params.m_onStarted();
processor.SetViewport(viewport, true /* forceUpdate */);
if (viewportSearch)
processor.SearchViewportPoints(res);
else
processor.Search(res, kResultsCount);
if (!processor.IsCancelled())
EmitResults(params, res);
}
catch (Query::CancelException const &)
{
LOG(LDEBUG, ("Search has been cancelled."));
}
if (!viewportSearch && !processor.IsCancelled())
SendStatistics(params, viewport, res);
// Emit finish marker to client.
params.m_onResults(Results::GetEndMarker(processor.IsCancelled()));
}