]> git.tdb.fi Git - r2c2.git/blobdiff - source/libmarklin/track.h
Fix memory leaks and other bad stuff
[r2c2.git] / source / libmarklin / track.h
index 3c96a82d2cec51f6463c3e958d1b417c3ebb003a..21c505fb9ae12c180ed955e632aab989d0684b03 100644 (file)
@@ -30,43 +30,49 @@ public:
 
 private:
        const TrackType &type;
-       Point        pos;
-       float        rot;
-       float        slope;
-       bool         flex;
-       unsigned     turnout_id;
-       unsigned     sensor_id;
+       Point pos;
+       float rot;
+       float slope;
+       bool flex;
+       unsigned turnout_id;
+       unsigned sensor_id;
        std::vector<Track *> links;
 
+       // Direct copying not allowed due to links.  See the copy() function.
+       Track(const Track &);
+       Track &operator=(const Track &);
 public:
        Track(const TrackType &);
        ~Track();
 
        const TrackType &get_type() const { return type; }
-       void            set_position(const Point &);
-       const Point     &get_position() const      { return pos; }
-       void            set_rotation(float);
-       float           get_rotation() const       { return rot; }
-       void            set_slope(float);
-       float           get_slope() const          { return slope; }
-       void            set_flex(bool);
-       bool            get_flex() const           { return flex; }
-       void            set_turnout_id(unsigned);
-       unsigned        get_turnout_id() const     { return turnout_id; }
-       void            set_sensor_id(unsigned);
-       unsigned        get_sensor_id() const      { return sensor_id; }
-       int             get_endpoint_by_link(const Track &) const;
-       Point           get_endpoint_position(unsigned) const;
-       float           get_endpoint_direction(unsigned) const;
-       bool            snap_to(Track &, bool);
-       bool            snap(Point &, float &) const;
-       void            break_link(Track &);
-       void            break_links();
+
+       void set_position(const Point &);
+       void set_rotation(float);
+       void set_slope(float);
+       void set_flex(bool);
+       const Point &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();
+
+       void set_turnout_id(unsigned);
+       void set_sensor_id(unsigned);
+       unsigned get_turnout_id() const { return turnout_id; }
+       unsigned get_sensor_id() const { return sensor_id; }
+
+       int get_endpoint_by_link(const Track &) const;
+       Point get_endpoint_position(unsigned) const;
+       float get_endpoint_direction(unsigned) const;
+       bool snap_to(Track &, bool);
+       bool snap(Point &, float &) const;
+       void break_link(Track &);
+       void break_links();
        const std::vector<Track *> &get_links() const { return links; }
-       Track           *get_link(unsigned) const;
-       void            check_slope();
-       int             traverse(unsigned, unsigned) const;
-       Point           get_point(unsigned, unsigned, float) const;
+       Track *get_link(unsigned) const;
+       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
@@ -75,11 +81,6 @@ public:
        Track *copy() const;
 
        void save(std::list<Msp::DataFile::Statement> &) const;
-private:
-
-       // Direct copying not allowed due to links.  See the copy() function.
-       Track(const Track &);
-       Track &operator=(const Track &);
 };
 
 } // namespace Marklin