00001 #ifndef __SIZE2_H__ 00002 #define __SIZE2_H__ 00003 00004 #ifndef DOXYGEN_IGNORE_TAG 00005 00026 #endif 00027 00028 #include <iostream> 00029 00030 #include "Vec2.h" 00031 00032 template <typename T> 00033 struct Size2 00034 { 00035 T width; 00036 T height; 00038 Size2(void):width(0),height(0) {} 00039 00041 00045 Size2(const T& width, const T& height):width(width),height(height) {} 00046 00047 template <typename U> 00048 Size2(const Vec2<U>& size):width(size.x),height(size.y) {} 00049 00050 bool operator==(const Size2<T>& s)const 00051 { 00052 if ( s.width == this->width && s.height == this->height ) 00053 { 00054 return true; 00055 } 00056 00057 return false; 00058 } 00059 }; 00060 00061 template <typename T> 00062 std::ostream& operator<< (std::ostream& o, const Size2<T>& s) 00063 { 00064 o << "Size2(" << s.width << ";" << s.height << ")"; 00065 00066 return o; 00067 } 00068 00069 template <typename T> 00070 bool operator< (const Size2<T>& s1, const Size2<T>& s2) 00071 { 00072 if ( s1.width < s2.width && s1.height < s2.height ) 00073 { 00074 return true; 00075 } 00076 00077 return false; 00078 } 00079 00080 typedef Size2<int> ISize2; 00081 typedef Size2<unsigned int> USize2; 00082 00104 #endif