Changeset 2002 for code/branches/objecthierarchy/src/util/MultiType.cc
- Timestamp:
- Oct 24, 2008, 12:37:54 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/util/MultiType.cc
r1791 r2002 39 39 @param type The type 40 40 */ 41 voidMultiType::convert(MT_Type type)41 bool MultiType::convert(MT_Type type) 42 42 { 43 43 switch (type) 44 44 { 45 45 case MT_char: 46 this->convert<char>(); break;46 return this->convert<char>(); break; 47 47 case MT_uchar: 48 this->convert<unsigned char>(); break;48 return this->convert<unsigned char>(); break; 49 49 case MT_short: 50 this->convert<short>(); break;50 return this->convert<short>(); break; 51 51 case MT_ushort: 52 this->convert<unsigned short>(); break;52 return this->convert<unsigned short>(); break; 53 53 case MT_int: 54 this->convert<int>(); break;54 return this->convert<int>(); break; 55 55 case MT_uint: 56 this->convert<unsigned int>(); break;56 return this->convert<unsigned int>(); break; 57 57 case MT_long: 58 this->convert<long>(); break;58 return this->convert<long>(); break; 59 59 case MT_ulong: 60 this->convert<unsigned long>(); break;60 return this->convert<unsigned long>(); break; 61 61 case MT_longlong: 62 this->convert<long long>(); break;62 return this->convert<long long>(); break; 63 63 case MT_ulonglong: 64 this->convert<unsigned long long>(); break;64 return this->convert<unsigned long long>(); break; 65 65 case MT_float: 66 this->convert<float>(); break;66 return this->convert<float>(); break; 67 67 case MT_double: 68 this->convert<double>(); break;68 return this->convert<double>(); break; 69 69 case MT_longdouble: 70 this->convert<long double>(); break;70 return this->convert<long double>(); break; 71 71 case MT_bool: 72 this->convert<bool>(); break;72 return this->convert<bool>(); break; 73 73 case MT_void: 74 this->convert<void*>(); break;74 return this->convert<void*>(); break; 75 75 case MT_string: 76 this->convert<std::string>(); break;76 return this->convert<std::string>(); break; 77 77 case MT_vector2: 78 this->convert<orxonox::Vector2>(); break;78 return this->convert<orxonox::Vector2>(); break; 79 79 case MT_vector3: 80 this->convert<orxonox::Vector3>(); break;80 return this->convert<orxonox::Vector3>(); break; 81 81 case MT_vector4: 82 this->convert<orxonox::Vector4>(); break;82 return this->convert<orxonox::Vector4>(); break; 83 83 case MT_colourvalue: 84 this->convert<orxonox::ColourValue>(); break;84 return this->convert<orxonox::ColourValue>(); break; 85 85 case MT_quaternion: 86 this->convert<orxonox::Quaternion>(); break;86 return this->convert<orxonox::Quaternion>(); break; 87 87 case MT_radian: 88 this->convert<orxonox::Radian>(); break;88 return this->convert<orxonox::Radian>(); break; 89 89 case MT_degree: 90 this->convert<orxonox::Degree>(); break;90 return this->convert<orxonox::Degree>(); break; 91 91 default: 92 this->reset(); break;92 this->reset(); return false; break; 93 93 }; 94 94 } … … 168 168 MultiType::operator double() const { return (this->value_) ? ((this->value_->type_ == MT_double ) ? ((MT_Value<double> *)this->value_)->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */ 169 169 MultiType::operator long double() const { return (this->value_) ? ((this->value_->type_ == MT_longdouble ) ? ((MT_Value<long double> *)this->value_)->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */ 170 MultiType::operator bool() const { return (this->value_) ? ((this->value_->type_ == MT_bool ) ? ((MT_Value<bool> *)this->value_)->value_ : (*this->value_)) : false;} /** @brief Returns the current value, converted to the requested type. */171 MultiType::operator void*() const { return (this->value_) ? ((this->value_->type_ == MT_void ) ? ((MT_Value<void*> *)this->value_)->value_ : (*this->value_)) : (void*)0;} /** @brief Returns the current value, converted to the requested type. */172 MultiType::operator std::string() const { return (this->value_) ? ((this->value_->type_ == MT_string ) ? ((MT_Value<std::string> *)this->value_)->value_ : (*this->value_)) : std::string(); } /** @brief Returns the current value, converted to the requested type. */173 MultiType::operator orxonox::Vector2() const { return (this->value_) ? ((this->value_->type_ == MT_vector2 ) ? ((MT_Value<orxonox::Vector2> *)this->value_)->value_ : (*this->value_)) : orxonox::Vector2(); } /** @brief Returns the current value, converted to the requested type. */174 MultiType::operator orxonox::Vector3() const { return (this->value_) ? ((this->value_->type_ == MT_vector3 ) ? ((MT_Value<orxonox::Vector3> *)this->value_)->value_ : (*this->value_)) : orxonox::Vector3(); } /** @brief Returns the current value, converted to the requested type. */175 MultiType::operator orxonox::Vector4() const { return (this->value_) ? ((this->value_->type_ == MT_vector4 ) ? ((MT_Value<orxonox::Vector4> *)this->value_)->value_ : (*this->value_)) : orxonox::Vector4(); } /** @brief Returns the current value, converted to the requested type. */176 MultiType::operator orxonox::ColourValue() const { return (this->value_) ? ((this->value_->type_ == MT_colourvalue) ? ((MT_Value<orxonox::ColourValue>*)this->value_)->value_ : (*this->value_)) : orxonox::ColourValue(); } /** @brief Returns the current value, converted to the requested type. */177 MultiType::operator orxonox::Quaternion() const { return (this->value_) ? ((this->value_->type_ == MT_quaternion ) ? ((MT_Value<orxonox::Quaternion> *)this->value_)->value_ : (*this->value_)) : orxonox::Quaternion(); } /** @brief Returns the current value, converted to the requested type. */178 MultiType::operator orxonox::Radian() const { return (this->value_) ? ((this->value_->type_ == MT_radian ) ? ((MT_Value<orxonox::Radian> *)this->value_)->value_ : (*this->value_)) : orxonox::Radian(); } /** @brief Returns the current value, converted to the requested type. */179 MultiType::operator orxonox::Degree() const { return (this->value_) ? ((this->value_->type_ == MT_degree ) ? ((MT_Value<orxonox::Degree> *)this->value_)->value_ : (*this->value_)) : orxonox::Degree(); } /** @brief Returns the current value, converted to the requested type. */170 MultiType::operator bool() const { return (this->value_) ? ((this->value_->type_ == MT_bool ) ? ((MT_Value<bool> *)this->value_)->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */ 171 MultiType::operator void*() const { return (this->value_) ? ((this->value_->type_ == MT_void ) ? ((MT_Value<void*> *)this->value_)->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */ 172 MultiType::operator std::string() const { return (this->value_) ? ((this->value_->type_ == MT_string ) ? ((MT_Value<std::string> *)this->value_)->value_ : (*this->value_)) : zeroise<std::string>(); } /** @brief Returns the current value, converted to the requested type. */ 173 MultiType::operator orxonox::Vector2() const { return (this->value_) ? ((this->value_->type_ == MT_vector2 ) ? ((MT_Value<orxonox::Vector2> *)this->value_)->value_ : (*this->value_)) : zeroise<orxonox::Vector2>(); } /** @brief Returns the current value, converted to the requested type. */ 174 MultiType::operator orxonox::Vector3() const { return (this->value_) ? ((this->value_->type_ == MT_vector3 ) ? ((MT_Value<orxonox::Vector3> *)this->value_)->value_ : (*this->value_)) : zeroise<orxonox::Vector3>(); } /** @brief Returns the current value, converted to the requested type. */ 175 MultiType::operator orxonox::Vector4() const { return (this->value_) ? ((this->value_->type_ == MT_vector4 ) ? ((MT_Value<orxonox::Vector4> *)this->value_)->value_ : (*this->value_)) : zeroise<orxonox::Vector4>(); } /** @brief Returns the current value, converted to the requested type. */ 176 MultiType::operator orxonox::ColourValue() const { return (this->value_) ? ((this->value_->type_ == MT_colourvalue) ? ((MT_Value<orxonox::ColourValue>*)this->value_)->value_ : (*this->value_)) : zeroise<orxonox::ColourValue>(); } /** @brief Returns the current value, converted to the requested type. */ 177 MultiType::operator orxonox::Quaternion() const { return (this->value_) ? ((this->value_->type_ == MT_quaternion ) ? ((MT_Value<orxonox::Quaternion> *)this->value_)->value_ : (*this->value_)) : zeroise<orxonox::Quaternion>(); } /** @brief Returns the current value, converted to the requested type. */ 178 MultiType::operator orxonox::Radian() const { return (this->value_) ? ((this->value_->type_ == MT_radian ) ? ((MT_Value<orxonox::Radian> *)this->value_)->value_ : (*this->value_)) : zeroise<orxonox::Radian>(); } /** @brief Returns the current value, converted to the requested type. */ 179 MultiType::operator orxonox::Degree() const { return (this->value_) ? ((this->value_->type_ == MT_degree ) ? ((MT_Value<orxonox::Degree> *)this->value_)->value_ : (*this->value_)) : zeroise<orxonox::Degree>(); } /** @brief Returns the current value, converted to the requested type. */ 180 180 181 181 template <> void MultiType::createNewValueContainer(const char& value) { this->value_ = new MT_Value<char> (value, MT_char ); } /** @brief Creates a new value container for the given type. */
Note: See TracChangeset
for help on using the changeset viewer.