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 Point get_endpoint_position(const Endpoint &) const;
79 const std::string &get_description() const { return description; }
80 float get_slope() const { return slope; }
81 bool get_flex() const { return flex; }
82 float get_length() const;
83 float get_total_length() const;
84 unsigned get_turnout_id() const { return turnout_id; }
85 unsigned get_sensor_id() const { return sensor_id; }
86 unsigned get_n_routes() const;
87 bool snap_to(Track &, bool);
88 bool snap(Point &, float &) const;
89 void break_link(Track &);
92 const Endpoint *traverse(const Endpoint *, unsigned) const;
95 Creates a copy of the track. The new track will be almost identical, but
96 won't have any links to other tracks, nor a turnout or sensor id.
101 std::string description;
103 EndpointSeq endpoints;
111 // Direct copying not allowed due to links. See the copy() function.
112 //Track(const Track &);
113 Track &operator=(const Track &);
115 void collect_endpoints();
117 typedef std::list<Track *> TrackSeq;
118 typedef std::set<Track *> TrackSet;
120 } // namespace Marklin