]> git.tdb.fi Git - r2c2.git/blobdiff - source/libmarklin/train.h
Reserve two ids for double-address turnouts
[r2c2.git] / source / libmarklin / train.h
index e4458be82d7bfb47bf7a853b57e1ef6f8cb73298..02d1d52de1b8751d411bc5aa063300f46d2fb110 100644 (file)
@@ -12,15 +12,14 @@ Distributed under the GPL
 #include <sigc++/trackable.h>
 #include <msp/time/timestamp.h>
 #include "block.h"
+#include "controller.h"
 
 namespace Marklin {
 
-class Controller;
 class Route;
 class Timetable;
 class Vehicle;
 class VehicleType;
-struct TrainControl;
 
 class Train: public sigc::trackable
 {
@@ -75,10 +74,13 @@ private:
        unsigned address;
        std::string name;
        int priority;
+       const Train *yielding_to;
        std::vector<Vehicle *> vehicles;
        std::list<BlockRef> cur_blocks;
        std::list<BlockRef> rsv_blocks;
        Block *pending_block;
+       bool reserving;
+       bool advancing;
        Controller *controller;
        Timetable *timetable;
        bool active;
@@ -109,6 +111,7 @@ public:
        void set_name(const std::string &);
        const std::string &get_name() const { return name; }
        void set_priority(int);
+       void yield_to(const Train &);
        int get_priority() const { return priority; }
        Controller &get_controller() const { return *controller; }
 
@@ -134,6 +137,7 @@ public:
        void go_to(const Track &);
        const Route *get_route() const { return route; }
        void place(Block &, unsigned);
+       void unplace();
        bool is_placed() const { return !cur_blocks.empty(); }
        bool free_block(Block &);
        int get_entry_to_block(Block &) const;
@@ -145,7 +149,7 @@ public:
 
        void save(std::list<Msp::DataFile::Statement> &) const;
 private:
-       void control_changed(const TrainControl &);
+       void control_changed(const Controller::Control &);
        void loco_speed_event(unsigned, unsigned, bool);
        void loco_func_event(unsigned, unsigned, bool);
        void sensor_event(unsigned, bool);
@@ -153,6 +157,7 @@ private:
        void halt_event(bool);
        void block_reserved(const Block &, const Train *);
        unsigned reserve_more();
+       float get_reserved_distance_until(const Block *, bool) const;
        float get_real_speed(unsigned) const;
        unsigned find_speed(float) const;
        float get_travel_speed() const;