1 #ifndef LIBR2C2_VEHICLE_H_
2 #define LIBR2C2_VEHICLE_H_
5 #include "vehicletype.h"
12 class attachment_error: public std::logic_error
15 attachment_error(const std::string &w): std::logic_error(w) { }
16 virtual ~attachment_error() throw() { }
34 const VehicleType::Axle *type;
37 Axle(const VehicleType::Axle &);
42 const VehicleType::Bogie *type;
44 std::vector<Axle> axles;
46 Bogie(const VehicleType::Bogie &);
51 const VehicleType::Rod *type;
55 Rod(const VehicleType::Rod &);
66 TrackPosition(Track *, unsigned, float);
68 TrackPoint get_point() const;
72 const VehicleType &type;
75 TrackPosition track_pos;
78 std::vector<Axle> axles;
79 std::vector<Bogie> bogies;
80 std::vector<Rod> rods;
81 unsigned front_sensor;
85 Vehicle(Layout &, const VehicleType &);
88 const VehicleType &get_type() const { return type; }
90 void attach_back(Vehicle &);
91 void attach_front(Vehicle &);
94 Vehicle *get_next() const { return next; }
95 Vehicle *get_previous() const { return prev; }
97 void place(Track &, unsigned, float, PlaceMode = CENTER);
100 Track *get_track() const { return track_pos.track; }
101 unsigned get_entry() const { return track_pos.ep; }
102 float get_offset() const { return track_pos.offs; }
103 const Vector &get_position() const { return position; }
104 float get_direction() const { return direction; }
105 const Axle &get_fixed_axle(unsigned) const;
106 const Bogie &get_bogie(unsigned) const;
107 const Axle &get_bogie_axle(unsigned, unsigned) const;
108 const Rod &get_rod(unsigned) const;
110 void update_position();
111 void update_position_from(const Vehicle &);
112 void propagate_position();
113 void propagate_forward();
114 void propagate_backward();
115 void check_sensor(float, unsigned &);
116 void turn_axles(float);
119 void adjust_for_distance(TrackPosition &, TrackPosition &, float, float = 0.5) const;
120 TrackPoint get_point(const Vector &, const Vector &, float = 0.5) const;
121 TrackPoint get_point(const TrackPosition &, float, float = 0.5) const;