if(!_block)
return TrackIter();
- const Block::Endpoint &ep = _block->get_endpoints()[_entry];
+ const Block::Endpoint &ep = _block->get_endpoint(_entry);
return TrackIter(ep.track, ep.track_ep);
}
+const Block::Endpoint &BlockIter::endpoint() const
+{
+ if(!_block)
+ throw InvalidState("BlockIter is null");
+
+ return _block->get_endpoint(_entry);
+}
+
int BlockIter::get_exit(const Route *route) const
{
const vector<Block::Endpoint> &eps = _block->get_endpoints();
if(!_block->has_track(*t_iter))
throw LogicError("Block traversal strayed out of the block");
- int path = -1;
- if(t_iter->get_turnout_id() && route)
- path = route->get_turnout(t_iter->get_turnout_id());
- if(path==-1)
- path = t_iter->get_active_path();
-
+ unsigned path = (route ? route->get_path(*t_iter) : t_iter->get_active_path());
TrackIter t_exit = t_iter.reverse(path);
for(unsigned i=0; i<eps.size(); ++i)
if(eps[i].track==t_exit.track() && eps[i].track_ep==t_exit.entry())
return i;
- t_iter = t_iter.next(path);
+ t_iter = t_exit.flip();
}
return -1;