#include <sigc++/trackable.h>
#include <msp/datafile/objectloader.h>
#include <msp/time/timestamp.h>
-#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;
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);
};
sigc::signal<void, Block &> signal_advanced;
private:
- typedef std::list<BlockIter> BlockList;
-
Layout &layout;
const VehicleType &loco_type;
unsigned address;
std::string name;
const Train *preceding_train;
std::vector<Vehicle *> 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<TrainAI *> ais;
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;
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 &);
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