diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/engine/core/util/structures/utilstructures.i	Sun Jun 29 18:44:17 2008 +0000
@@ -0,0 +1,78 @@
+%{
+#include "util/structures/point.h"
+#include "util/structures/rect.h"
+%}
+
+namespace FIFE {
+
+	template <typename T> class PointType2D {
+	public:
+		T x;
+		T y;
+		explicit PointType2D(T _x = 0, T _y = 0);
+		PointType2D<T> operator+(const PointType2D<T>& p) const;
+		PointType2D<T> operator-(const PointType2D<T>& p) const;
+		PointType2D<T>& operator+=(const PointType2D<T>& p);
+		PointType2D<T>& operator-=(const PointType2D<T>& p);
+		PointType2D<T> operator*(const T& i) const;
+		PointType2D<T> operator/(const T& i) const;
+		bool operator==(const PointType2D<T>& p) const;
+		bool operator!=(const PointType2D<T>& p) const;
+		T length() const;
+	};
+
+	template<typename T>
+	std::ostream& operator<<(std::ostream& os, const PointType2D<T>& p);
+
+	typedef PointType2D<int> Point;
+	typedef PointType2D<int> IntPoint;
+	typedef PointType2D<double> DoublePoint;
+	typedef PointType2D<int> IntPoint2D;
+	typedef PointType2D<double> DoublePoint2D;
+
+	%template(Point) PointType2D<int>;
+	%template(DoublePoint) PointType2D<double>;
+
+	template <typename T> class PointType3D {
+	public:
+		T x;
+		T y;
+		T z;
+		explicit PointType3D(T _x = 0, T _y = 0, T _z = 0);
+		PointType3D<T> operator+(const PointType3D<T>& p) const;
+		PointType3D<T> operator-(const PointType3D<T>& p) const;
+		PointType3D<T>& operator+=(const PointType3D<T>& p);
+		PointType3D<T>& operator-=(const PointType3D<T>& p);
+		PointType3D<T> operator*(const T& i) const;
+		PointType3D<T> operator/(const T& i) const;
+		bool operator==(const PointType3D<T>& p) const;
+		bool operator!=(const PointType3D<T>& p) const;
+		T length() const;
+	};
+
+	template<typename T>
+	std::ostream& operator<<(std::ostream& os, const PointType3D<T>& p);
+
+	typedef PointType3D<int> Point3D;
+	typedef PointType3D<int> IntPoint3D;
+	typedef PointType3D<double> DoublePoint3D;
+
+	%template(Point3D) PointType3D<int>;
+	%template(DoublePoint3D) PointType3D<double>;
+	
+	class Rect {
+	public:
+		int x;
+		int y;
+		int w;
+		int h;
+		explicit Rect(int x = 0, int y = 0, unsigned int width = 0, unsigned int height = 0);
+		int right() const;
+		int bottom() const;
+		bool operator==(const Rect& rect ) const;
+		bool contains( const Point& point ) const;
+		bool intersects( const Rect& rect ) const;
+		bool intersectInplace( const Rect& rect );
+	};
+	std::ostream& operator<<(std::ostream&, const Rect&);
+}