X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Ftimetable.h;h=f8fc8a0ed97346ca6a2eefc0c1f3f547088febd4;hb=cb4e53ba1b8ea41b978190de6668e9862b9cfea8;hp=86b4ae2944c8e21ebb207d49e27e54a946d62dbf;hpb=7e27b311e33beda1746eb63e0945633f262427f6;p=r2c2.git diff --git a/source/libr2c2/timetable.h b/source/libr2c2/timetable.h index 86b4ae2..f8fc8a0 100644 --- a/source/libr2c2/timetable.h +++ b/source/libr2c2/timetable.h @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of R²C² -Copyright © 2010 Mikkosoft Productions, Mikko Rasa -Distributed under the GPL -*/ - #ifndef LIBR2C2_TIMETABLE_H_ #define LIBR2C2_TIMETABLE_H_ @@ -12,7 +5,8 @@ Distributed under the GPL #include #include #include -#include +#include "sensor.h" +#include "trainai.h" namespace R2C2 { @@ -21,7 +15,7 @@ class Track; class Train; class Zone; -class Timetable: public sigc::trackable +class Timetable: public TrainAI, public sigc::trackable { public: class Loader: public Msp::DataFile::ObjectLoader @@ -31,22 +25,26 @@ public: private: void arrive(); void goto_sensor(unsigned); - void goto_sensor(const std::string &); + void goto_sensor_str(const std::string &); void goto_zone(const std::string &); void route(const std::string &); void reverse(); void speed(unsigned); - void travel(const std::string &); + void travel_to(unsigned); + void travel_past(unsigned); void wait(unsigned); void wait_train(unsigned, unsigned); + void wait_until(unsigned, unsigned); }; enum RowType { GOTO_SENSOR, GOTO_ZONE, - TRAVEL, + TRAVEL_TO, + TRAVEL_PAST, WAIT_TIME, + WAIT_UNTIL, WAIT_TRAIN, ARRIVE, SPEED, @@ -75,7 +73,6 @@ public: }; private: - Train &train; bool enabled; std::vector rows; unsigned current_row; @@ -83,6 +80,7 @@ private: Block *pending_block; Train *pending_train; Msp::Time::TimeStamp wait_timeout; + bool arrived; public: Timetable(Train &); @@ -97,13 +95,16 @@ public: unsigned get_n_rows() const { return rows.size(); } const Row &get_row(unsigned) const; - void tick(const Msp::Time::TimeStamp &); + void tick(const Msp::Time::TimeStamp &, const Msp::Time::TimeDelta &); void save(std::list &) const; private: - Track &get_sensor(unsigned); + Block &get_sensor(unsigned); + Track &get_turnout(unsigned); Zone &get_zone(const std::string &); - void sensor_event(unsigned, bool); - void train_arrived(); + void sensor_state_changed(Sensor &, Sensor::State); + void block_reserved(Block &, Train *); + void train_advanced(Block &); + void event(TrainAI &, const Message &); }; } // namespace R2C2