3 This file is part of R²C²
4 Copyright © 2010-2011 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
8 #ifndef LIBR2C2_TIMETABLE_H_
9 #define LIBR2C2_TIMETABLE_H_
13 #include <sigc++/trackable.h>
14 #include <msp/datafile/objectloader.h>
15 #include <msp/time/timestamp.h>
24 class Timetable: public sigc::trackable
27 class Loader: public Msp::DataFile::ObjectLoader<Timetable>
33 void goto_sensor(unsigned);
34 void goto_sensor_str(const std::string &);
35 void goto_zone(const std::string &);
36 void route(const std::string &);
39 void travel_to(unsigned);
40 void travel_past(unsigned);
42 void wait_train(unsigned, unsigned);
43 void wait_until(unsigned, unsigned);
64 std::vector<Msp::Variant> params;
69 Row(RowType, const T &);
72 const T &get_param(unsigned) const;
74 std::string str() const;
76 Msp::DataFile::Statement save() const;
78 static Row parse(const std::string &);
84 std::vector<Row> rows;
89 Msp::Time::TimeStamp wait_timeout;
95 void set_enabled(bool);
96 bool is_enabled() const { return enabled; }
100 void append(const Row &);
101 void insert(unsigned, const Row &);
102 unsigned get_n_rows() const { return rows.size(); }
103 const Row &get_row(unsigned) const;
105 void tick(const Msp::Time::TimeStamp &);
106 void save(std::list<Msp::DataFile::Statement> &) const;
108 Track &get_sensor(unsigned);
109 Track &get_turnout(unsigned);
110 Zone &get_zone(const std::string &);
111 void sensor_event(unsigned, bool);
112 void block_reserved(Block &, Train *);
113 void train_advanced(Block &);
114 void train_arrived();