1 #ifndef LIBR2C2_TRAINROUTEPLANNER_H_
2 #define LIBR2C2_TRAINROUTEPLANNER_H_
6 #include <msp/time/timedelta.h>
17 class TrainRoutePlanner
20 struct TrainRoutingState;
22 struct TrainRoutingInfo
27 std::list<TrainRoutingState *> waits;
29 TrainRoutingInfo(Train &);
40 OccupiedTrack(Track &, unsigned, OccupiedTrack *);
41 OccupiedTrack(const OccupiedTrack &);
53 struct TrainRoutingState
55 TrainRoutingInfo *info;
58 OccupiedTrack *occupied_tracks;
63 TrainRoutingState(TrainRoutingInfo &);
64 TrainRoutingState(const TrainRoutingState &);
67 Msp::Time::TimeDelta get_time_to_next_track() const;
68 bool is_occupied(Track &) const;
70 void advance_track(unsigned);
75 Msp::Time::TimeDelta time;
76 std::vector<TrainRoutingState> trains;
80 RoutingStep(RoutingStep *);
82 void advance(const Msp::Time::TimeDelta &);
85 bool operator<(const RoutingStep &) const;
88 std::vector<TrainRoutingInfo> routed_trains;
89 std::list<RoutingStep> steps;
92 TrainRoutePlanner(Layout &);
96 bool update_states(RoutingStep &);
97 int find_next_train(RoutingStep &);
98 void add_steps(RoutingStep &, unsigned);
99 void add_waiting_step(RoutingStep &, unsigned);
100 void add_steps(RoutingStep &, TrainRoutingState &train);
101 void create_routes(RoutingStep &);