1 /***************************************************************************
2  *      Mechanized Assault and Exploration Reloaded Projectfile            *
3  *                                                                         *
4  *   This program is free software; you can redistribute it and/or modify  *
5  *   it under the terms of the GNU General Public License as published by  *
6  *   the Free Software Foundation; either version 2 of the License, or     *
7  *   (at your option) any later version.                                   *
8  *                                                                         *
9  *   This program is distributed in the hope that it will be useful,       *
10  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12  *   GNU General Public License for more details.                          *
13  *                                                                         *
14  *   You should have received a copy of the GNU General Public License     *
15  *   along with this program; if not, write to the                         *
16  *   Free Software Foundation, Inc.,                                       *
17  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
18  ***************************************************************************/
19 
20 #ifndef utility_positionH
21 #define utility_positionH
22 
23 #include "utility/fixedvector.h"
24 
25 /**
26  * Fixed vector class for 2-dimensional integer positions.
27  */
28 class cPosition : public cFixedVector<int, 2>
29 {
30 public:
cPosition()31 	cPosition() {}
cPosition(const cPosition & other)32 	cPosition (const cPosition& other) :
33 		cFixedVector<int, 2> (other)
34 	{}
cPosition(const cFixedVector<int,2> & other)35 	cPosition (const cFixedVector<int, 2>& other) :
36 		cFixedVector<int, 2> (other)
37 	{}
cPosition(int x_,int y_)38 	cPosition (int x_, int y_)
39 	{
40 		x() = x_;
41 		y() = y_;
42 	}
43 
x()44 	int x() const
45 	{
46 		return (*this)[0];
47 	}
y()48 	int y() const
49 	{
50 		return (*this)[1];
51 	}
52 
x()53 	int& x()
54 	{
55 		return (*this)[0];
56 	}
y()57 	int& y()
58 	{
59 		return (*this)[1];
60 	}
61 
62 	cPosition& operator= (const value_type& value)
63 	{
64 		cFixedVector<int, 2>::operator= (value);
65 		return *this;
66 	}
67 };
68 
69 #endif // utility_positionH
70