11 BlockIter::BlockIter():
16 BlockIter::BlockIter(Block *b, unsigned e):
20 if(_block && _entry>_block->get_endpoints().size())
21 throw out_of_range("BlockIter::BlockIter");
24 TrackIter BlockIter::track_iter() const
29 return _block->get_endpoint(_entry).track_iter();
32 const Block::Endpoint &BlockIter::endpoint() const
35 throw logic_error("null block");
37 return _block->get_endpoint(_entry);
40 int BlockIter::get_exit(const Route *route) const
42 const vector<Block::Endpoint> &eps = _block->get_endpoints();
43 if(_block->get_turnout_address())
45 /* The endpoints of a turnout block exactly correspond to the endpoints
47 TrackIter t_iter = track_iter();
48 unsigned path = (route ? route->get_path(*t_iter) : t_iter->get_active_path());
49 return t_iter.reverse(path).entry();
51 else if(eps.size()==2)
57 BlockIter BlockIter::next(const Route *route) const
62 int exit = get_exit(route);
67 result._block = _block->get_link(exit);
68 result._entry = (result._block ? result._block->get_endpoint_by_link(*_block) : 0);
73 BlockIter BlockIter::reverse(const Route *route) const
78 int exit = get_exit(route);
82 return BlockIter(_block, exit);
85 BlockIter BlockIter::flip() const
91 result._block = _block->get_link(_entry);
92 result._entry = (result._block ? result._block->get_endpoint_by_link(*_block) : 0);
97 Block &BlockIter::operator*() const
100 throw logic_error("null block");
105 bool BlockIter::operator==(const BlockIter &other) const
107 return _block==other._block && _entry==other._entry;