/* -*- C++ -*- * Copyright ©2004 Hugo Mills * * This software is distributed under the terms of the GNU GPL v3 * For more information on the GPL, see the file COPYING or * visit http://www.gnu.org/ * * This software is distributed without warranty */ #ifndef CROSSING_H #define CROSSING_H #include "direction.h" #include "coordinate.h" class Crossing { public: Crossing() : _pos(-1, -1), _d(), _isc(true) { } Crossing(int x, int y, Direction d) : _pos(x, y), _d(d), _isc(false) { } Crossing(int x, int y) : _pos(x, y), _d(0), _isc(true) { } Crossing(const iCoordinate& c) : _pos(c), _d(0), _isc(true) { } Crossing(const iCoordinate& c, Direction d) : _pos(c), _d(d), _isc(false) { } iCoordinate start(void) const { return _pos; } iCoordinate end(void) const; const iCoordinate& pos(void) const { return _pos; } Crossing opp(void) const; bool operator==(const Crossing& c) const; bool _isc; iCoordinate _pos; Direction _d; }; std::ostream& operator<<(std::ostream& o, const Crossing& c); class Diff { public: Diff(int x, int y, int d) : _pos(x, y), _d(d), _isc(false) { } Diff(int x, int y) : _pos(x, y), _d(0), _isc(true) { } bool isc(void) const { return _isc; } int x(void) const { return _pos.x; } int y(void) const { return _pos.y; } iCoordinate pos(void) const { return _pos; } Direction d(void) const { return _d; } private: bool _isc; iCoordinate _pos; Direction _d; }; Crossing operator+(const Crossing& c, const Diff& d); #endif