Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLev Dragunov <l.dragunov@corp.mail.ru>2015-07-30 17:45:48 +0300
committerAlex Zolotarev <alex@maps.me>2015-09-23 02:58:41 +0300
commit5a50c9c892997a8d318160c307aeabcb7cfa3325 (patch)
treed6e09f8444c05a185d971754741aa9c003475818 /routing/router_delegate.hpp
parent8accabb3a272ee484dcca5eaa061e8f5ff705f11 (diff)
TimeoutObserver to RouterDelegate refactoring.
Diffstat (limited to 'routing/router_delegate.hpp')
-rw-r--r--routing/router_delegate.hpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/routing/router_delegate.hpp b/routing/router_delegate.hpp
new file mode 100644
index 0000000000..2b21a982de
--- /dev/null
+++ b/routing/router_delegate.hpp
@@ -0,0 +1,46 @@
+#pragma once
+
+#include "geometry/point2d.hpp"
+
+#include "base/cancellable.hpp"
+#include "base/timer.hpp"
+
+#include "std/function.hpp"
+
+namespace routing
+{
+
+class TimeoutCancellable : public my::Cancellable
+{
+ public:
+ TimeoutCancellable() : m_timeoutSec(0) {}
+
+ /// Sets timeout in seconds to autamaticly calcel. 0 is infinity value.
+ void SetTimeout(uint32_t);
+ bool IsCancelled() const override;
+ private:
+ my::Timer m_timer;
+ uint32_t m_timeoutSec;
+};
+
+class RouterDelegate : public TimeoutCancellable
+{
+public:
+ using TProgressCallback = function<void(float)>;
+ using TPointCheckCallback = function<void(m2::PointD const &)>;
+
+ RouterDelegate();
+
+ /// Set routing progress. Waits current progress status from 0 to 100.
+ void OnProgress(float progress) const { m_progressFn(progress); }
+ void OnPointCheck(m2::PointD const & point) const { m_pointFn(point); }
+
+ void SetProgressCallback(TProgressCallback const & progressFn);
+ void SetPointCheckCallback(TPointCheckCallback const & pointFn);
+
+private:
+ TProgressCallback m_progressFn;
+ TPointCheckCallback m_pointFn;
+};
+
+} // nomespace routing