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 const Block::Endpoint &ep = _block->get_endpoint(_entry);
30 return TrackIter(ep.track, ep.track_ep);
33 const Block::Endpoint &BlockIter::endpoint() const
36 throw logic_error("null block");
38 return _block->get_endpoint(_entry);
41 int BlockIter::get_exit(const Route *route) const
43 const vector<Block::Endpoint> &eps = _block->get_endpoints();
44 TrackIter t_iter = track_iter();
48 if(!_block->has_track(*t_iter))
49 throw logic_error("internal error (block traversal escaped the block)");
51 unsigned path = (route ? route->get_path(*t_iter) : t_iter->get_active_path());
52 TrackIter t_exit = t_iter.reverse(path);
54 for(unsigned i=0; i<eps.size(); ++i)
55 if(eps[i].track==t_exit.track() && eps[i].track_ep==t_exit.entry())
58 t_iter = t_exit.flip();
64 BlockIter BlockIter::next(const Route *route) const
69 int exit = get_exit(route);
74 result._block = _block->get_link(exit);
75 result._entry = (result._block ? result._block->get_endpoint_by_link(*_block) : 0);
80 BlockIter BlockIter::reverse(const Route *route) const
85 int exit = get_exit(route);
89 return BlockIter(_block, exit);
92 BlockIter BlockIter::flip() const
98 result._block = _block->get_link(_entry);
99 result._entry = (result._block ? result._block->get_endpoint_by_link(*_block) : 0);
104 Block &BlockIter::operator*() const
107 throw logic_error("null block");
112 bool BlockIter::operator==(const BlockIter &other) const
114 return _block==other._block && _entry==other._entry;