void TrainRoutePlanner::plan()
{
- RoutingStep *goal = 0;
+ const RoutingStep *goal = 0;
for(list<RoutingStep>::iterator i=steps.begin(); i!=steps.end(); ++i)
{
if(i->is_goal())
create_routes(*goal);
}
-void TrainRoutePlanner::add_steps(RoutingStep &step)
+void TrainRoutePlanner::add_steps(const RoutingStep &step)
{
list<RoutingStep> new_steps;
step.create_successors(new_steps);
steps.merge(new_steps);
}
-void TrainRoutePlanner::create_routes(RoutingStep &goal)
+void TrainRoutePlanner::create_routes(const RoutingStep &goal)
{
for(vector<TrainRoutingInfo>::iterator i=routed_trains.begin(); i!=routed_trains.end(); ++i)
{
i->route->set_temporary(true);
}
- for(RoutingStep *i=&goal; i; i=i->prev)
+ for(const RoutingStep *i=&goal; i; i=i->prev)
{
- for(vector<TrainRoutingState>::iterator j=i->trains.begin(); j!=i->trains.end(); ++j)
+ for(vector<TrainRoutingState>::const_iterator j=i->trains.begin(); j!=i->trains.end(); ++j)
{
if(j->state==WAITING || j->state==BLOCKED)
j->info->waits.push_front(&*j);
for(vector<TrainRoutingInfo>::iterator i=routed_trains.begin(); i!=routed_trains.end(); ++i)
{
i->router->set_route(i->route);
- TrainRoutingState *current_wait = 0;
- for(list<TrainRoutingState *>::iterator j=i->waits.begin(); j!=i->waits.end(); ++j)
+ const TrainRoutingState *current_wait = 0;
+ for(list<const TrainRoutingState *>::const_iterator j=i->waits.begin(); j!=i->waits.end(); ++j)
if(!current_wait || (*j)->track.track()!=current_wait->track.track())
{
Block &block = (*j)->track.next()->get_block();
prev(0)
{ }
-TrainRoutePlanner::RoutingStep::RoutingStep(RoutingStep *p):
+TrainRoutePlanner::RoutingStep::RoutingStep(const RoutingStep *p):
time(p->time),
trains(p->trains),
prev(p)
{ }
-void TrainRoutePlanner::RoutingStep::create_successors(list<RoutingStep> &new_steps)
+void TrainRoutePlanner::RoutingStep::create_successors(list<RoutingStep> &new_steps) const
{
RoutingStep next(this);
if(next.update_states())
float speed;
TrainRouter *router;
Route *route;
- std::list<TrainRoutingState *> waits;
+ std::list<const TrainRoutingState *> waits;
TrainRoutingInfo(Train &);
};
{
Msp::Time::TimeDelta time;
std::vector<TrainRoutingState> trains;
- RoutingStep *prev;
+ const RoutingStep *prev;
RoutingStep();
- RoutingStep(RoutingStep *);
+ RoutingStep(const RoutingStep *);
- void create_successors(std::list<RoutingStep> &);
+ void create_successors(std::list<RoutingStep> &) const;
bool update_states();
bool check_deadlocks() const;
int get_occupant(Track &) const;
void plan();
private:
- void add_steps(RoutingStep &);
- void create_routes(RoutingStep &);
+ void add_steps(const RoutingStep &);
+ void create_routes(const RoutingStep &);
};
} // namespace R2C2