]> git.tdb.fi Git - r2c2.git/blobdiff - source/libmarklin/train.h
Add Track::get_endpoint_position to avoid duplicating calculations
[r2c2.git] / source / libmarklin / train.h
index 363fb5572c9184dde7a64e339815f3fbe4f28983..23bd3cc1b09405fedfae44d62af17e10a40a8f6b 100644 (file)
@@ -1,8 +1,9 @@
 #ifndef LIBMARKLIN_TRAIN_H_
 #define LIBMARKLIN_TRAIN_H_
 
+#include <sigc++/signal.h>
 #include <sigc++/trackable.h>
-#include "section.h"
+#include "block.h"
 
 namespace Marklin {
 
@@ -12,27 +13,31 @@ class TrafficManager;
 class Train: public sigc::trackable
 {
 public:
+       sigc::signal<void, const std::string &> signal_name_changed;
+
        Train(TrafficManager &, Locomotive &);
-       const std::string &get_name() const { return name; }
+       void set_name(const std::string &);
        void set_speed(unsigned);
-       void place(Section *, const Section::Endpoint *);
-       bool free_section(Section *);
+       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 SectionRef
+       struct BlockRef
        {
-               Section *section;
-               const Section::Endpoint *entry;
+               Block *block;
+               const Block::Endpoint *entry;
 
-               SectionRef(Section *s, const Section::Endpoint *e): section(s), entry(e) { }
+               BlockRef(Block *s, const Block::Endpoint *e): block(s), entry(e) { }
        };
-       typedef std::list<SectionRef> SectRefSeq;
+       typedef std::list<BlockRef> BlockRefSeq;
 
        TrafficManager &trfc_mgr;
        std::string name;
        Locomotive &loco;
-       SectRefSeq cur_sections;
-       SectRefSeq rsv_sections;
+       BlockRefSeq cur_blocks;
+       BlockRefSeq rsv_blocks;
        unsigned target_speed;
 
        void sensor_event(unsigned, bool);