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
54
55
56
57
58
59
60
61
62
63
64
65
|
#pragma once
#include "base/cancellable.hpp"
#include "routing/road_graph.hpp"
#include "routing/router.hpp"
#include "routing/base/astar_progress.hpp"
#include "std/functional.hpp"
#include "std/string.hpp"
#include "std/vector.hpp"
namespace routing
{
// IRoutingAlgorithm is an abstract interface of a routing algorithm,
// which searches the optimal way between two junctions on the graph
class IRoutingAlgorithm
{
public:
enum class Result
{
OK,
NoPath,
Cancelled
};
virtual Result CalculateRoute(IRoadGraph const & graph, Junction const & startPos,
Junction const & finalPos, RouterDelegate const & delegate,
vector<Junction> & path) = 0;
};
string DebugPrint(IRoutingAlgorithm::Result const & result);
// Base class for AStar-based routing algorithms
class AStarRoutingAlgorithmBase : public IRoutingAlgorithm
{
protected:
AStarRoutingAlgorithmBase();
AStarProgress m_progress;
};
// AStar routing algorithm implementation
class AStarRoutingAlgorithm : public AStarRoutingAlgorithmBase
{
public:
// IRoutingAlgorithm overrides:
Result CalculateRoute(IRoadGraph const & graph, Junction const & startPos,
Junction const & finalPos, RouterDelegate const & delegate,
vector<Junction> & path) override;
};
// AStar-bidirectional routing algorithm implementation
class AStarBidirectionalRoutingAlgorithm : public AStarRoutingAlgorithmBase
{
public:
// IRoutingAlgorithm overrides:
Result CalculateRoute(IRoadGraph const & graph, Junction const & startPos,
Junction const & finalPos, RouterDelegate const & delegate,
vector<Junction> & path) override;
};
} // namespace routing
|