ESA JPIP server  0.1
point.h
Go to the documentation of this file.
1 #ifndef _JPEG2000_POINT_H_
2 #define _JPEG2000_POINT_H_
3 
4 
5 #include <iostream>
6 
7 
8 namespace jpeg2000
9 {
10  using namespace std;
11 
12 
18  class Point
19  {
20  public:
21  int x;
22  int y;
23 
28  {
29  x = y = 0;
30  }
31 
37  Point(int x, int y)
38  {
39  this->x = x;
40  this->y = y;
41  }
42 
46  Point(const Point& p)
47  {
48  *this = p;
49  }
50 
54  Point& operator=(const Point& p)
55  {
56  x = p.x;
57  y = p.y;
58 
59  return *this;
60  }
61 
67  {
68  x++;
69  y++;
70 
71  return *this;
72  }
73 
79  {
80  x--;
81  y--;
82 
83  return *this;
84  }
85 
91  Point& operator+=(int val)
92  {
93  x += val;
94  y += val;
95 
96  return *this;
97  }
98 
104  Point& operator-=(int val)
105  {
106  x -= val;
107  y -= val;
108 
109  return *this;
110  }
111 
117  Point& operator*=(int val)
118  {
119  x *= val;
120  y *= val;
121 
122  return *this;
123  }
124 
130  Point& operator/=(int val)
131  {
132  x /= val;
133  y /= val;
134 
135  return *this;
136  }
137 
142  friend Point operator+(const Point& a, int value)
143  {
144  return Point(a.x + value, a.y + value);
145  }
146 
151  friend Point operator-(const Point& a, int value)
152  {
153  return Point(a.x - value, a.y - value);
154  }
155 
160  friend Point operator*(const Point& a, int value)
161  {
162  return Point(a.x * value, a.y * value);
163  }
164 
169  friend Point operator/(const Point& a, int value)
170  {
171  return Point(a.x / value, a.y / value);
172  }
173 
178  friend Point operator+(const Point& a, const Point& b)
179  {
180  return Point(a.x + b.x, a.y + b.y);
181  }
182 
187  friend Point operator-(const Point& a, const Point& b)
188  {
189  return Point(a.x - b.x, a.y - b.y);
190  }
191 
196  friend Point operator*(const Point& a, const Point& b)
197  {
198  return Point(a.x * b.x, a.y * b.y);
199  }
200 
205  friend Point operator/(const Point& a, const Point& b)
206  {
207  return Point(a.x / b.x, a.y / b.y);
208  }
209 
213  friend bool operator==(const Point& a, const Point& b)
214  {
215  return ((a.x == b.x) && (a.y == b.y));
216  }
217 
221  friend bool operator!=(const Point& a, const Point& b)
222  {
223  return ((a.x != b.x) || (a.y != b.y));
224  }
225 
226  friend ostream& operator << (ostream &out, const Point &point)
227  {
228  out << "(" << point.x << ", " << point.y << ")";
229  return out;
230  }
231 
232  template<typename T> T& SerializeWith(T& stream)
233  {
234  return (stream & x & y);
235  }
236 
237  virtual ~Point()
238  {
239  }
240  };
241 
247  typedef Point Size;
248 
249 }
250 
251 
252 #endif /* _JPEG2000_POINT_H_ */
Point & operator--()
Decrements by one the two values.
Definition: point.h:78
friend Point operator/(const Point &a, const Point &b)
Returns the division of two points.
Definition: point.h:205
virtual ~Point()
Definition: point.h:237
friend Point operator-(const Point &a, const Point &b)
Returns the subtraction of two points.
Definition: point.h:187
Point Size
It is a synonymous of the class Point.
Definition: point.h:247
friend Point operator-(const Point &a, int value)
Returns the subtraction of a point with an integer value.
Definition: point.h:151
friend Point operator+(const Point &a, int value)
Returns the sum of a point with an integer value.
Definition: point.h:142
Point(int x, int y)
Initializes the object.
Definition: point.h:37
Point()
Initializes the object.
Definition: point.h:27
friend bool operator!=(const Point &a, const Point &b)
Returns true if the two points are not equal.
Definition: point.h:221
STL namespace.
Point & operator+=(int val)
Increments the two values.
Definition: point.h:91
Point(const Point &p)
Copy constructor.
Definition: point.h:46
Point & operator=(const Point &p)
Copy assignment.
Definition: point.h:54
Point & operator*=(int val)
Multiplies the two values by one value.
Definition: point.h:117
friend bool operator==(const Point &a, const Point &b)
Returns true if the two points are equal.
Definition: point.h:213
friend Point operator*(const Point &a, const Point &b)
Returns the multiplication of two points.
Definition: point.h:196
friend Point operator+(const Point &a, const Point &b)
Returns the sum of two points.
Definition: point.h:178
T & SerializeWith(T &stream)
Definition: point.h:232
Point & operator-=(int val)
Decrements the two values.
Definition: point.h:104
Represents a couple of integer values that can be used to identify a coordinate as well as a size...
Definition: point.h:18
int y
Value Y.
Definition: point.h:22
Set of classes for handling (reading and indexing) image files with the format defined in the Part 1 ...
Definition: codestream_index.h:10
int x
Value X.
Definition: point.h:21
friend Point operator*(const Point &a, int value)
Returns the multiplication of a point with an integer value.
Definition: point.h:160
Point & operator/=(int val)
Divides the two values by one value.
Definition: point.h:130
friend Point operator/(const Point &a, int value)
Returns the division of a point with an integer value.
Definition: point.h:169
Point & operator++()
Increments by one the two values.
Definition: point.h:66
ostream & operator<<(ostream &out, const Request &request)
Definition: request.cc:65