1 #ifndef BLUB_MATH_VECTOR2TEMPLATE_HPP
2 #define BLUB_MATH_VECTOR2TEMPLATE_HPP
4 #include "blub/core/globals.hpp"
5 #include "blub/serialization/access.hpp"
6 #include "blub/serialization/nameValuePair.hpp"
8 #include <boost/functional/hash.hpp>
14 template <
typename valueType, valueType valueDefault>
18 typedef vector2Template<valueType, valueDefault> t_thisClass;
27 vector2Template(
const valueType& x_,
const valueType& y_)
34 vector2Template(
const valueType& val)
41 vector2Template(
const t_thisClass& copy)
48 bool operator == (
const t_thisClass& other)
const
50 return other.x == x && other.y == y;
53 bool operator <= (
const t_thisClass& other)
const
55 return x <= other.x && y <= other.y;
58 bool operator < (
const t_thisClass& other)
const
60 return x < other.x && y < other.y;
63 bool operator >= (
const t_thisClass& other)
const
65 return x >= other.x && y >= other.y;
68 bool operator > (
const t_thisClass& other)
const
70 return x > other.x && y > other.y;
73 t_thisClass operator * (
const t_thisClass& other)
const
75 return t_thisClass(other.x*x, other.y*y);
78 t_thisClass operator * (
const int32& other)
const
80 return t_thisClass(other*x, other*y);
83 t_thisClass operator + (
const t_thisClass& other)
const
85 return t_thisClass(other.x+x, other.y+y);
88 t_thisClass operator - (
const t_thisClass& other)
const
90 return t_thisClass(x-other.x, y-other.y);
93 t_thisClass operator - (
void)
const
95 return t_thisClass(-x, -y);
98 t_thisClass operator / (
const t_thisClass& other)
const
100 return t_thisClass(x/other.x, y/other.y);
103 t_thisClass operator / (
const valueType& other)
const
105 return t_thisClass(x/other, y/other);
108 valueType calculateArea()
const
114 BLUB_SERIALIZATION_ACCESS
115 template<
typename Archive>
116 void serialize(Archive & readWrite,
const unsigned int version)
120 readWrite & BLUB_SERIALIZATION_NAMEVALUEPAIR(x);
121 readWrite & BLUB_SERIALIZATION_NAMEVALUEPAIR(y);
130 template <
typename valueType, valueType valueDefault>
131 std::ostream& operator<< (std::ostream& ostr, const vector2Template<valueType, valueDefault>& toCast)
133 return ostr <<
"(" << toCast.x <<
"," << toCast.y <<
")";
136 template <
typename valueType, valueType valueDefault>
137 std::size_t hash_value(
const vector2Template<valueType, valueDefault>& value)
139 std::size_t result(value.x);
140 boost::hash_combine(result, value.y);
149 #endif // BLUB_MATH_VECTOR2TEMPLATE_HPP
Definition: deadlineTimer.hpp:10