Logging improvements to allow prettier displays in the server GUI.
[dcpomatic.git] / src / lib / position.h
1 /*
2     Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
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 Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef DCPOMATIC_POSITION_H
21 #define DCPOMATIC_POSITION_H
22
23 /** @struct Position
24  *  @brief A position (x and y coordinates)
25  */
26 template <class T>
27 class Position
28 {
29 public:
30         Position ()
31                 : x (0)
32                 , y (0)
33         {}
34
35         Position (T x_, T y_)
36                 : x (x_)
37                 , y (y_)
38         {}
39
40         /** x coordinate */
41         T x;
42         /** y coordinate */
43         T y;
44 };
45
46 template<class T>
47 Position<T>
48 operator+ (Position<T> const & a, Position<T> const & b)
49 {
50         return Position<T> (a.x + b.x, a.y + b.y);
51 }
52
53 template<class T>
54 Position<T>
55 operator- (Position<T> const & a, Position<T> const & b)
56 {
57         return Position<T> (a.x - b.x, a.y - b.y);
58 }
59
60 template<class T>
61 bool
62 operator== (Position<T> const & a, Position<T> const & b)
63 {
64         return a.x == b.x && a.y == b.y;
65 }
66
67 template<class T>
68 bool
69 operator!= (Position<T> const & a, Position<T> const & b)
70 {
71         return a.x != b.x || a.y != b.y;
72 }
73
74 #endif