]> git.tdb.fi Git - r2c2.git/blobdiff - source/libmarklin/train.h
Major code refactoring:
[r2c2.git] / source / libmarklin / train.h
index 23bd3cc1b09405fedfae44d62af17e10a40a8f6b..21f1382c8c7ba5704797cfae4cf9b248dd1afd62 100644 (file)
@@ -8,39 +8,40 @@
 namespace Marklin {
 
 class Locomotive;
+class Sensor;
 class TrafficManager;
 
 class Train: public sigc::trackable
 {
-public:
-       sigc::signal<void, const std::string &> signal_name_changed;
-
-       Train(TrafficManager &, Locomotive &);
-       void set_name(const std::string &);
-       void set_speed(unsigned);
-       const std::string &get_name() const { return name; }
-       Locomotive &get_locomotive() const { return loco; }
-       void place(Block *, const Block::Endpoint *);
-       bool free_block(Block *);
-       void tick();
 private:
        struct BlockRef
        {
                Block *block;
-               const Block::Endpoint *entry;
+               unsigned entry;
 
-               BlockRef(Block *s, const Block::Endpoint *e): block(s), entry(e) { }
+               BlockRef(Block *s, unsigned e): block(s), entry(e) { }
        };
-       typedef std::list<BlockRef> BlockRefSeq;
 
        TrafficManager &trfc_mgr;
        std::string name;
        Locomotive &loco;
-       BlockRefSeq cur_blocks;
-       BlockRefSeq rsv_blocks;
+       std::list<BlockRef> cur_blocks;
+       std::list<BlockRef> rsv_blocks;
        unsigned target_speed;
 
-       void sensor_event(unsigned, bool);
+public:
+       sigc::signal<void, const std::string &> signal_name_changed;
+
+       Train(TrafficManager &, Locomotive &);
+       void set_name(const std::string &);
+       void set_speed(unsigned);
+       const std::string &get_name() const { return name; }
+       Locomotive &get_locomotive() const { return loco; }
+       void place(Block *, unsigned);
+       bool free_block(Block *);
+       void tick();
+private:
+       void sensor_event(bool, Sensor *);
        bool reserve_more();
 };
 typedef std::list<Train *> TrainSeq;