X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibmarklin%2Ftrack.h;h=34d484c9f67bc487b3fc15b4afcf9778b6dd0be7;hb=9ddcd066e37e4c72685817c042c30897786ece05;hp=b000e346bf0b4943fc96b5f66733c9c24f109a51;hpb=449fb5de95ddb2ac9da4bd72a1c12150505d5549;p=r2c2.git diff --git a/source/libmarklin/track.h b/source/libmarklin/track.h index b000e34..34d484c 100644 --- a/source/libmarklin/track.h +++ b/source/libmarklin/track.h @@ -1,7 +1,7 @@ /* $Id$ This file is part of the MSP Märklin suite -Copyright © 2006-2009 Mikkosoft Productions, Mikko Rasa +Copyright © 2006-2010 Mikkosoft Productions, Mikko Rasa Distributed under the GPL */ @@ -10,14 +10,16 @@ Distributed under the GPL #include #include +#include #include #include "geometry.h" namespace Marklin { +class Layout; class TrackType; -class Track +class Track: public sigc::trackable { public: class Loader: public Msp::DataFile::BasicLoader @@ -26,9 +28,12 @@ public: Loader(Track &); private: void position(float, float, float); + void sensor_id(unsigned); + void turnout_id(unsigned); }; private: + Layout &layout; const TrackType &type; Point pos; float rot; @@ -37,14 +42,15 @@ private: unsigned turnout_id; unsigned sensor_id; std::vector links; + unsigned active_path; - // Direct copying not allowed due to links. See the copy() function. Track(const Track &); Track &operator=(const Track &); public: - Track(const TrackType &); + Track(Layout &, const TrackType &); ~Track(); + Layout &get_layout() const { return layout; } const TrackType &get_type() const { return type; } void set_position(const Point &); @@ -61,6 +67,8 @@ public: void set_sensor_id(unsigned); unsigned get_turnout_id() const { return turnout_id; } unsigned get_sensor_id() const { return sensor_id; } + void set_active_path(unsigned); + unsigned get_active_path() const { return active_path; } int get_endpoint_by_link(const Track &) const; Point get_endpoint_position(unsigned) const; @@ -71,16 +79,14 @@ public: void break_links(); const std::vector &get_links() const { return links; } Track *get_link(unsigned) const; - int traverse(unsigned, unsigned) const; - Point get_point(unsigned, unsigned, float) const; - - /** - Creates a copy of the track. The new track will be almost identical, but - won't have any links to other tracks, nor a turnout or sensor id. - */ - Track *copy() const; + unsigned traverse(unsigned, unsigned) const; + unsigned traverse(unsigned) const; + TrackPoint get_point(unsigned, unsigned, float) const; + TrackPoint get_point(unsigned, float) const; void save(std::list &) const; +private: + void turnout_event(unsigned, bool); }; } // namespace Marklin