]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/layout.h
Remove a queued block reservation if the block is released
[r2c2.git] / source / libr2c2 / layout.h
index 887b2d189f453dcc2dab13e59316f0642ce54df5..e06d4fb04f50d8ccb1e581a363e2dce18d13d91a 100644 (file)
@@ -1,9 +1,11 @@
 #ifndef LIBR2C2_LAYOUT_H_
 #define LIBR2C2_LAYOUT_H_
 
+#include <deque>
 #include <set>
 #include <sigc++/sigc++.h>
 #include <msp/datafile/objectloader.h>
+#include <msp/time/timedelta.h>
 #include <msp/time/timestamp.h>
 #include "geometry.h"
 #include "sensor.h"
@@ -40,7 +42,8 @@ public:
                void terrain(const std::string &);
                void track(const std::string &);
                void train(const std::string &, unsigned, const std::string &);
-               void turnout(unsigned, unsigned);
+               void turnout(unsigned);
+               void turnout2(unsigned, unsigned);
                void zone();
        };
 
@@ -67,6 +70,14 @@ private:
                void del();
        };
 
+       struct BlockReservation
+       {
+               Block *block;
+               Train *train;
+
+               BlockReservation(Block &, Train *);
+       };
+
 public:
        typedef std::vector<Zone *> ZoneArray;
 
@@ -91,6 +102,8 @@ private:
        std::map<unsigned, Train *> trains;
        Msp::Time::TimeStamp last_tick;
        unsigned next_turnout_addr;
+       bool emitting_block_reserved;
+       std::deque<BlockReservation> block_reserve_queue;
 
 public:
        Layout(Catalogue &, Driver * = 0);
@@ -138,13 +151,17 @@ public:
        const std::map<unsigned, Train *> &get_trains() const { return trains; }
        void remove_train(Train &);
 
-       void tick();
+       void tick(float = 1.0f);
+private:
+       void step(const Msp::Time::TimeDelta &);
+public:
        void emergency(Block *, const std::string &);
 
        void save(const std::string &) const;
        void save_dynamic(const std::string &) const;
 private:
        void sensor_state_changed(Sensor &, Sensor::State);
+       void block_reserved(Block &, Train *);
 };
 
 } // namespace R2C2