X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Ftrain.h;h=e3eebe1fc5d050d2d3b2a230eaa332416c909a1f;hb=d2dfed1a38c5e8487532e9055fad464cf54efd83;hp=461a27e583146bde1080e64acbb6384b0c33a3e6;hpb=dec294d40194a640e7b4bccf20dd1baa4a87038c;p=r2c2.git diff --git a/source/libr2c2/train.h b/source/libr2c2/train.h index 461a27e..e3eebe1 100644 --- a/source/libr2c2/train.h +++ b/source/libr2c2/train.h @@ -5,14 +5,15 @@ #include #include #include -#include "block.h" -#include "blockiter.h" +#include "blockallocator.h" #include "controller.h" +#include "sensor.h" #include "trainai.h" namespace R2C2 { class ArticleNumber; +class Block; class SpeedQuantizer; class Vehicle; class VehicleType; @@ -30,12 +31,10 @@ public: Loader(Train &); private: virtual void finish(); - void block(unsigned); - void block_hint(unsigned); + void blocks(); void name(const std::string &); void quantized_speed(); void router(); - void timetable(); void vehicle(ArticleNumber); }; @@ -46,8 +45,6 @@ public: sigc::signal signal_advanced; private: - typedef std::list BlockList; - Layout &layout; const VehicleType &loco_type; unsigned address; @@ -55,11 +52,7 @@ private: std::string name; const Train *preceding_train; std::vector vehicles; - BlockList blocks; - BlockList::iterator cur_blocks_end; - Block *pending_block; - Block *stop_at_block; - bool reserving; + BlockAllocator allocator; bool advancing; Controller *controller; std::list ais; @@ -70,8 +63,8 @@ private: Msp::Time::TimeStamp stop_timeout; unsigned functions; + BlockIter last_entry_block; Msp::Time::TimeStamp last_entry_time; - float travel_dist; bool pure_speed; SpeedQuantizer *speed_quantizer; bool accurate_position; @@ -120,15 +113,14 @@ public: return 0; } - void place(Block &, unsigned); + void place(const BlockIter &); void unplace(); - bool is_placed() const { return !blocks.empty(); } + bool is_placed() const { return !allocator.empty(); } void stop_at(Block *); bool free_block(Block &); void free_noncritical_blocks(); - const BlockIter &get_head_block() const; - const BlockIter &get_tail_block() const; - int get_entry_to_block(const Block &) const; + void reserve_more(); + const BlockAllocator &get_block_allocator() const { return allocator; } float get_reserved_distance() const; void tick(const Msp::Time::TimeStamp &, const Msp::Time::TimeDelta &); @@ -138,17 +130,10 @@ private: void control_changed(const Controller::Control &); void loco_speed_event(unsigned, unsigned, bool); void loco_func_event(unsigned, unsigned, bool); - void block_state_changed(Block &, Block::State); - void turnout_path_changed(Track &); + void sensor_state_changed(Sensor &, Sensor::State); void halt_event(bool); void block_reserved(const Block &, const Train *); -public: - void reserve_more(); -private: - float get_reserved_distance_until(const Block *, bool) const; - void release_blocks(); - void release_blocks(BlockList::iterator, BlockList::iterator); - void reverse_blocks(BlockList &) const; + float get_reserved_distance_until(const Block *) const; }; } // namespace R2C2