coord.h

Go to the documentation of this file.
00001 /* Eliot                                                                     */
00002 /* Copyright (C) 1999  Antoine Fraboulet                                     */
00003 /*                                                                           */
00004 /* This file is part of Eliot.                                               */
00005 /*                                                                           */
00006 /* Eliot is free software; you can redistribute it and/or modify             */
00007 /* it under the terms of the GNU General Public License as published by      */
00008 /* the Free Software Foundation; either version 2 of the License, or         */
00009 /* (at your option) any later version.                                       */
00010 /*                                                                           */
00011 /* Eliot is distributed in the hope that it will be useful,                  */
00012 /* but WITHOUT ANY WARRANTY; without even the implied warranty of            */
00013 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             */
00014 /* GNU General Public License for more details.                              */
00015 /*                                                                           */
00016 /* You should have received a copy of the GNU General Public License         */
00017 /* along with this program; if not, write to the Free Software               */
00018 /* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
00019 
00020 /**
00021  *  \file   coord.h
00022  *  \brief  Board coordinates system
00023  *  \author Antoine Fraboulet
00024  *  \date   2005
00025  */
00026 
00027 #ifndef _COORD_H
00028 #define _COORD_H
00029 
00030 using std::string;
00031 
00032 class Coord
00033 {
00034 public:
00035 
00036     enum Direction {VERTICAL, HORIZONTAL};
00037 
00038     // Construction, destruction
00039     Coord(int iRow = -1, int iCol = -1, Direction iDir = HORIZONTAL);
00040     Coord(const string &iStr);
00041     virtual ~Coord() {}
00042 
00043     // Accessors
00044     void setRow(int iRow)       { m_row = iRow; }
00045     void setCol(int iCol)       { m_col = iCol; }
00046     void setDir(Direction iDir) { m_dir = iDir; }
00047     int getRow() const          { return m_row; }
00048     int getCol() const          { return m_col; }
00049     Direction getDir() const    { return m_dir; }
00050 
00051     bool isValid() const;
00052     void operator=(const Coord &iOther);
00053 
00054     // Swap the coordinates (without changing the direction)
00055     void swap();
00056 
00057     void setFromString(const string &iStr);
00058 
00059     typedef enum {
00060         COORD_MODE_COMPACT,
00061         COORD_MODE_LONG
00062     } coord_mode_t;
00063     string toString(coord_mode_t mode = COORD_MODE_COMPACT) const;
00064 
00065 private:
00066     Direction m_dir;
00067     int m_row, m_col;
00068 
00069 };
00070 
00071 #endif
00072 
00073 /// Local Variables:
00074 /// mode: c++
00075 /// mode: hs-minor
00076 /// c-basic-offset: 4
00077 /// indent-tabs-mode: nil
00078 /// End:

Generated on Thu Dec 29 02:01:14 2005 for Eliot by  doxygen 1.4.5