]> git.tdb.fi Git - r2c2.git/blob - source/libr2c2/trainroutemetric.h
Don't diverge from critical blocks
[r2c2.git] / source / libr2c2 / trainroutemetric.h
1 #ifndef LIBR2C2_TRAINROUTEMETRIC_H_
2 #define LIBR2C2_TRAINROUTEMETRIC_H_
3
4 #include <map>
5 #include <vector>
6
7 namespace R2C2 {
8
9 class Layout;
10 class Track;
11 class TrackChain;
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 &);
43
44         void chain_to(const TrainRouteMetric &);
45         float get_distance_from(const Track &, unsigned) const;
46 };
47
48 } // namespace R2C2
49
50 #endif