]> git.tdb.fi Git - r2c2.git/blob - source/libr2c2/blockiter.h
Strip Id tags and copyright notices from files
[r2c2.git] / source / libr2c2 / blockiter.h
1 #ifndef LIBR2C2_BLOCKITER_H_
2 #define LIBR2C2_BLOCKITER_H_
3
4 namespace R2C2 {
5
6 class Block;
7 class Route;
8 class TrackIter;
9
10 /**
11 An iterator for traversing blocks.
12 */
13 class BlockIter
14 {
15 private:
16         Block *_block;
17         unsigned _entry;
18
19 public:
20         BlockIter();
21         BlockIter(Block *, unsigned);
22
23         Block *block() const { return _block; }
24         unsigned entry() const { return _entry; }
25         TrackIter track_iter() const;
26         const Block::Endpoint &endpoint() const;
27
28 private:
29         int get_exit(const Route *) const;
30 public:
31         BlockIter next(const Route * = 0) const;
32         BlockIter reverse(const Route * = 0) const;
33         BlockIter flip() const;
34
35         Block &operator*() const;
36         Block *operator->() const { return _block; }
37         bool operator==(const BlockIter &) const;
38         bool operator!=(const BlockIter &other) const { return !(*this==other); }
39         operator bool() const { return _block!=0; }
40 };
41
42 } // namespace R2C2
43
44 #endif