]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/track.h
Add a common base class for tangible objects
[r2c2.git] / source / libr2c2 / track.h
index 4dbfa2db87eabd56c12616f759adebdef1f4ca2c..883fb5eda506ab04a0614bbbebf1333560bbe41f 100644 (file)
@@ -6,14 +6,15 @@
 #include <sigc++/trackable.h>
 #include <msp/datafile/objectloader.h>
 #include "geometry.h"
+#include "object.h"
+#include "tracktype.h"
 
 namespace R2C2 {
 
 class Block;
 class Layout;
-class TrackType;
 
-class Track: public sigc::trackable
+class Track: public Object, public sigc::trackable
 {
 public:
        class Loader: public Msp::DataFile::ObjectLoader<Track>
@@ -22,6 +23,7 @@ public:
                Loader(Track &);
        private:
                void position(float, float, float);
+               void rotation(float);
                void sensor_id(unsigned);
                void turnout_id(unsigned);
        };
@@ -30,11 +32,8 @@ public:
        sigc::signal<void, unsigned> signal_path_changed;
 
 private:
-       Layout &layout;
        const TrackType &type;
        Block *block;
-       Vector pos;
-       float rot;
        float slope;
        bool flex;
        unsigned turnout_id;
@@ -49,17 +48,15 @@ public:
        Track(Layout &, const TrackType &);
        ~Track();
 
-       Layout &get_layout() const { return layout; }
-       const TrackType &get_type() const { return type; }
+       virtual Track *clone(Layout * = 0) const;
+       virtual const TrackType &get_type() const { return type; }
 
        void set_block(Block *);
        Block &get_block() const;
-       void set_position(const Vector &);
-       void set_rotation(float);
+       virtual void set_position(const Vector &);
+       virtual void set_rotation(float);
        void set_slope(float);
        void set_flex(bool);
-       const Vector &get_position() const { return pos; }
-       float get_rotation() const { return rot; }
        float get_slope() const { return slope; }
        bool get_flex() const { return flex; }
        void check_slope();
@@ -85,7 +82,7 @@ public:
        TrackPoint get_point(unsigned, float) const;
        TrackPoint get_nearest_point(const Vector &) const;
 
-       bool collide_ray(const Vector &, const Vector &);
+       virtual bool collide_ray(const Vector &, const Vector &) const;
 
        void save(std::list<Msp::DataFile::Statement> &) const;
 private: