[792] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * |
---|
| 4 | * |
---|
| 5 | * License notice: |
---|
| 6 | * |
---|
| 7 | * This program is free software; you can redistribute it and/or |
---|
| 8 | * modify it under the terms of the GNU General Public License |
---|
| 9 | * as published by the Free Software Foundation; either version 2 |
---|
| 10 | * of the License, or (at your option) any later version. |
---|
| 11 | * |
---|
| 12 | * This program is distributed in the hope that it will be useful, |
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 15 | * GNU General Public License for more details. |
---|
| 16 | * |
---|
| 17 | * You should have received a copy of the GNU General Public License |
---|
| 18 | * along with this program; if not, write to the Free Software |
---|
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 20 | * |
---|
| 21 | * Author: |
---|
| 22 | * Fabian 'x3n' Landau |
---|
| 23 | * Co-authors: |
---|
| 24 | * ... |
---|
| 25 | * |
---|
| 26 | * Inspiration: MultiType by Benjamin Grauer |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | #ifndef _MultiTypeMath_H__ |
---|
| 30 | #define _MultiTypeMath_H__ |
---|
| 31 | |
---|
| 32 | #include "UtilPrereqs.h" |
---|
| 33 | |
---|
| 34 | #include "MultiTypeString.h" |
---|
| 35 | #include "Math.h" |
---|
| 36 | |
---|
| 37 | class _UtilExport MultiTypeMath : public MultiTypeString |
---|
| 38 | { |
---|
| 39 | public: |
---|
[925] | 40 | MultiTypeMath(MultiType type = MT_null); |
---|
| 41 | inline MultiTypeMath(void* value) : MultiTypeString(value) {} |
---|
[794] | 42 | inline MultiTypeMath(int value) : MultiTypeString(value) {} |
---|
| 43 | inline MultiTypeMath(unsigned int value) : MultiTypeString(value) {} |
---|
| 44 | inline MultiTypeMath(char value) : MultiTypeString(value) {} |
---|
| 45 | inline MultiTypeMath(unsigned char value) : MultiTypeString(value) {} |
---|
| 46 | inline MultiTypeMath(short value) : MultiTypeString(value) {} |
---|
| 47 | inline MultiTypeMath(unsigned short value) : MultiTypeString(value) {} |
---|
| 48 | inline MultiTypeMath(long value) : MultiTypeString(value) {} |
---|
| 49 | inline MultiTypeMath(unsigned long value) : MultiTypeString(value) {} |
---|
| 50 | inline MultiTypeMath(float value) : MultiTypeString(value) {} |
---|
| 51 | inline MultiTypeMath(double value) : MultiTypeString(value) {} |
---|
| 52 | inline MultiTypeMath(long double value) : MultiTypeString(value) {} |
---|
| 53 | inline MultiTypeMath(bool value) : MultiTypeString(value) {} |
---|
[925] | 54 | inline MultiTypeMath(const char* value) : MultiTypeString(value) {} |
---|
| 55 | inline MultiTypeMath(const std::string& value) : MultiTypeString(value) {} |
---|
| 56 | inline MultiTypeMath(const orxonox::Element& value) : MultiTypeString(value) {} |
---|
[794] | 57 | inline MultiTypeMath(const orxonox::Vector2& value) { this->setValue(value); } |
---|
| 58 | inline MultiTypeMath(const orxonox::Vector3& value) { this->setValue(value); } |
---|
| 59 | inline MultiTypeMath(const orxonox::ColourValue& value) { this->setValue(value); } |
---|
| 60 | inline MultiTypeMath(const orxonox::Quaternion& value) { this->setValue(value); } |
---|
| 61 | inline MultiTypeMath(const orxonox::Radian& value) { this->setValue(value); } |
---|
| 62 | inline MultiTypeMath(const orxonox::Degree& value) { this->setValue(value); } |
---|
[853] | 63 | inline MultiTypeMath(const MultiTypeMath& mtm) { this->setValue(mtm); } |
---|
[869] | 64 | virtual inline ~MultiTypeMath() {} |
---|
[792] | 65 | |
---|
[794] | 66 | using MultiTypeString::operator=; |
---|
| 67 | inline MultiTypeMath& operator=(const orxonox::Vector2& value) { this->setValue(value); return *this; } |
---|
| 68 | inline MultiTypeMath& operator=(const orxonox::Vector3& value) { this->setValue(value); return *this; } |
---|
| 69 | inline MultiTypeMath& operator=(const orxonox::ColourValue& value) { this->setValue(value); return *this; } |
---|
| 70 | inline MultiTypeMath& operator=(const orxonox::Quaternion& value) { this->setValue(value); return *this; } |
---|
| 71 | inline MultiTypeMath& operator=(const orxonox::Radian& value) { this->setValue(value); return *this; } |
---|
| 72 | inline MultiTypeMath& operator=(const orxonox::Degree& value) { this->setValue(value); return *this; } |
---|
[853] | 73 | inline MultiTypeMath& operator=(const MultiTypeMath& mtm) { this->setValue(mtm); return *this; } |
---|
[792] | 74 | |
---|
[794] | 75 | using MultiTypeString::operator==; |
---|
| 76 | inline bool operator==(const orxonox::Vector2& value) const { return (this->vector2_ == value); } |
---|
| 77 | inline bool operator==(const orxonox::Vector3& value) const { return (this->vector3_ == value); } |
---|
| 78 | inline bool operator==(const orxonox::ColourValue& value) const { return (this->colourvalue_ == value); } |
---|
| 79 | inline bool operator==(const orxonox::Quaternion& value) const { return (this->quaternion_ == value); } |
---|
| 80 | inline bool operator==(const orxonox::Radian& value) const { return (this->radian_ == value); } |
---|
| 81 | inline bool operator==(const orxonox::Degree& value) const { return (this->degree_ == value); } |
---|
[792] | 82 | bool operator==(const MultiTypeMath& mtm) const; |
---|
| 83 | |
---|
[794] | 84 | using MultiTypeString::operator!=; |
---|
| 85 | inline bool operator!=(const orxonox::Vector2& value) const { return (this->vector2_ != value); } |
---|
| 86 | inline bool operator!=(const orxonox::Vector3& value) const { return (this->vector3_ != value); } |
---|
| 87 | inline bool operator!=(const orxonox::ColourValue& value) const { return (this->colourvalue_ != value); } |
---|
| 88 | inline bool operator!=(const orxonox::Quaternion& value) const { return (this->quaternion_ != value); } |
---|
| 89 | inline bool operator!=(const orxonox::Radian& value) const { return (this->radian_ != value); } |
---|
| 90 | inline bool operator!=(const orxonox::Degree& value) const { return (this->degree_ != value); } |
---|
[792] | 91 | bool operator!=(const MultiTypeMath& mtm) const; |
---|
| 92 | |
---|
[925] | 93 | virtual operator void*() const; |
---|
[869] | 94 | virtual operator int() const; |
---|
| 95 | virtual operator unsigned int() const; |
---|
| 96 | virtual operator char() const; |
---|
| 97 | virtual operator unsigned char() const; |
---|
| 98 | virtual operator short() const; |
---|
| 99 | virtual operator unsigned short() const; |
---|
| 100 | virtual operator long() const; |
---|
| 101 | virtual operator unsigned long() const; |
---|
| 102 | virtual operator float () const; |
---|
| 103 | virtual operator double () const; |
---|
| 104 | virtual operator long double() const; |
---|
| 105 | virtual operator bool() const; |
---|
| 106 | virtual operator std::string() const; |
---|
| 107 | virtual operator const char*() const; |
---|
[925] | 108 | virtual operator orxonox::Element() const; |
---|
[869] | 109 | virtual operator orxonox::Vector2() const; |
---|
| 110 | virtual operator orxonox::Vector3() const; |
---|
| 111 | virtual operator orxonox::ColourValue() const; |
---|
| 112 | virtual operator orxonox::Quaternion() const; |
---|
| 113 | virtual operator orxonox::Radian() const; |
---|
| 114 | virtual operator orxonox::Degree() const; |
---|
[834] | 115 | |
---|
[794] | 116 | using MultiTypeString::setValue; |
---|
[792] | 117 | inline void setValue(const orxonox::Vector2& value) { this->type_ = MT_vector2; this->vector2_ = value; } |
---|
[854] | 118 | inline void setValue(const orxonox::Vector3& value) { this->type_ = MT_vector3; this->vector3_ = value; } |
---|
[792] | 119 | inline void setValue(const orxonox::ColourValue& value) { this->type_ = MT_colourvalue; this->colourvalue_ = value; } |
---|
| 120 | inline void setValue(const orxonox::Quaternion& value) { this->type_ = MT_quaternion; this->quaternion_ = value; } |
---|
| 121 | inline void setValue(const orxonox::Radian& value) { this->type_ = MT_radian; this->radian_ = value; } |
---|
| 122 | inline void setValue(const orxonox::Degree& value) { this->type_ = MT_degree; this->degree_ = value; } |
---|
| 123 | void setValue(const MultiTypeMath& mtm); |
---|
| 124 | |
---|
[848] | 125 | inline orxonox::Vector2 getVector2() const { return this->vector2_; } |
---|
| 126 | inline orxonox::Vector3 getVector3() const { return this->vector3_; } |
---|
| 127 | inline orxonox::ColourValue getColourValue() const { return this->colourvalue_; } |
---|
| 128 | inline orxonox::Quaternion getQuaternion() const { return this->quaternion_; } |
---|
| 129 | inline orxonox::Radian getRadian() const { return this->radian_; } |
---|
| 130 | inline orxonox::Degree getDegree() const { return this->degree_; } |
---|
| 131 | |
---|
[792] | 132 | inline orxonox::Vector2& getVector2() { return this->vector2_; } |
---|
| 133 | inline orxonox::Vector3& getVector3() { return this->vector3_; } |
---|
| 134 | inline orxonox::ColourValue& getColourValue() { return this->colourvalue_; } |
---|
| 135 | inline orxonox::Quaternion& getQuaternion() { return this->quaternion_; } |
---|
| 136 | inline orxonox::Radian& getRadian() { return this->radian_; } |
---|
| 137 | inline orxonox::Degree& getDegree() { return this->degree_; } |
---|
| 138 | |
---|
[794] | 139 | using MultiTypeString::getValue; |
---|
[792] | 140 | inline void getValue(orxonox::Vector2* variable) const { (*variable) = orxonox::Vector2 (this->vector2_); } |
---|
| 141 | inline void getValue(orxonox::Vector3* variable) const { (*variable) = orxonox::Vector3 (this->vector3_); } |
---|
| 142 | inline void getValue(orxonox::ColourValue* variable) const { (*variable) = orxonox::ColourValue (this->colourvalue_); } |
---|
| 143 | inline void getValue(orxonox::Quaternion* variable) const { (*variable) = orxonox::Quaternion (this->quaternion_); } |
---|
| 144 | inline void getValue(orxonox::Radian* variable) const { (*variable) = orxonox::Radian (this->radian_); } |
---|
| 145 | inline void getValue(orxonox::Degree* variable) const { (*variable) = orxonox::Degree (this->degree_); } |
---|
| 146 | |
---|
[947] | 147 | virtual std::string getTypename() const; |
---|
| 148 | |
---|
[869] | 149 | virtual std::string toString() const; |
---|
| 150 | virtual bool fromString(const std::string value); |
---|
[848] | 151 | |
---|
[792] | 152 | protected: |
---|
| 153 | orxonox::Vector2 vector2_; |
---|
| 154 | orxonox::Vector3 vector3_; |
---|
| 155 | orxonox::ColourValue colourvalue_; |
---|
| 156 | orxonox::Quaternion quaternion_; |
---|
| 157 | orxonox::Radian radian_; |
---|
| 158 | orxonox::Degree degree_; |
---|
| 159 | }; |
---|
| 160 | |
---|
[797] | 161 | std::ostream& operator<<(std::ostream& out, MultiTypeMath& mtm); |
---|
| 162 | |
---|
[792] | 163 | #endif /* _MultiTypeMath_H__ */ |
---|