]> git.tdb.fi Git - r2c2.git/blob - source/libr2c2/trainroutemetric.h
Allow direction to be specified for routing waypoints
[r2c2.git] / source / libr2c2 / trainroutemetric.h
1 #ifndef LIBR2C2_TRAINROUTEMETRIC_H_
2 #define LIBR2C2_TRAINROUTEMETRIC_H_
3
4 #include <map>
5 #include <vector>
6 #include "trackchain.h"
7
8 namespace R2C2 {
9
10 class Layout;
11 class Track;
12
13 // Metrics store iterators facing away from the goal
14 class TrainRouteMetric
15 {
16 private:
17         typedef std::pair<const Track *, unsigned> Key;
18
19         struct Goal
20         {
21                 TrackIter track;
22                 float base_distance;
23
24                 Goal();
25                 Goal(const TrackIter &);
26         };
27
28         struct Data
29         {
30                 float distance;
31                 const Goal *goal;
32
33                 Data();
34                 Data(float, const Goal *);
35         };
36
37         std::vector<Goal> goals;
38         std::map<Key, Data> tracks;
39
40 public:
41         TrainRouteMetric() { }
42         TrainRouteMetric(const TrackChain &, TrackChain::Direction = TrackChain::UNSPECIFIED);
43
44         void chain_to(const TrainRouteMetric &);
45         float get_distance_from(const Track &, unsigned) const;
46 };
47
48 } // namespace R2C2
49
50 #endif