1 #ifndef LIBMARKLIN_TRACK_H_
2 #define LIBMARKLIN_TRACK_H_
6 #include <msp/parser/loader.h>
14 class Loader: public Msp::Parser::Loader
18 Track &get_object() { return track; }
24 void position(float, float, float);
34 Endpoint(const Point &p, float r, unsigned o): pos(p), rot(r), link(0), routes(o) { }
36 typedef std::list<Endpoint> EndpointSeq;
40 class Loader: public Msp::Parser::Loader
44 Part &get_object() { return part; }
49 void start(float, float, float);
60 void collect_endpoints(EndpointSeq &);
62 typedef std::list<Part> PartSeq;
66 void set_position(const Point &);
67 void set_rotation(float);
68 void set_slope(float);
69 void set_flex(bool f) { flex=f; }
70 void set_turnout_id(unsigned i) { turnout_id=i; }
71 void set_sensor_id(unsigned i) { sensor_id=i; }
72 const Point &get_position() const { return pos; }
73 float get_rotation() const { return rot; }
74 unsigned get_article_number() const { return art_nr; }
75 const PartSeq &get_parts() const { return parts; }
76 const EndpointSeq &get_endpoints() const { return endpoints; }
77 const Endpoint *get_endpoint_by_link(Track *) const;
78 const std::string &get_description() const { return description; }
79 float get_slope() const { return slope; }
80 bool get_flex() const { return flex; }
81 float get_length() const;
82 float get_total_length() const;
83 unsigned get_turnout_id() const { return turnout_id; }
84 unsigned get_sensor_id() const { return sensor_id; }
85 unsigned get_n_routes() const;
86 bool snap_to(Track &, bool);
87 bool snap(Point &, float &) const;
88 void break_link(Track &);
91 const Endpoint *traverse(const Endpoint *, unsigned) const;
94 Creates a copy of the track. The new track will be almost identical, but
95 won't have any links to other tracks, nor a turnout or sensor id.
100 std::string description;
102 EndpointSeq endpoints;
110 // Direct copying not allowed due to links. See the copy() function.
111 //Track(const Track &);
112 Track &operator=(const Track &);
114 void collect_endpoints();
116 typedef std::list<Track *> TrackSeq;
117 typedef std::set<Track *> TrackSet;
119 } // namespace Marklin