X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Ftrain.h;h=6b384f8220b9eece5e5873ead9ab07283d601755;hb=54392d65e2053d1eacb4cfcc435f1013993f2973;hp=461a27e583146bde1080e64acbb6384b0c33a3e6;hpb=dec294d40194a640e7b4bccf20dd1baa4a87038c;p=r2c2.git diff --git a/source/libr2c2/train.h b/source/libr2c2/train.h index 461a27e..6b384f8 100644 --- a/source/libr2c2/train.h +++ b/source/libr2c2/train.h @@ -6,7 +6,7 @@ #include #include #include "block.h" -#include "blockiter.h" +#include "blockallocator.h" #include "controller.h" #include "trainai.h" @@ -30,8 +30,7 @@ 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(); @@ -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; @@ -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 &); @@ -139,16 +131,9 @@ private: 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 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; }; } // namespace R2C2