]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/train.h
Remove diversion logic
[r2c2.git] / source / libr2c2 / train.h
index 90b2a72dc5ce94e3795d2a3d232d932fed22d484..709140c9a6102e3dcb61a94ffc130894dfb10baf 100644 (file)
@@ -1,15 +1,9 @@
-/* $Id$
-
-This file is part of R²C²
-Copyright © 2006-2011  Mikkosoft Productions, Mikko Rasa
-Distributed under the GPL
-*/
-
 #ifndef LIBR2C2_TRAIN_H_
 #define LIBR2C2_TRAIN_H_
 
 #include <sigc++/signal.h>
 #include <sigc++/trackable.h>
+#include <msp/datafile/objectloader.h>
 #include <msp/time/timestamp.h>
 #include "block.h"
 #include "blockiter.h"
@@ -28,7 +22,7 @@ class Zone;
 class Train: public sigc::trackable
 {
 public:
-       class Loader: public Msp::DataFile::BasicLoader<Train>
+       class Loader: public Msp::DataFile::ObjectLoader<Train>
        {
        private:
                Block *prev_block;
@@ -57,14 +51,6 @@ public:
        sigc::signal<void, const std::string &> signal_status_changed;
 
 private:
-       struct RouteRef
-       {
-               const Route *route;
-               unsigned diversion;
-
-               RouteRef(const Route *, unsigned = 0);
-       };
-
        typedef std::list<BlockIter> BlockList;
 
        Layout &layout;
@@ -90,7 +76,7 @@ private:
        bool reverse;
        Msp::Time::TimeStamp stop_timeout;
        unsigned functions;
-       std::list<RouteRef> routes;
+       std::list<const Route *> routes;
        bool end_of_route;
 
        Msp::Time::TimeStamp last_entry_time;
@@ -141,14 +127,13 @@ public:
        bool set_route(const Route *);
        bool go_to(Track &);
        bool go_to(const Zone &);
-       bool divert(Track &);
        const Route *get_route() const;
        void place(Block &, unsigned);
        void unplace();
        bool is_placed() const { return !blocks.empty(); }
        bool free_block(Block &);
        void free_noncritical_blocks();
-       int get_entry_to_block(Block &) const;
+       int get_entry_to_block(const Block &) const;
        float get_reserved_distance() const;
 
        void tick(const Msp::Time::TimeStamp &, const Msp::Time::TimeDelta &);
@@ -158,7 +143,7 @@ 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);
+       void block_state_changed(Block &, Block::State);
        void turnout_path_changed(Track &);
        void halt_event(bool);
        void block_reserved(const Block &, const Train *);
@@ -168,9 +153,8 @@ private:
        void release_blocks();
        void release_blocks(BlockList::iterator, BlockList::iterator);
        void reverse_blocks(BlockList &) const;
-       bool advance_route(std::list<RouteRef>::iterator &, Track &);
+       bool advance_route(std::list<const Route *>::iterator &, Track &);
        Route *create_lead_route(Route *, const Route *);
-       bool is_valid_diversion(const Route &, const TrackIter &);
 };
 
 } // namespace R2C2