]> git.tdb.fi Git - r2c2.git/blobdiff - source/libmarklin/train.h
Use RAII for setting the anti-recursion flags
[r2c2.git] / source / libmarklin / train.h
index ee66e1d1ca29e0dc38df83e4fc86dc0a3f0b548a..3e7a56b7e423da7e9d4157d88138fc7e4e4ede85 100644 (file)
@@ -12,10 +12,10 @@ Distributed under the GPL
 #include <sigc++/trackable.h>
 #include <msp/time/timestamp.h>
 #include "block.h"
+#include "controller.h"
 
 namespace Marklin {
 
-class ControlModel;
 class Route;
 class Timetable;
 class Vehicle;
@@ -78,7 +78,9 @@ private:
        std::list<BlockRef> cur_blocks;
        std::list<BlockRef> rsv_blocks;
        Block *pending_block;
-       ControlModel *control;
+       bool reserving;
+       bool advancing;
+       Controller *controller;
        Timetable *timetable;
        bool active;
        unsigned current_speed;
@@ -109,7 +111,7 @@ public:
        const std::string &get_name() const { return name; }
        void set_priority(int);
        int get_priority() const { return priority; }
-       ControlModel &get_control() const { return *control; }
+       Controller &get_controller() const { return *controller; }
 
        void add_vehicle(const VehicleType &);
        void remove_vehicle(unsigned);
@@ -121,6 +123,7 @@ public:
        void set_active(bool);
        void set_function(unsigned, bool);
        float get_control(const std::string &) const;
+       float get_speed() const;
        bool is_active() const { return active; }
        bool get_function(unsigned) const;
        unsigned get_functions() const { return functions; }
@@ -143,6 +146,7 @@ public:
 
        void save(std::list<Msp::DataFile::Statement> &) const;
 private:
+       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);