File indexing completed on 2024-11-24 03:43:18
0001 /******************************************************************* 0002 * 0003 * Copyright 2007 Aron Boström <c02ab@efd.lth.se> 0004 * 0005 * Bovo is free software; you can redistribute it and/or modify 0006 * it under the terms of the GNU General Public License as published by 0007 * the Free Software Foundation; either version 2, or (at your option) 0008 * any later version. 0009 * 0010 * Bovo is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 * GNU General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU General Public License 0016 * along with Bovo; see the file COPYING. If not, write to 0017 * the Free Software Foundation, 51 Franklin Street, Fifth Floor, 0018 * Boston, MA 02110-1301, USA. 0019 * 0020 ********************************************************************/ 0021 0022 #ifndef BOVO_DIMENSION_H 0023 #define BOVO_DIMENSION_H 0024 0025 #include "common.h" 0026 0027 /** @file file declaring the Dimension class */ 0028 0029 /** namespace for game engine */ 0030 namespace bovo 0031 { 0032 0033 class Coord; 0034 0035 /** 0036 * Dimension is logic container of the width and height of a playing board 0037 * 0038 * Dimension keeps the size data of a playing board, that is how wide and how 0039 * high the board is. It can also be used to verify a given Coord is inside 0040 * the limits of the Dimension (i.e. the Coord is a valid Coord on the playing 0041 * board). 0042 * 0043 * @code 0044 * Dimension dim1(15, 15); 0045 * Dimension dim2(dim1); 0046 * Coord coord(18, 7); 0047 * dim1.ok(coord); // <i>returns false</i> 0048 * for (int i = 0; i < dim2.width(); ++i) { 0049 * } 0050 * @endcode 0051 */ 0052 class Dimension 0053 { 0054 public: 0055 /** 0056 * @brief standard constructor 0057 * @description constructs a Dimension with a certain width and height 0058 * @param width the number of columns of this Dimension 0059 * @param height the number of rows of this Dimension 0060 */ 0061 Dimension(usi width, usi height); 0062 0063 /** 0064 * @brief copy constructor 0065 * @description constructs a Dimension that is a copy of a given 0066 * dimension 0067 * @param dimension the dimension to copy 0068 */ 0069 Dimension(const Dimension &dimension); 0070 0071 /** 0072 * @brief height of Dimension 0073 * @description the height (number of rows) of this Dimension 0074 * @return the height of this Dimension 0075 */ 0076 usi height() const; 0077 0078 /** 0079 * @brief width of Dimension 0080 * @description the width (number of columns) of this Dimension 0081 * @return the width of this Dimension 0082 */ 0083 usi width() const; 0084 0085 /** 0086 * @brief decides if a Coord is legal 0087 * @description decides if a given Coord is legal 0088 * (i.e. inside the bounds of this Dimension) 0089 * @param coord the coord to test 0090 * @return @c true if coord is inside bounds, $c false otherwise 0091 */ 0092 bool ok(const Coord *c) const; 0093 0094 /** 0095 * @brief decides if a Coord is legal 0096 * @description decides if a given Coord is legal 0097 * (i.e. inside the bounds of this Dimension) 0098 * @param coord the coord to test 0099 * @return @c true if coord is inside bounds, $c false otherwise 0100 */ 0101 bool ok(const Coord &coord) const; 0102 0103 private: 0104 /* height property */ 0105 usi m_height; 0106 0107 /* width property */ 0108 usi m_width; 0109 }; 0110 0111 } /* namespace bovo */ 0112 0113 #endif // BOVO_DIMENSION_H