X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibmarklin%2Ftimetable.h;h=72e12d3d9980f5ca1a66732678c88abfd17cf20e;hb=97443d96ff3ce51388d2edd1e0dca8f2cd231346;hp=39cff5ee6b2b14a077445521783ac2039630acd9;hpb=a9180bc4bb7ff4c403e206cc2c785ff32544a0d6;p=r2c2.git diff --git a/source/libmarklin/timetable.h b/source/libmarklin/timetable.h index 39cff5e..72e12d3 100644 --- a/source/libmarklin/timetable.h +++ b/source/libmarklin/timetable.h @@ -10,6 +10,7 @@ Distributed under the GPL #include #include +#include #include #include @@ -18,7 +19,7 @@ namespace Marklin { class Block; class Train; -class Timetable +class Timetable: public sigc::trackable { public: class Loader: public Msp::DataFile::ObjectLoader @@ -26,9 +27,11 @@ public: public: Loader(Timetable &); private: + void arrive(); void go_to(const std::string &); void route(const std::string &); - void speed(int); + void reverse(); + void speed(unsigned); void travel(const std::string &); void wait(unsigned); }; @@ -38,22 +41,35 @@ public: GOTO, TRAVEL, WAIT, + ARRIVE, SPEED, + REVERSE, ROUTE }; struct Row { RowType type; - int intparam; - std::string strparam; + std::vector params; - Row(RowType, int); - Row(RowType, const std::string &); + Row(RowType); + + template + Row(RowType, const T &); + + template + const T &get_param(unsigned) const; + + std::string str() const; + + Msp::DataFile::Statement save() const; + + static Row parse(const std::string &); }; private: Train &train; + bool enabled; std::vector rows; unsigned current_row; bool executing; @@ -63,6 +79,16 @@ private: public: Timetable(Train &); + void set_enabled(bool); + bool is_enabled() const { return enabled; } + void reset(); + + void clear(); + void append(const Row &); + void insert(unsigned, const Row &); + unsigned get_n_rows() const { return rows.size(); } + const Row &get_row(unsigned) const; + void tick(const Msp::Time::TimeStamp &); void save(std::list &) const; private: