blob: be87acbec48cc1daa458849fc204929093191fbe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#pragma once
#include "geometry/point2d.hpp"
#include "base/cancellable.hpp"
#include "base/timer.hpp"
#include "std/function.hpp"
#include "std/mutex.hpp"
namespace routing
{
class TimeoutCancellable : public my::Cancellable
{
public:
TimeoutCancellable();
/// Sets timeout before cancellation. 0 means an infinite timeout.
void SetTimeout(uint32_t timeoutSec);
// Cancellable overrides:
bool IsCancelled() const override;
void Reset() 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;
void OnPointCheck(m2::PointD const & point) const;
void SetProgressCallback(TProgressCallback const & progressCallback);
void SetPointCheckCallback(TPointCheckCallback const & pointCallback);
void Reset() override {lock_guard<mutex> l(m_guard); TimeoutCancellable::Reset();}
private:
mutable mutex m_guard;
TProgressCallback m_progressCallback;
TPointCheckCallback m_pointCallback;
};
} // nomespace routing
|