/
githubmirror
/
omim
Обзор
Документация
Войти
/
githubmirror
/
omim
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
android-940
routing/router_delegate.cpp
69 строк
1 KB
Mikhail Gorbushin
[routing] remove std/...
26 фев 2019, 15:25
26 фев 2019, 15:25
dbf3450
Код
Авторство
О чём код?
#include "routing/router_delegate.hpp" namespace routing { namespace { void DefaultProgressFn(float /* progress */) {} void DefaultPointFn(m2::PointD const & /* point */) {} } // namespace RouterDelegate::RouterDelegate() { m_progressCallback = DefaultProgressFn; m_pointCallback = DefaultPointFn; } void RouterDelegate::SetProgressCallback(ProgressCallback const & progressCallback) { m_progressCallback = progressCallback ? progressCallback : DefaultProgressFn; } void RouterDelegate::SetPointCheckCallback(PointCheckCallback const & pointCallback) { m_pointCallback = pointCallback ? pointCallback : DefaultPointFn; } void RouterDelegate::OnProgress(float progress) const { std::lock_guard<std::mutex> l(m_guard); if (!IsCancelled()) m_progressCallback(progress); } void RouterDelegate::Reset() { std::lock_guard<std::mutex> l(m_guard); TimeoutCancellable::Reset(); } void RouterDelegate::OnPointCheck(m2::PointD const & point) const { std::lock_guard<std::mutex> l(m_guard); if (!IsCancelled()) m_pointCallback(point); } TimeoutCancellable::TimeoutCancellable() : m_timeoutSec(0) { } bool TimeoutCancellable::IsCancelled() const { if (m_timeoutSec && m_timer.ElapsedSeconds() > m_timeoutSec) return true; return Cancellable::IsCancelled(); } void TimeoutCancellable::Reset() { m_timeoutSec = 0; Cancellable::Reset(); } void TimeoutCancellable::SetTimeout(uint32_t timeoutSec) { m_timeoutSec = timeoutSec; m_timer.Reset(); } } // namespace routing