X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Fblockiter.h;fp=source%2Flibr2c2%2Fblockiter.h;h=5c235a54eb2a05be726755a529b73a17ed19ce17;hb=1ff06c5bc46a677fa389ef86c6b26664368f1653;hp=0000000000000000000000000000000000000000;hpb=9b05c573a38639827697fe393d55b7c76f5bde45;p=r2c2.git diff --git a/source/libr2c2/blockiter.h b/source/libr2c2/blockiter.h new file mode 100644 index 0000000..5c235a5 --- /dev/null +++ b/source/libr2c2/blockiter.h @@ -0,0 +1,51 @@ +/* $Id$ + +This file is part of R²C² +Copyright © 2010 Mikkosoft Productions, Mikko Rasa +Distributed under the GPL +*/ + +#ifndef LIBR2C2_BLOCKITER_H_ +#define LIBR2C2_BLOCKITER_H_ + +namespace R2C2 { + +class Block; +class Route; +class TrackIter; + +/** +An iterator for traversing blocks. +*/ +class BlockIter +{ +private: + Block *_block; + unsigned _entry; + +public: + BlockIter(); + BlockIter(Block *, unsigned); + + Block *block() const { return _block; } + unsigned entry() const { return _entry; } + TrackIter track_iter() const; + const Block::Endpoint &endpoint() const; + +private: + int get_exit(const Route *) const; +public: + BlockIter next(const Route * = 0) const; + BlockIter reverse(const Route * = 0) const; + BlockIter flip() const; + + Block &operator*() const; + Block *operator->() const { return _block; } + bool operator==(const BlockIter &) const; + bool operator!=(const BlockIter &other) const { return !(*this==other); } + operator bool() const { return _block!=0; } +}; + +} // namespace R2C2 + +#endif