3 This file is part of the MSP Märklin suite
4 Copyright © 2006-2009 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
8 #ifndef LIBMARKLIN_TRACK_H_
9 #define LIBMARKLIN_TRACK_H_
13 #include <msp/datafile/loader.h>
23 class Loader: public Msp::DataFile::BasicLoader<Track>
28 void position(float, float, float);
32 const TrackType &type;
39 std::vector<Track *> links;
42 Track(const TrackType &);
45 const TrackType &get_type() const { return type; }
46 void set_position(const Point &);
47 const Point &get_position() const { return pos; }
48 void set_rotation(float);
49 float get_rotation() const { return rot; }
50 void set_slope(float);
51 float get_slope() const { return slope; }
53 bool get_flex() const { return flex; }
54 void set_turnout_id(unsigned);
55 unsigned get_turnout_id() const { return turnout_id; }
56 void set_sensor_id(unsigned);
57 unsigned get_sensor_id() const { return sensor_id; }
58 int get_endpoint_by_link(const Track &) const;
59 Point get_endpoint_position(unsigned) const;
60 float get_endpoint_direction(unsigned) const;
61 bool snap_to(Track &, bool);
62 bool snap(Point &, float &) const;
63 void break_link(Track &);
65 const std::vector<Track *> &get_links() const { return links; }
66 Track *get_link(unsigned) const;
68 int traverse(unsigned, unsigned) const;
69 Point get_point(unsigned, unsigned, float) const;
72 Creates a copy of the track. The new track will be almost identical, but
73 won't have any links to other tracks, nor a turnout or sensor id.
77 void save(std::list<Msp::DataFile::Statement> &) const;
80 // Direct copying not allowed due to links. See the copy() function.
82 Track &operator=(const Track &);
85 } // namespace Marklin