Mercurial > fife-parpg
comparison engine/core/util/structures/utilstructures.i @ 0:4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
author | mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sun, 29 Jun 2008 18:44:17 +0000 |
parents | |
children | 90005975cdbb |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4a0efb7baf70 |
---|---|
1 %{ | |
2 #include "util/structures/point.h" | |
3 #include "util/structures/rect.h" | |
4 %} | |
5 | |
6 namespace FIFE { | |
7 | |
8 template <typename T> class PointType2D { | |
9 public: | |
10 T x; | |
11 T y; | |
12 explicit PointType2D(T _x = 0, T _y = 0); | |
13 PointType2D<T> operator+(const PointType2D<T>& p) const; | |
14 PointType2D<T> operator-(const PointType2D<T>& p) const; | |
15 PointType2D<T>& operator+=(const PointType2D<T>& p); | |
16 PointType2D<T>& operator-=(const PointType2D<T>& p); | |
17 PointType2D<T> operator*(const T& i) const; | |
18 PointType2D<T> operator/(const T& i) const; | |
19 bool operator==(const PointType2D<T>& p) const; | |
20 bool operator!=(const PointType2D<T>& p) const; | |
21 T length() const; | |
22 }; | |
23 | |
24 template<typename T> | |
25 std::ostream& operator<<(std::ostream& os, const PointType2D<T>& p); | |
26 | |
27 typedef PointType2D<int> Point; | |
28 typedef PointType2D<int> IntPoint; | |
29 typedef PointType2D<double> DoublePoint; | |
30 typedef PointType2D<int> IntPoint2D; | |
31 typedef PointType2D<double> DoublePoint2D; | |
32 | |
33 %template(Point) PointType2D<int>; | |
34 %template(DoublePoint) PointType2D<double>; | |
35 | |
36 template <typename T> class PointType3D { | |
37 public: | |
38 T x; | |
39 T y; | |
40 T z; | |
41 explicit PointType3D(T _x = 0, T _y = 0, T _z = 0); | |
42 PointType3D<T> operator+(const PointType3D<T>& p) const; | |
43 PointType3D<T> operator-(const PointType3D<T>& p) const; | |
44 PointType3D<T>& operator+=(const PointType3D<T>& p); | |
45 PointType3D<T>& operator-=(const PointType3D<T>& p); | |
46 PointType3D<T> operator*(const T& i) const; | |
47 PointType3D<T> operator/(const T& i) const; | |
48 bool operator==(const PointType3D<T>& p) const; | |
49 bool operator!=(const PointType3D<T>& p) const; | |
50 T length() const; | |
51 }; | |
52 | |
53 template<typename T> | |
54 std::ostream& operator<<(std::ostream& os, const PointType3D<T>& p); | |
55 | |
56 typedef PointType3D<int> Point3D; | |
57 typedef PointType3D<int> IntPoint3D; | |
58 typedef PointType3D<double> DoublePoint3D; | |
59 | |
60 %template(Point3D) PointType3D<int>; | |
61 %template(DoublePoint3D) PointType3D<double>; | |
62 | |
63 class Rect { | |
64 public: | |
65 int x; | |
66 int y; | |
67 int w; | |
68 int h; | |
69 explicit Rect(int x = 0, int y = 0, unsigned int width = 0, unsigned int height = 0); | |
70 int right() const; | |
71 int bottom() const; | |
72 bool operator==(const Rect& rect ) const; | |
73 bool contains( const Point& point ) const; | |
74 bool intersects( const Rect& rect ) const; | |
75 bool intersectInplace( const Rect& rect ); | |
76 }; | |
77 std::ostream& operator<<(std::ostream&, const Rect&); | |
78 } |