]> git.tdb.fi Git - r2c2.git/blobdiff - source/libmarklin/train.h
Add a timetable row type to wait for another train
[r2c2.git] / source / libmarklin / train.h
index 2b082893b308f02782b5ba5d7415bde7b76e5ffb..d9026c7be84ba78299874d63305b92c204176f82 100644 (file)
@@ -60,6 +60,14 @@ private:
                BlockRef next() const;
        };
 
+       struct RouteRef
+       {
+               const Route *route;
+               unsigned diversion;
+
+               RouteRef(const Route *, unsigned = 0);
+       };
+
        struct RealSpeed
        {
                float speed;
@@ -89,8 +97,7 @@ private:
        bool reverse;
        Msp::Time::TimeStamp stop_timeout;
        unsigned functions;
-       const Route *route;
-       const Route *next_route;
+       std::list<RouteRef> routes;
        bool end_of_route;
        std::string status;
 
@@ -135,10 +142,13 @@ public:
 
        void set_route(const Route *);
        void go_to(const Track &);
-       const Route *get_route() const { return route; }
+       bool divert(Track &);
+       const Route *get_route() const;
        void place(Block &, unsigned);
+       void unplace();
        bool is_placed() const { return !cur_blocks.empty(); }
        bool free_block(Block &);
+       void free_noncritical_blocks();
        int get_entry_to_block(Block &) const;
        float get_reserved_distance() const;
 
@@ -156,6 +166,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;
@@ -163,6 +174,9 @@ private:
        void release_blocks(std::list<BlockRef> &);
        void release_blocks(std::list<BlockRef> &, std::list<BlockRef>::iterator, std::list<BlockRef>::iterator);
        void reverse_blocks(std::list<BlockRef> &) const;
+       bool advance_route(std::list<RouteRef>::iterator &, const Track &);
+       Route *create_lead_route(Route *, const Route *);
+       bool is_valid_diversion(const Route &, const Track &, unsigned);
 };
 
 } // namespace Marklin