Changeset 1722 for code/branches/core3/src/util/MultiType.cc
- Timestamp:
- Sep 6, 2008, 7:34:49 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core3/src/util/MultiType.cc
r1720 r1722 87 87 std::string MultiType::getTypename() const 88 88 { 89 switch (this->type_) 89 MT_Type type = (this->value_) ? this->value_->type_ : MT_null; 90 91 switch (type) 90 92 { 91 93 case MT_char: … … 140 142 } 141 143 142 MultiType::operator char() const { return (this-> type_ == MT_char ) ? ((MT_Value<char> *)this->value_)->value_ : (this->value_) ? (*this->value_) : 0; }143 MultiType::operator unsigned char() const { return (this-> type_ == MT_uchar ) ? ((MT_Value<unsigned char> *)this->value_)->value_ : (this->value_) ? (*this->value_) : 0; }144 MultiType::operator short() const { return (this-> type_ == MT_short ) ? ((MT_Value<short> *)this->value_)->value_ : (this->value_) ? (*this->value_) : 0; }145 MultiType::operator unsigned short() const { return (this-> type_ == MT_ushort ) ? ((MT_Value<unsigned short> *)this->value_)->value_ : (this->value_) ? (*this->value_) : 0; }146 MultiType::operator int() const { return (this-> type_ == MT_int ) ? ((MT_Value<int> *)this->value_)->value_ : (this->value_) ? (*this->value_) : 0; }147 MultiType::operator unsigned int() const { return (this-> type_ == MT_uint ) ? ((MT_Value<unsigned int> *)this->value_)->value_ : (this->value_) ? (*this->value_) : 0; }148 MultiType::operator long() const { return (this-> type_ == MT_long ) ? ((MT_Value<long> *)this->value_)->value_ : (this->value_) ? (*this->value_) : 0; }149 MultiType::operator unsigned long() const { return (this-> type_ == MT_ulong ) ? ((MT_Value<unsigned long> *)this->value_)->value_ : (this->value_) ? (*this->value_) : 0; }150 MultiType::operator long long() const { return (this-> type_ == MT_longlong ) ? ((MT_Value<long long> *)this->value_)->value_ : (this->value_) ? (*this->value_) : 0; }151 MultiType::operator unsigned long long() const { return (this-> type_ == MT_ulonglong ) ? ((MT_Value<unsigned long long> *)this->value_)->value_ : (this->value_) ? (*this->value_) : 0; }152 MultiType::operator float() const { return (this-> type_ == MT_float ) ? ((MT_Value<float> *)this->value_)->value_ : (this->value_) ? (*this->value_) : 0; }153 MultiType::operator double() const { return (this-> type_ == MT_double ) ? ((MT_Value<double> *)this->value_)->value_ : (this->value_) ? (*this->value_) : 0; }154 MultiType::operator long double() const { return (this-> type_ == MT_longdouble ) ? ((MT_Value<long double> *)this->value_)->value_ : (this->value_) ? (*this->value_) : 0; }155 MultiType::operator bool() const { return (this-> type_ == MT_bool ) ? ((MT_Value<bool> *)this->value_)->value_ : (this->value_) ? (*this->value_) : false; }156 MultiType::operator void*() const { return (this-> type_ == MT_void ) ? ((MT_Value<void*> *)this->value_)->value_ : (this->value_) ? (*this->value_) : (void*)0; }157 MultiType::operator std::string() const { return (this-> type_ == MT_string ) ? ((MT_Value<std::string> *)this->value_)->value_ : (this->value_) ? (*this->value_) : std::string(); }158 MultiType::operator orxonox::Vector2() const { return (this-> type_ == MT_vector2 ) ? ((MT_Value<orxonox::Vector2> *)this->value_)->value_ : (this->value_) ? (*this->value_) : orxonox::Vector2(); }159 MultiType::operator orxonox::Vector3() const { return (this-> type_ == MT_vector3 ) ? ((MT_Value<orxonox::Vector3> *)this->value_)->value_ : (this->value_) ? (*this->value_) : orxonox::Vector3(); }160 MultiType::operator orxonox::Vector4() const { return (this-> type_ == MT_vector4 ) ? ((MT_Value<orxonox::Vector4> *)this->value_)->value_ : (this->value_) ? (*this->value_) : orxonox::Vector4(); }161 MultiType::operator orxonox::ColourValue() const { return (this-> type_ == MT_colourvalue) ? ((MT_Value<orxonox::ColourValue>*)this->value_)->value_ : (this->value_) ? (*this->value_) : orxonox::ColourValue(); }162 MultiType::operator orxonox::Quaternion() const { return (this-> type_ == MT_quaternion ) ? ((MT_Value<orxonox::Quaternion> *)this->value_)->value_ : (this->value_) ? (*this->value_) : orxonox::Quaternion(); }163 MultiType::operator orxonox::Radian() const { return (this-> type_ == MT_radian ) ? ((MT_Value<orxonox::Radian> *)this->value_)->value_ : (this->value_) ? (*this->value_) : orxonox::Radian(); }164 MultiType::operator orxonox::Degree() const { return (this-> type_ == MT_degree ) ? ((MT_Value<orxonox::Degree> *)this->value_)->value_ : (this->value_) ? (*this->value_) : orxonox::Degree(); }144 MultiType::operator char() const { return (this->value_) ? ((this->value_->type_ == MT_char ) ? ((MT_Value<char> *)this->value_)->value_ : (*this->value_)) : 0; } 145 MultiType::operator unsigned char() const { return (this->value_) ? ((this->value_->type_ == MT_uchar ) ? ((MT_Value<unsigned char> *)this->value_)->value_ : (*this->value_)) : 0; } 146 MultiType::operator short() const { return (this->value_) ? ((this->value_->type_ == MT_short ) ? ((MT_Value<short> *)this->value_)->value_ : (*this->value_)) : 0; } 147 MultiType::operator unsigned short() const { return (this->value_) ? ((this->value_->type_ == MT_ushort ) ? ((MT_Value<unsigned short> *)this->value_)->value_ : (*this->value_)) : 0; } 148 MultiType::operator int() const { return (this->value_) ? ((this->value_->type_ == MT_int ) ? ((MT_Value<int> *)this->value_)->value_ : (*this->value_)) : 0; } 149 MultiType::operator unsigned int() const { return (this->value_) ? ((this->value_->type_ == MT_uint ) ? ((MT_Value<unsigned int> *)this->value_)->value_ : (*this->value_)) : 0; } 150 MultiType::operator long() const { return (this->value_) ? ((this->value_->type_ == MT_long ) ? ((MT_Value<long> *)this->value_)->value_ : (*this->value_)) : 0; } 151 MultiType::operator unsigned long() const { return (this->value_) ? ((this->value_->type_ == MT_ulong ) ? ((MT_Value<unsigned long> *)this->value_)->value_ : (*this->value_)) : 0; } 152 MultiType::operator long long() const { return (this->value_) ? ((this->value_->type_ == MT_longlong ) ? ((MT_Value<long long> *)this->value_)->value_ : (*this->value_)) : 0; } 153 MultiType::operator unsigned long long() const { return (this->value_) ? ((this->value_->type_ == MT_ulonglong ) ? ((MT_Value<unsigned long long> *)this->value_)->value_ : (*this->value_)) : 0; } 154 MultiType::operator float() const { return (this->value_) ? ((this->value_->type_ == MT_float ) ? ((MT_Value<float> *)this->value_)->value_ : (*this->value_)) : 0; } 155 MultiType::operator double() const { return (this->value_) ? ((this->value_->type_ == MT_double ) ? ((MT_Value<double> *)this->value_)->value_ : (*this->value_)) : 0; } 156 MultiType::operator long double() const { return (this->value_) ? ((this->value_->type_ == MT_longdouble ) ? ((MT_Value<long double> *)this->value_)->value_ : (*this->value_)) : 0; } 157 MultiType::operator bool() const { return (this->value_) ? ((this->value_->type_ == MT_bool ) ? ((MT_Value<bool> *)this->value_)->value_ : (*this->value_)) : false; } 158 MultiType::operator void*() const { return (this->value_) ? ((this->value_->type_ == MT_void ) ? ((MT_Value<void*> *)this->value_)->value_ : (*this->value_)) : (void*)0; } 159 MultiType::operator std::string() const { return (this->value_) ? ((this->value_->type_ == MT_string ) ? ((MT_Value<std::string> *)this->value_)->value_ : (*this->value_)) : std::string(); } 160 MultiType::operator orxonox::Vector2() const { return (this->value_) ? ((this->value_->type_ == MT_vector2 ) ? ((MT_Value<orxonox::Vector2> *)this->value_)->value_ : (*this->value_)) : orxonox::Vector2(); } 161 MultiType::operator orxonox::Vector3() const { return (this->value_) ? ((this->value_->type_ == MT_vector3 ) ? ((MT_Value<orxonox::Vector3> *)this->value_)->value_ : (*this->value_)) : orxonox::Vector3(); } 162 MultiType::operator orxonox::Vector4() const { return (this->value_) ? ((this->value_->type_ == MT_vector4 ) ? ((MT_Value<orxonox::Vector4> *)this->value_)->value_ : (*this->value_)) : orxonox::Vector4(); } 163 MultiType::operator orxonox::ColourValue() const { return (this->value_) ? ((this->value_->type_ == MT_colourvalue) ? ((MT_Value<orxonox::ColourValue>*)this->value_)->value_ : (*this->value_)) : orxonox::ColourValue(); } 164 MultiType::operator orxonox::Quaternion() const { return (this->value_) ? ((this->value_->type_ == MT_quaternion ) ? ((MT_Value<orxonox::Quaternion> *)this->value_)->value_ : (*this->value_)) : orxonox::Quaternion(); } 165 MultiType::operator orxonox::Radian() const { return (this->value_) ? ((this->value_->type_ == MT_radian ) ? ((MT_Value<orxonox::Radian> *)this->value_)->value_ : (*this->value_)) : orxonox::Radian(); } 166 MultiType::operator orxonox::Degree() const { return (this->value_) ? ((this->value_->type_ == MT_degree ) ? ((MT_Value<orxonox::Degree> *)this->value_)->value_ : (*this->value_)) : orxonox::Degree(); } 165 167 166 template <> void MultiType::createNewValueContainer(const char& value) { this->value_ = new MT_Value<char> (value ); }167 template <> void MultiType::createNewValueContainer(const unsigned char& value) { this->value_ = new MT_Value<unsigned char> (value ); }168 template <> void MultiType::createNewValueContainer(const short& value) { this->value_ = new MT_Value<short> (value ); }169 template <> void MultiType::createNewValueContainer(const unsigned short& value) { this->value_ = new MT_Value<unsigned short> (value ); }170 template <> void MultiType::createNewValueContainer(const int& value) { this->value_ = new MT_Value<int> (value ); }171 template <> void MultiType::createNewValueContainer(const unsigned int& value) { this->value_ = new MT_Value<unsigned int> (value ); }172 template <> void MultiType::createNewValueContainer(const long& value) { this->value_ = new MT_Value<long> (value ); }173 template <> void MultiType::createNewValueContainer(const unsigned long& value) { this->value_ = new MT_Value<unsigned long> (value ); }174 template <> void MultiType::createNewValueContainer(const long long& value) { this->value_ = new MT_Value<long long> (value ); }175 template <> void MultiType::createNewValueContainer(const unsigned long long& value) { this->value_ = new MT_Value<unsigned long long> (value ); }176 template <> void MultiType::createNewValueContainer(const float& value) { this->value_ = new MT_Value<float> (value ); }177 template <> void MultiType::createNewValueContainer(const double& value) { this->value_ = new MT_Value<double> (value ); }178 template <> void MultiType::createNewValueContainer(const long double& value) { this->value_ = new MT_Value<long double> (value ); }179 template <> void MultiType::createNewValueContainer(const bool& value) { this->value_ = new MT_Value<bool> (value ); }180 template <> void MultiType::createNewValueContainer( void* const& value) { this->value_ = new MT_Value<void*> (value ); }181 template <> void MultiType::createNewValueContainer(const std::string& value) { this->value_ = new MT_Value<std::string> (value ); }182 template <> void MultiType::createNewValueContainer(const orxonox::Vector2& value) { this->value_ = new MT_Value<orxonox::Vector2> (value ); }183 template <> void MultiType::createNewValueContainer(const orxonox::Vector3& value) { this->value_ = new MT_Value<orxonox::Vector3> (value ); }184 template <> void MultiType::createNewValueContainer(const orxonox::Vector4& value) { this->value_ = new MT_Value<orxonox::Vector4> (value ); }185 template <> void MultiType::createNewValueContainer(const orxonox::ColourValue& value) { this->value_ = new MT_Value<orxonox::ColourValue>(value ); }186 template <> void MultiType::createNewValueContainer(const orxonox::Quaternion& value) { this->value_ = new MT_Value<orxonox::Quaternion> (value ); }187 template <> void MultiType::createNewValueContainer(const orxonox::Radian& value) { this->value_ = new MT_Value<orxonox::Radian> (value ); }188 template <> void MultiType::createNewValueContainer(const orxonox::Degree& value) { this->value_ = new MT_Value<orxonox::Degree> (value ); }168 template <> void MultiType::createNewValueContainer(const char& value) { this->value_ = new MT_Value<char> (value, MT_char ); } 169 template <> void MultiType::createNewValueContainer(const unsigned char& value) { this->value_ = new MT_Value<unsigned char> (value, MT_uchar ); } 170 template <> void MultiType::createNewValueContainer(const short& value) { this->value_ = new MT_Value<short> (value, MT_short ); } 171 template <> void MultiType::createNewValueContainer(const unsigned short& value) { this->value_ = new MT_Value<unsigned short> (value, MT_ushort ); } 172 template <> void MultiType::createNewValueContainer(const int& value) { this->value_ = new MT_Value<int> (value, MT_int ); } 173 template <> void MultiType::createNewValueContainer(const unsigned int& value) { this->value_ = new MT_Value<unsigned int> (value, MT_uint ); } 174 template <> void MultiType::createNewValueContainer(const long& value) { this->value_ = new MT_Value<long> (value, MT_long ); } 175 template <> void MultiType::createNewValueContainer(const unsigned long& value) { this->value_ = new MT_Value<unsigned long> (value, MT_ulong ); } 176 template <> void MultiType::createNewValueContainer(const long long& value) { this->value_ = new MT_Value<long long> (value, MT_longlong ); } 177 template <> void MultiType::createNewValueContainer(const unsigned long long& value) { this->value_ = new MT_Value<unsigned long long> (value, MT_ulonglong ); } 178 template <> void MultiType::createNewValueContainer(const float& value) { this->value_ = new MT_Value<float> (value, MT_float ); } 179 template <> void MultiType::createNewValueContainer(const double& value) { this->value_ = new MT_Value<double> (value, MT_double ); } 180 template <> void MultiType::createNewValueContainer(const long double& value) { this->value_ = new MT_Value<long double> (value, MT_longdouble ); } 181 template <> void MultiType::createNewValueContainer(const bool& value) { this->value_ = new MT_Value<bool> (value, MT_bool ); } 182 template <> void MultiType::createNewValueContainer( void* const& value) { this->value_ = new MT_Value<void*> (value, MT_void ); } 183 template <> void MultiType::createNewValueContainer(const std::string& value) { this->value_ = new MT_Value<std::string> (value, MT_string ); } 184 template <> void MultiType::createNewValueContainer(const orxonox::Vector2& value) { this->value_ = new MT_Value<orxonox::Vector2> (value, MT_vector2 ); } 185 template <> void MultiType::createNewValueContainer(const orxonox::Vector3& value) { this->value_ = new MT_Value<orxonox::Vector3> (value, MT_vector3 ); } 186 template <> void MultiType::createNewValueContainer(const orxonox::Vector4& value) { this->value_ = new MT_Value<orxonox::Vector4> (value, MT_vector4 ); } 187 template <> void MultiType::createNewValueContainer(const orxonox::ColourValue& value) { this->value_ = new MT_Value<orxonox::ColourValue>(value, MT_colourvalue); } 188 template <> void MultiType::createNewValueContainer(const orxonox::Quaternion& value) { this->value_ = new MT_Value<orxonox::Quaternion> (value, MT_quaternion ); } 189 template <> void MultiType::createNewValueContainer(const orxonox::Radian& value) { this->value_ = new MT_Value<orxonox::Radian> (value, MT_radian ); } 190 template <> void MultiType::createNewValueContainer(const orxonox::Degree& value) { this->value_ = new MT_Value<orxonox::Degree> (value, MT_degree ); }
Note: See TracChangeset
for help on using the changeset viewer.