[1716] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * > www.orxonox.net < |
---|
| 4 | * |
---|
| 5 | * |
---|
| 6 | * License notice: |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
| 9 | * modify it under the terms of the GNU General Public License |
---|
| 10 | * as published by the Free Software Foundation; either version 2 |
---|
| 11 | * of the License, or (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 21 | * |
---|
| 22 | * Author: |
---|
| 23 | * Fabian 'x3n' Landau |
---|
| 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | #ifndef _MultiTypeValue_H__ |
---|
| 30 | #define _MultiTypeValue_H__ |
---|
| 31 | |
---|
| 32 | #include "UtilPrereqs.h" |
---|
| 33 | #include "Convert.h" |
---|
[1718] | 34 | #include "MultiType.h" |
---|
[1716] | 35 | |
---|
| 36 | template <typename T> |
---|
| 37 | struct MT_Value : public MultiType::MT_ValueBase |
---|
| 38 | { |
---|
| 39 | MT_Value() {} |
---|
| 40 | MT_Value(const T& value) : value_(value) {} |
---|
| 41 | |
---|
| 42 | inline MT_ValueBase* clone() const { return new MT_Value<T>(this->value_); } |
---|
[1720] | 43 | |
---|
[1716] | 44 | inline void setValue(const char& value) { this->value_ = getConvertedValue<char, T>(value); } |
---|
| 45 | inline void setValue(const unsigned char& value) { this->value_ = getConvertedValue<unsigned char, T>(value); } |
---|
| 46 | inline void setValue(const short& value) { this->value_ = getConvertedValue<short, T>(value); } |
---|
| 47 | inline void setValue(const unsigned short& value) { this->value_ = getConvertedValue<unsigned short, T>(value); } |
---|
| 48 | inline void setValue(const int& value) { this->value_ = getConvertedValue<int, T>(value); } |
---|
| 49 | inline void setValue(const unsigned int& value) { this->value_ = getConvertedValue<unsigned int, T>(value); } |
---|
| 50 | inline void setValue(const long& value) { this->value_ = getConvertedValue<long, T>(value); } |
---|
| 51 | inline void setValue(const unsigned long& value) { this->value_ = getConvertedValue<unsigned long, T>(value); } |
---|
| 52 | inline void setValue(const long long& value) { this->value_ = getConvertedValue<long long, T>(value); } |
---|
| 53 | inline void setValue(const unsigned long long& value) { this->value_ = getConvertedValue<unsigned long long, T>(value); } |
---|
| 54 | inline void setValue(const float& value) { this->value_ = getConvertedValue<float, T>(value); } |
---|
| 55 | inline void setValue(const double& value) { this->value_ = getConvertedValue<double, T>(value); } |
---|
| 56 | inline void setValue(const long double& value) { this->value_ = getConvertedValue<long double, T>(value); } |
---|
| 57 | inline void setValue(const bool& value) { this->value_ = getConvertedValue<bool, T>(value); } |
---|
| 58 | inline void setValue( void* const& value) { this->value_ = getConvertedValue<void*, T>(value); } |
---|
| 59 | inline void setValue(const std::string& value) { this->value_ = getConvertedValue<std::string, T>(value); } |
---|
| 60 | inline void setValue(const orxonox::Vector2& value) { this->value_ = getConvertedValue<orxonox::Vector2, T>(value); } |
---|
| 61 | inline void setValue(const orxonox::Vector3& value) { this->value_ = getConvertedValue<orxonox::Vector3, T>(value); } |
---|
| 62 | inline void setValue(const orxonox::Vector4& value) { this->value_ = getConvertedValue<orxonox::Vector4, T>(value); } |
---|
| 63 | inline void setValue(const orxonox::ColourValue& value) { this->value_ = getConvertedValue<orxonox::ColourValue, T>(value); } |
---|
| 64 | inline void setValue(const orxonox::Quaternion& value) { this->value_ = getConvertedValue<orxonox::Quaternion, T>(value); } |
---|
| 65 | inline void setValue(const orxonox::Radian& value) { this->value_ = getConvertedValue<orxonox::Radian, T>(value); } |
---|
| 66 | inline void setValue(const orxonox::Degree& value) { this->value_ = getConvertedValue<orxonox::Degree, T>(value); } |
---|
| 67 | |
---|
| 68 | inline operator char() const { return getConvertedValue<T, char> (this->value_, 0); } |
---|
| 69 | inline operator unsigned char() const { return getConvertedValue<T, unsigned char> (this->value_, 0); } |
---|
| 70 | inline operator short() const { return getConvertedValue<T, short> (this->value_, 0); } |
---|
| 71 | inline operator unsigned short() const { return getConvertedValue<T, unsigned short> (this->value_, 0); } |
---|
| 72 | inline operator int() const { return getConvertedValue<T, int> (this->value_, 0); } |
---|
| 73 | inline operator unsigned int() const { return getConvertedValue<T, unsigned int> (this->value_, 0); } |
---|
| 74 | inline operator long() const { return getConvertedValue<T, long> (this->value_, 0); } |
---|
| 75 | inline operator unsigned long() const { return getConvertedValue<T, unsigned long> (this->value_, 0); } |
---|
| 76 | inline operator long long() const { return getConvertedValue<T, long long> (this->value_, 0); } |
---|
| 77 | inline operator unsigned long long() const { return getConvertedValue<T, unsigned long long> (this->value_, 0); } |
---|
| 78 | inline operator float() const { return getConvertedValue<T, float> (this->value_, 0); } |
---|
| 79 | inline operator double() const { return getConvertedValue<T, double> (this->value_, 0); } |
---|
| 80 | inline operator long double() const { return getConvertedValue<T, long double> (this->value_, 0); } |
---|
| 81 | inline operator bool() const { return getConvertedValue<T, bool> (this->value_, false); } |
---|
| 82 | inline operator void*() const { return getConvertedValue<T, void*> (this->value_, 0); } |
---|
| 83 | inline operator std::string() const { return getConvertedValue<T, std::string> (this->value_); } |
---|
| 84 | inline operator orxonox::Vector2() const { return getConvertedValue<T, orxonox::Vector2> (this->value_); } |
---|
| 85 | inline operator orxonox::Vector3() const { return getConvertedValue<T, orxonox::Vector3> (this->value_); } |
---|
| 86 | inline operator orxonox::Vector4() const { return getConvertedValue<T, orxonox::Vector4> (this->value_); } |
---|
| 87 | inline operator orxonox::ColourValue() const { return getConvertedValue<T, orxonox::ColourValue>(this->value_); } |
---|
| 88 | inline operator orxonox::Quaternion() const { return getConvertedValue<T, orxonox::Quaternion> (this->value_); } |
---|
| 89 | inline operator orxonox::Radian() const { return getConvertedValue<T, orxonox::Radian> (this->value_); } |
---|
| 90 | inline operator orxonox::Degree() const { return getConvertedValue<T, orxonox::Degree> (this->value_); } |
---|
| 91 | |
---|
| 92 | inline void toString(std::ostream& outstream) const { outstream << this->value_; } |
---|
| 93 | |
---|
| 94 | T value_; |
---|
| 95 | }; |
---|
| 96 | |
---|
| 97 | #endif /* _MultiTypeValue_H__ */ |
---|