3 This file is part of the MSP Märklin suite
4 Copyright © 2006-2008 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
8 #ifndef LIBMARKLIN_TRAIN_H_
9 #define LIBMARKLIN_TRAIN_H_
11 #include <sigc++/signal.h>
12 #include <sigc++/trackable.h>
13 #include <msp/time/timestamp.h>
22 class Train: public sigc::trackable
30 BlockRef(Block *s, unsigned e): block(s), entry(e) { }
33 TrafficManager &trfc_mgr;
36 std::list<BlockRef> cur_blocks;
37 std::list<BlockRef> rsv_blocks;
38 unsigned target_speed;
39 Msp::Time::TimeStamp try_reserve;
41 Msp::Time::TimeStamp last_entry_time;
46 sigc::signal<void, const std::string &> signal_name_changed;
47 sigc::signal<void, const std::string &> signal_status_changed;
49 Train(TrafficManager &, Locomotive &);
51 void set_name(const std::string &);
52 void set_speed(unsigned);
53 const std::string &get_name() const { return name; }
54 Locomotive &get_locomotive() const { return loco; }
55 const std::string &get_status() const { return status; }
56 void place(Block *, unsigned);
57 bool free_block(Block *);
58 void tick(const Msp::Time::TimeStamp &);
60 void sensor_event(bool, Sensor *);
62 void set_status(const std::string &);
65 } // namespace Marklin