]> git.tdb.fi Git - r2c2.git/blob - source/libmarklin/blockiter.h
Make LCD output selectable at runtime through an extra I/O pin
[r2c2.git] / source / libmarklin / blockiter.h
1 /* $Id$
2
3 This file is part of the MSP Märklin suite
4 Copyright © 2010  Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
6 */
7
8 #ifndef LIBMARKLIN_BLOCKITER_H_
9 #define LIBMARKLIN_BLOCKITER_H_
10
11 namespace Marklin {
12
13 class Block;
14 class Route;
15 class TrackIter;
16
17 /**
18 An iterator for traversing blocks.
19 */
20 class BlockIter
21 {
22 private:
23         Block *_block;
24         unsigned _entry;
25
26 public:
27         BlockIter();
28         BlockIter(Block *, unsigned);
29
30         Block *block() const { return _block; }
31         unsigned entry() const { return _entry; }
32         TrackIter track_iter() const;
33         const Block::Endpoint &endpoint() const;
34
35 private:
36         int get_exit(const Route *) const;
37 public:
38         BlockIter next(const Route * = 0) const;
39         BlockIter reverse(const Route * = 0) const;
40         BlockIter flip() const;
41
42         Block &operator*() const;
43         Block *operator->() const { return _block; }
44         bool operator==(const BlockIter &) const;
45         bool operator!=(const BlockIter &other) const { return !(*this==other); }
46         operator bool() const { return _block!=0; }
47 };
48
49 } // namespace Marklin
50
51 #endif