]> git.tdb.fi Git - r2c2.git/blobdiff - source/libmarklin/track.h
Major architecture rework
[r2c2.git] / source / libmarklin / track.h
index 21c505fb9ae12c180ed955e632aab989d0684b03..7ef511919986adefcff8fd4eec5627e16db5dad6 100644 (file)
@@ -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 <list>
 #include <set>
+#include <sigc++/trackable.h>
 #include <msp/datafile/loader.h>
 #include "geometry.h"
 
 namespace Marklin {
 
+class Layout;
 class TrackType;
 
-class Track
+class Track: public sigc::trackable
 {
 public:
        class Loader: public Msp::DataFile::BasicLoader<Track>
@@ -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,12 +42,12 @@ private:
        unsigned turnout_id;
        unsigned sensor_id;
        std::vector<Track *> 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();
 
        const TrackType &get_type() const { return type; }
@@ -61,6 +66,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;
@@ -74,13 +81,9 @@ public:
        unsigned 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;
-
        void save(std::list<Msp::DataFile::Statement> &) const;
+private:
+       void turnout_event(unsigned, bool);
 };
 
 } // namespace Marklin