Changeset 2087 for code/trunk/src/util/MultiType.h
- Timestamp:
- Nov 1, 2008, 7:04:09 PM (17 years ago)
- Location:
- code/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/util
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
/code/branches/ceguilua/src/util merged eligible /code/branches/script_trigger/src/util merged eligible /code/branches/core3/src/util 1572-1739,1742-2014 /code/branches/gcc43/src/util 1580 /code/branches/gui/src/util 1635-1723 /code/branches/input/src/util 1629-1636
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
-
code/trunk/src/util/MultiType.h
r1854 r2087 58 58 a.convert<bool>(); // converts 3.14 to bool, which is true 59 59 a = false; // assigns false, this is equivalent to a.setValue(false) 60 61 @note 62 Whenever a value gets converted, there is a boolean return value telling you whether it was 63 successful or not. If it wasn't a zero value is assigned with the help of zeroise<T>(). 60 64 */ 61 65 … … 128 132 struct _UtilExport MT_ValueBase 129 133 { 130 MT_ValueBase(MT_Type type) : type_(type) {}134 MT_ValueBase(MT_Type type) : type_(type), bHasDefaultValue_(false) {} 131 135 virtual ~MT_ValueBase() {} 132 136 … … 134 138 135 139 virtual void reset() = 0; 136 virtual voidassimilate(const MultiType& other) = 0;140 virtual bool assimilate(const MultiType& other) = 0; 137 141 138 142 /** @brief Returns the type of the current value. */ 139 143 const MT_Type& getType() const { return this->type_; } 140 144 141 virtual void setValue(const char& value) = 0; 142 virtual void setValue(const unsigned char& value) = 0; 143 virtual void setValue(const short& value) = 0; 144 virtual void setValue(const unsigned short& value) = 0; 145 virtual void setValue(const int& value) = 0; 146 virtual void setValue(const unsigned int& value) = 0; 147 virtual void setValue(const long& value) = 0; 148 virtual void setValue(const unsigned long& value) = 0; 149 virtual void setValue(const long long& value) = 0; 150 virtual void setValue(const unsigned long long& value) = 0; 151 virtual void setValue(const float& value) = 0; 152 virtual void setValue(const double& value) = 0; 153 virtual void setValue(const long double& value) = 0; 154 virtual void setValue(const bool& value) = 0; 155 virtual void setValue( void* const& value) = 0; 156 virtual void setValue(const std::string& value) = 0; 157 virtual void setValue(const orxonox::Vector2& value) = 0; 158 virtual void setValue(const orxonox::Vector3& value) = 0; 159 virtual void setValue(const orxonox::Vector4& value) = 0; 160 virtual void setValue(const orxonox::ColourValue& value) = 0; 161 virtual void setValue(const orxonox::Quaternion& value) = 0; 162 virtual void setValue(const orxonox::Radian& value) = 0; 163 virtual void setValue(const orxonox::Degree& value) = 0; 145 /** @brief Checks whether the value is a default one. */ 146 bool hasDefaultValue() const { return this->bHasDefaultValue_; } 147 148 virtual bool setValue(const char& value) = 0; 149 virtual bool setValue(const unsigned char& value) = 0; 150 virtual bool setValue(const short& value) = 0; 151 virtual bool setValue(const unsigned short& value) = 0; 152 virtual bool setValue(const int& value) = 0; 153 virtual bool setValue(const unsigned int& value) = 0; 154 virtual bool setValue(const long& value) = 0; 155 virtual bool setValue(const unsigned long& value) = 0; 156 virtual bool setValue(const long long& value) = 0; 157 virtual bool setValue(const unsigned long long& value) = 0; 158 virtual bool setValue(const float& value) = 0; 159 virtual bool setValue(const double& value) = 0; 160 virtual bool setValue(const long double& value) = 0; 161 virtual bool setValue(const bool& value) = 0; 162 virtual bool setValue( void* const& value) = 0; 163 virtual bool setValue(const std::string& value) = 0; 164 virtual bool setValue(const orxonox::Vector2& value) = 0; 165 virtual bool setValue(const orxonox::Vector3& value) = 0; 166 virtual bool setValue(const orxonox::Vector4& value) = 0; 167 virtual bool setValue(const orxonox::ColourValue& value) = 0; 168 virtual bool setValue(const orxonox::Quaternion& value) = 0; 169 virtual bool setValue(const orxonox::Radian& value) = 0; 170 virtual bool setValue(const orxonox::Degree& value) = 0; 171 172 virtual bool getValue(char* value) const = 0; 173 virtual bool getValue(unsigned char* value) const = 0; 174 virtual bool getValue(short* value) const = 0; 175 virtual bool getValue(unsigned short* value) const = 0; 176 virtual bool getValue(int* value) const = 0; 177 virtual bool getValue(unsigned int* value) const = 0; 178 virtual bool getValue(long* value) const = 0; 179 virtual bool getValue(unsigned long* value) const = 0; 180 virtual bool getValue(long long* value) const = 0; 181 virtual bool getValue(unsigned long long* value) const = 0; 182 virtual bool getValue(float* value) const = 0; 183 virtual bool getValue(double* value) const = 0; 184 virtual bool getValue(long double* value) const = 0; 185 virtual bool getValue(bool* value) const = 0; 186 virtual bool getValue(void** value) const = 0; 187 virtual bool getValue(std::string* value) const = 0; 188 virtual bool getValue(orxonox::Vector2* value) const = 0; 189 virtual bool getValue(orxonox::Vector3* value) const = 0; 190 virtual bool getValue(orxonox::Vector4* value) const = 0; 191 virtual bool getValue(orxonox::ColourValue* value) const = 0; 192 virtual bool getValue(orxonox::Quaternion* value) const = 0; 193 virtual bool getValue(orxonox::Radian* value) const = 0; 194 virtual bool getValue(orxonox::Degree* value) const = 0; 164 195 165 196 virtual operator char() const = 0; … … 189 220 virtual void toString(std::ostream& outstream) const = 0; 190 221 191 MT_Type type_; //!< The type of the current value 222 MT_Type type_; //!< The type of the current value 223 bool bHasDefaultValue_; //!< True if the last conversion wasn't successful 192 224 }; 193 225 … … 229 261 inline const MultiType& operator=(MT_Type type) { this->setType(type); return (*this); } /** @brief Resets the value and changes the type. */ 230 262 231 inline voidsetValue(const char& value);232 inline voidsetValue(const unsigned char& value);233 inline voidsetValue(const short& value);234 inline voidsetValue(const unsigned short& value);235 inline voidsetValue(const int& value);236 inline voidsetValue(const unsigned int& value);237 inline voidsetValue(const long& value);238 inline voidsetValue(const unsigned long& value);239 inline voidsetValue(const long long& value);240 inline voidsetValue(const unsigned long long& value);241 inline voidsetValue(const float& value);242 inline voidsetValue(const double& value);243 inline voidsetValue(const long double& value);244 inline voidsetValue(const bool& value);245 inline voidsetValue( void* const& value);246 inline voidsetValue(const std::string& value);247 inline voidsetValue(const orxonox::Vector2& value);248 inline voidsetValue(const orxonox::Vector3& value);249 inline voidsetValue(const orxonox::Vector4& value);250 inline voidsetValue(const orxonox::ColourValue& value);251 inline voidsetValue(const orxonox::Quaternion& value);252 inline voidsetValue(const orxonox::Radian& value);253 inline voidsetValue(const orxonox::Degree& value);254 inline voidsetValue(const char* value);263 inline bool setValue(const char& value); 264 inline bool setValue(const unsigned char& value); 265 inline bool setValue(const short& value); 266 inline bool setValue(const unsigned short& value); 267 inline bool setValue(const int& value); 268 inline bool setValue(const unsigned int& value); 269 inline bool setValue(const long& value); 270 inline bool setValue(const unsigned long& value); 271 inline bool setValue(const long long& value); 272 inline bool setValue(const unsigned long long& value); 273 inline bool setValue(const float& value); 274 inline bool setValue(const double& value); 275 inline bool setValue(const long double& value); 276 inline bool setValue(const bool& value); 277 inline bool setValue( void* const& value); 278 inline bool setValue(const std::string& value); 279 inline bool setValue(const orxonox::Vector2& value); 280 inline bool setValue(const orxonox::Vector3& value); 281 inline bool setValue(const orxonox::Vector4& value); 282 inline bool setValue(const orxonox::ColourValue& value); 283 inline bool setValue(const orxonox::Quaternion& value); 284 inline bool setValue(const orxonox::Radian& value); 285 inline bool setValue(const orxonox::Degree& value); 286 inline bool setValue(const char* value); 255 287 /** @brief Assigns a pointer. */ 256 template <typename V> inline void setValue(V* value) { if (this->value_) { this->value_->setValue((void*)value); } else {this->assignValue((void*)value); } }288 template <typename V> inline bool setValue(V* value) { if (this->value_) { return this->value_->setValue((void*)value); } else { return this->assignValue((void*)value); } } 257 289 /** @brief Assigns the value of the other MultiType and converts it to the current type. */ 258 void setValue(const MultiType& other) { if (this->value_) { this->value_->assimilate(other); } else { if (other.value_) { this->value_ = other.value_->clone(); }} }290 bool setValue(const MultiType& other) { if (this->value_) { return this->value_->assimilate(other); } else { if (other.value_) { this->value_ = other.value_->clone(); } return true; } } 259 291 /** @brief Changes the type to T and assigns the new value (which might be of another type than T - it gets converted). */ 260 template <typename T, typename V> inline void setValue(const V& value) { this->setType<T>();this->setValue(value); }292 template <typename T, typename V> inline bool setValue(const V& value) { this->setType<T>(); return this->setValue(value); } 261 293 262 294 … … 264 296 inline void copy(const MultiType& other) { if (this == &other) { return; } if (this->value_) { delete this->value_; } this->value_ = (other.value_) ? other.value_->clone() : 0; } 265 297 266 template <typename T> inline void convert() {this->setValue<T>((T)(*this)); } /** @brief Converts the current value to type T. */267 inline void convert(const MultiType& other) {this->convert(other.getType()); } /** @brief Converts the current value to the type of the other MultiType. */268 voidconvert(MT_Type type);269 270 /** @brief Resets the value to the defaultvalue of the current type.*/271 inline void reset() { if (this->value_) { delete this->value_; this->value_ = 0; }}298 template <typename T> inline bool convert() { return this->setValue<T>((T)(*this)); } /** @brief Converts the current value to type T. */ 299 inline bool convert(const MultiType& other) { return this->convert(other.getType()); } /** @brief Converts the current value to the type of the other MultiType. */ 300 bool convert(MT_Type type); 301 302 /** @brief Current content gets deleted. New type is MT_null */ 303 inline void reset() { if (this->value_) this->value_->reset(); } 272 304 273 305 template <typename T> inline void setType() { this->assignValue(T()); } /** @brief Resets the value and changes the internal type to T. */ … … 282 314 template <typename T> inline bool isType() const { return false; } // Only works for specialized values - see below 283 315 std::string getTypename() const; 316 317 /** @brief Checks whether the value is a default one. */ 318 bool hasDefaultValue() const { return this->value_->hasDefaultValue(); } 284 319 285 320 operator char() const; … … 309 344 template <class T> operator T*() const { return ((T*)this->operator void*()); } 310 345 311 inline void getValue(char* value) const { if (this->value_) { (*value) = (*this->value_); }} /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */312 inline void getValue(unsigned char* value) const { if (this->value_) { (*value) = (*this->value_); }} /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */313 inline void getValue(short* value) const { if (this->value_) { (*value) = (*this->value_); }} /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */314 inline void getValue(unsigned short* value) const { if (this->value_) { (*value) = (*this->value_); }} /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */315 inline void getValue(int* value) const { if (this->value_) { (*value) = (*this->value_); }} /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */316 inline void getValue(unsigned int* value) const { if (this->value_) { (*value) = (*this->value_); }} /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */317 inline void getValue(long* value) const { if (this->value_) { (*value) = (*this->value_); }} /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */318 inline void getValue(unsigned long* value) const { if (this->value_) { (*value) = (*this->value_); }} /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */319 inline void getValue(long long* value) const { if (this->value_) { (*value) = (*this->value_); }} /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */320 inline void getValue(unsigned long long* value) const { if (this->value_) { (*value) = (*this->value_); }} /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */321 inline void getValue(float* value) const { if (this->value_) { (*value) = (*this->value_); }} /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */322 inline void getValue(double* value) const { if (this->value_) { (*value) = (*this->value_); }} /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */323 inline void getValue(long double* value) const { if (this->value_) { (*value) = (*this->value_); }} /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */324 inline void getValue(bool* value) const { if (this->value_) { (*value) = (*this->value_); }} /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */325 inline void getValue(void* value) const { if (this->value_) { value = (*this->value_); }} /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */326 inline void getValue(std::string* value) const { if (this->value_) { (*value) = this->value_->operator std::string(); }} /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */327 inline void getValue(orxonox::Vector2* value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Vector2(); }} /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */328 inline void getValue(orxonox::Vector3* value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Vector3(); }} /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */329 inline void getValue(orxonox::Vector4* value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Vector4(); }} /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */330 inline void getValue(orxonox::ColourValue* value) const { if (this->value_) { (*value) = this->value_->operator orxonox::ColourValue(); }} /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */331 inline void getValue(orxonox::Quaternion* value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Quaternion(); }} /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */332 inline void getValue(orxonox::Radian* value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Radian(); }} /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */333 inline void getValue(orxonox::Degree* value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Degree(); }} /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */346 inline bool getValue(char* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 347 inline bool getValue(unsigned char* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 348 inline bool getValue(short* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 349 inline bool getValue(unsigned short* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 350 inline bool getValue(int* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 351 inline bool getValue(unsigned int* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 352 inline bool getValue(long* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 353 inline bool getValue(unsigned long* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 354 inline bool getValue(long long* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 355 inline bool getValue(unsigned long long* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 356 inline bool getValue(float* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 357 inline bool getValue(double* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 358 inline bool getValue(long double* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 359 inline bool getValue(bool* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 360 inline bool getValue(void** value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 361 inline bool getValue(std::string* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 362 inline bool getValue(orxonox::Vector2* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 363 inline bool getValue(orxonox::Vector3* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 364 inline bool getValue(orxonox::Vector4* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 365 inline bool getValue(orxonox::ColourValue* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 366 inline bool getValue(orxonox::Quaternion* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 367 inline bool getValue(orxonox::Radian* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 368 inline bool getValue(orxonox::Degree* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */ 334 369 335 370 inline char getChar() const { return this->operator char(); } /** @brief Returns the current value, converted to the requested type. */ … … 359 394 360 395 private: 361 inline void assignValue(const char& value) { if (this->value_ && this->value_->type_ == MT_char) { this->value_->setValue(value); } else { this->changeValueContainer<char>(value);} } /** @brief Assigns a new value by changing type and creating a new container. */362 inline void assignValue(const unsigned char& value) { if (this->value_ && this->value_->type_ == MT_uchar) { this->value_->setValue(value); } else { this->changeValueContainer<unsigned char>(value);} } /** @brief Assigns a new value by changing type and creating a new container. */363 inline void assignValue(const short& value) { if (this->value_ && this->value_->type_ == MT_short) { this->value_->setValue(value); } else { this->changeValueContainer<short>(value);} } /** @brief Assigns a new value by changing type and creating a new container. */364 inline void assignValue(const unsigned short& value) { if (this->value_ && this->value_->type_ == MT_ushort) { this->value_->setValue(value); } else { this->changeValueContainer<unsigned short>(value);} } /** @brief Assigns a new value by changing type and creating a new container. */365 inline void assignValue(const int& value) { if (this->value_ && this->value_->type_ == MT_int) { this->value_->setValue(value); } else { this->changeValueContainer<int>(value);} } /** @brief Assigns a new value by changing type and creating a new container. */366 inline void assignValue(const unsigned int& value) { if (this->value_ && this->value_->type_ == MT_uint) { this->value_->setValue(value); } else { this->changeValueContainer<unsigned int>(value);} } /** @brief Assigns a new value by changing type and creating a new container. */367 inline void assignValue(const long& value) { if (this->value_ && this->value_->type_ == MT_long) { this->value_->setValue(value); } else { this->changeValueContainer<long>(value);} } /** @brief Assigns a new value by changing type and creating a new container. */368 inline void assignValue(const unsigned long& value) { if (this->value_ && this->value_->type_ == MT_ulong) { this->value_->setValue(value); } else { this->changeValueContainer<unsigned long>(value);} } /** @brief Assigns a new value by changing type and creating a new container. */369 inline void assignValue(const long long& value) { if (this->value_ && this->value_->type_ == MT_longlong) { this->value_->setValue(value); } else { this->changeValueContainer<long long>(value);} } /** @brief Assigns a new value by changing type and creating a new container. */370 inline void assignValue(const unsigned long long& value) { if (this->value_ && this->value_->type_ == MT_ulonglong) { this->value_->setValue(value); } else { this->changeValueContainer<unsigned long long>(value);} } /** @brief Assigns a new value by changing type and creating a new container. */371 inline void assignValue(const float& value) { if (this->value_ && this->value_->type_ == MT_float) { this->value_->setValue(value); } else { this->changeValueContainer<float>(value);} } /** @brief Assigns a new value by changing type and creating a new container. */372 inline void assignValue(const double& value) { if (this->value_ && this->value_->type_ == MT_double) { this->value_->setValue(value); } else { this->changeValueContainer<double>(value);} } /** @brief Assigns a new value by changing type and creating a new container. */373 inline void assignValue(const long double& value) { if (this->value_ && this->value_->type_ == MT_longdouble) { this->value_->setValue(value); } else { this->changeValueContainer<long double>(value);} } /** @brief Assigns a new value by changing type and creating a new container. */374 inline void assignValue(const bool& value) { if (this->value_ && this->value_->type_ == MT_bool) { this->value_->setValue(value); } else { this->changeValueContainer<bool>(value);} } /** @brief Assigns a new value by changing type and creating a new container. */375 inline void assignValue( void* const& value) { if (this->value_ && this->value_->type_ == MT_void) { this->value_->setValue(value); } else { this->changeValueContainer<void*>(value);} } /** @brief Assigns a new value by changing type and creating a new container. */376 inline void assignValue(const std::string& value) { if (this->value_ && this->value_->type_ == MT_string) { this->value_->setValue(value); } else { this->changeValueContainer<std::string>(value);} } /** @brief Assigns a new value by changing type and creating a new container. */377 inline void assignValue(const orxonox::Vector2& value) { if (this->value_ && this->value_->type_ == MT_vector2) { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector2>(value);} } /** @brief Assigns a new value by changing type and creating a new container. */378 inline void assignValue(const orxonox::Vector3& value) { if (this->value_ && this->value_->type_ == MT_vector3) { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector3>(value);} } /** @brief Assigns a new value by changing type and creating a new container. */379 inline void assignValue(const orxonox::Vector4& value) { if (this->value_ && this->value_->type_ == MT_vector4) { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector4>(value);} } /** @brief Assigns a new value by changing type and creating a new container. */380 inline void assignValue(const orxonox::ColourValue& value) { if (this->value_ && this->value_->type_ == MT_colourvalue) { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::ColourValue>(value); } } /** @brief Assigns a new value by changing type and creating a new container. */381 inline void assignValue(const orxonox::Quaternion& value) { if (this->value_ && this->value_->type_ == MT_quaternion) { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Quaternion>(value);} } /** @brief Assigns a new value by changing type and creating a new container. */382 inline void assignValue(const orxonox::Radian& value) { if (this->value_ && this->value_->type_ == MT_radian) { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Radian>(value);} } /** @brief Assigns a new value by changing type and creating a new container. */383 inline void assignValue(const orxonox::Degree& value) { if (this->value_ && this->value_->type_ == MT_degree) { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Degree>(value);} } /** @brief Assigns a new value by changing type and creating a new container. */396 inline bool assignValue(const char& value) { if (this->value_ && this->value_->type_ == MT_char) { return this->value_->setValue(value); } else { this->changeValueContainer<char>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ 397 inline bool assignValue(const unsigned char& value) { if (this->value_ && this->value_->type_ == MT_uchar) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned char>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ 398 inline bool assignValue(const short& value) { if (this->value_ && this->value_->type_ == MT_short) { return this->value_->setValue(value); } else { this->changeValueContainer<short>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ 399 inline bool assignValue(const unsigned short& value) { if (this->value_ && this->value_->type_ == MT_ushort) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned short>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ 400 inline bool assignValue(const int& value) { if (this->value_ && this->value_->type_ == MT_int) { return this->value_->setValue(value); } else { this->changeValueContainer<int>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ 401 inline bool assignValue(const unsigned int& value) { if (this->value_ && this->value_->type_ == MT_uint) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned int>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ 402 inline bool assignValue(const long& value) { if (this->value_ && this->value_->type_ == MT_long) { return this->value_->setValue(value); } else { this->changeValueContainer<long>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ 403 inline bool assignValue(const unsigned long& value) { if (this->value_ && this->value_->type_ == MT_ulong) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned long>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ 404 inline bool assignValue(const long long& value) { if (this->value_ && this->value_->type_ == MT_longlong) { return this->value_->setValue(value); } else { this->changeValueContainer<long long>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ 405 inline bool assignValue(const unsigned long long& value) { if (this->value_ && this->value_->type_ == MT_ulonglong) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned long long>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ 406 inline bool assignValue(const float& value) { if (this->value_ && this->value_->type_ == MT_float) { return this->value_->setValue(value); } else { this->changeValueContainer<float>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ 407 inline bool assignValue(const double& value) { if (this->value_ && this->value_->type_ == MT_double) { return this->value_->setValue(value); } else { this->changeValueContainer<double>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ 408 inline bool assignValue(const long double& value) { if (this->value_ && this->value_->type_ == MT_longdouble) { return this->value_->setValue(value); } else { this->changeValueContainer<long double>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ 409 inline bool assignValue(const bool& value) { if (this->value_ && this->value_->type_ == MT_bool) { return this->value_->setValue(value); } else { this->changeValueContainer<bool>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ 410 inline bool assignValue( void* const& value) { if (this->value_ && this->value_->type_ == MT_void) { return this->value_->setValue(value); } else { this->changeValueContainer<void*>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ 411 inline bool assignValue(const std::string& value) { if (this->value_ && this->value_->type_ == MT_string) { return this->value_->setValue(value); } else { this->changeValueContainer<std::string>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ 412 inline bool assignValue(const orxonox::Vector2& value) { if (this->value_ && this->value_->type_ == MT_vector2) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector2>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ 413 inline bool assignValue(const orxonox::Vector3& value) { if (this->value_ && this->value_->type_ == MT_vector3) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector3>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ 414 inline bool assignValue(const orxonox::Vector4& value) { if (this->value_ && this->value_->type_ == MT_vector4) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector4>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ 415 inline bool assignValue(const orxonox::ColourValue& value) { if (this->value_ && this->value_->type_ == MT_colourvalue) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::ColourValue>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ 416 inline bool assignValue(const orxonox::Quaternion& value) { if (this->value_ && this->value_->type_ == MT_quaternion) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Quaternion>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ 417 inline bool assignValue(const orxonox::Radian& value) { if (this->value_ && this->value_->type_ == MT_radian) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Radian>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ 418 inline bool assignValue(const orxonox::Degree& value) { if (this->value_ && this->value_->type_ == MT_degree) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Degree>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */ 384 419 385 420 /** @brief Changes the value container. */ 386 421 template <typename T> inline void changeValueContainer(const T& value) { if (this->value_) { delete this->value_; } this->createNewValueContainer<T>(value); } 387 422 /** @brief Creates a new value container (works only with specialized types). */ 388 template <typename T> void createNewValueContainer(const T& value) { BOOST_STATIC_ASSERT(sizeof(T) == 0); }423 template <typename T> void createNewValueContainer(const T& value) { BOOST_STATIC_ASSERT(sizeof(T) == 0); return false; } 389 424 390 425 MT_ValueBase* value_; //!< A pointer to the value container … … 419 454 420 455 // Specialization to avoid ambiguities with the conversion operator 421 template <> inline void MultiType::convert<std::string>() {this->setValue<std::string> (this->operator std::string()); } /** @brief Converts the current value to the given type. */422 template <> inline void MultiType::convert<orxonox::Vector2>() {this->setValue<orxonox::Vector2> (this->operator orxonox::Vector2()); } /** @brief Converts the current value to the given type. */423 template <> inline void MultiType::convert<orxonox::Vector3>() {this->setValue<orxonox::Vector3> (this->operator orxonox::Vector3()); } /** @brief Converts the current value to the given type. */424 template <> inline void MultiType::convert<orxonox::Vector4>() {this->setValue<orxonox::Vector4> (this->operator orxonox::Vector4()); } /** @brief Converts the current value to the given type. */425 template <> inline void MultiType::convert<orxonox::ColourValue>() {this->setValue<orxonox::ColourValue>(this->operator orxonox::ColourValue()); } /** @brief Converts the current value to the given type. */426 template <> inline void MultiType::convert<orxonox::Quaternion>() {this->setValue<orxonox::Quaternion> (this->operator orxonox::Quaternion()); } /** @brief Converts the current value to the given type. */427 template <> inline void MultiType::convert<orxonox::Radian>() {this->setValue<orxonox::Radian> (this->operator orxonox::Radian()); } /** @brief Converts the current value to the given type. */428 template <> inline void MultiType::convert<orxonox::Degree>() {this->setValue<orxonox::Degree> (this->operator orxonox::Degree()); } /** @brief Converts the current value to the given type. */456 template <> inline bool MultiType::convert<std::string>() { return this->setValue<std::string> (this->operator std::string()); } /** @brief Converts the current value to the given type. */ 457 template <> inline bool MultiType::convert<orxonox::Vector2>() { return this->setValue<orxonox::Vector2> (this->operator orxonox::Vector2()); } /** @brief Converts the current value to the given type. */ 458 template <> inline bool MultiType::convert<orxonox::Vector3>() { return this->setValue<orxonox::Vector3> (this->operator orxonox::Vector3()); } /** @brief Converts the current value to the given type. */ 459 template <> inline bool MultiType::convert<orxonox::Vector4>() { return this->setValue<orxonox::Vector4> (this->operator orxonox::Vector4()); } /** @brief Converts the current value to the given type. */ 460 template <> inline bool MultiType::convert<orxonox::ColourValue>() { return this->setValue<orxonox::ColourValue>(this->operator orxonox::ColourValue()); } /** @brief Converts the current value to the given type. */ 461 template <> inline bool MultiType::convert<orxonox::Quaternion>() { return this->setValue<orxonox::Quaternion> (this->operator orxonox::Quaternion()); } /** @brief Converts the current value to the given type. */ 462 template <> inline bool MultiType::convert<orxonox::Radian>() { return this->setValue<orxonox::Radian> (this->operator orxonox::Radian()); } /** @brief Converts the current value to the given type. */ 463 template <> inline bool MultiType::convert<orxonox::Degree>() { return this->setValue<orxonox::Degree> (this->operator orxonox::Degree()); } /** @brief Converts the current value to the given type. */ 429 464 430 465 // Specialization to avoid ambiguities with the conversion operator 431 template <> inline void MultiType::convert<const std::string&>() {this->convert<std::string>(); } /** @brief Converts the current value to the given type. */432 template <> inline void MultiType::convert<const orxonox::Vector2&>() {this->convert<orxonox::Vector2>(); } /** @brief Converts the current value to the given type. */433 template <> inline void MultiType::convert<const orxonox::Vector3&>() {this->convert<orxonox::Vector3>(); } /** @brief Converts the current value to the given type. */434 template <> inline void MultiType::convert<const orxonox::Vector4&>() {this->convert<orxonox::Vector4>(); } /** @brief Converts the current value to the given type. */435 template <> inline void MultiType::convert<const orxonox::ColourValue&>() {this->convert<orxonox::ColourValue>(); } /** @brief Converts the current value to the given type. */436 template <> inline void MultiType::convert<const orxonox::Quaternion&>() {this->convert<orxonox::Quaternion>(); } /** @brief Converts the current value to the given type. */437 template <> inline void MultiType::convert<const orxonox::Radian&>() {this->convert<orxonox::Radian>(); } /** @brief Converts the current value to the given type. */438 template <> inline void MultiType::convert<const orxonox::Degree&>() {this->convert<orxonox::Degree>(); } /** @brief Converts the current value to the given type. */466 template <> inline bool MultiType::convert<const std::string&>() { return this->convert<std::string>(); } /** @brief Converts the current value to the given type. */ 467 template <> inline bool MultiType::convert<const orxonox::Vector2&>() { return this->convert<orxonox::Vector2>(); } /** @brief Converts the current value to the given type. */ 468 template <> inline bool MultiType::convert<const orxonox::Vector3&>() { return this->convert<orxonox::Vector3>(); } /** @brief Converts the current value to the given type. */ 469 template <> inline bool MultiType::convert<const orxonox::Vector4&>() { return this->convert<orxonox::Vector4>(); } /** @brief Converts the current value to the given type. */ 470 template <> inline bool MultiType::convert<const orxonox::ColourValue&>() { return this->convert<orxonox::ColourValue>(); } /** @brief Converts the current value to the given type. */ 471 template <> inline bool MultiType::convert<const orxonox::Quaternion&>() { return this->convert<orxonox::Quaternion>(); } /** @brief Converts the current value to the given type. */ 472 template <> inline bool MultiType::convert<const orxonox::Radian&>() { return this->convert<orxonox::Radian>(); } /** @brief Converts the current value to the given type. */ 473 template <> inline bool MultiType::convert<const orxonox::Degree&>() { return this->convert<orxonox::Degree>(); } /** @brief Converts the current value to the given type. */ 439 474 440 475 template <> void MultiType::createNewValueContainer(const char& value); … … 462 497 template <> void MultiType::createNewValueContainer(const orxonox::Degree& value); 463 498 464 inline void MultiType::setValue(const char& value) { if (this->value_) { this->value_->setValue(value); } else {this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */465 inline void MultiType::setValue(const unsigned char& value) { if (this->value_) { this->value_->setValue(value); } else {this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */466 inline void MultiType::setValue(const short& value) { if (this->value_) { this->value_->setValue(value); } else {this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */467 inline void MultiType::setValue(const unsigned short& value) { if (this->value_) { this->value_->setValue(value); } else {this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */468 inline void MultiType::setValue(const int& value) { if (this->value_) { this->value_->setValue(value); } else {this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */469 inline void MultiType::setValue(const unsigned int& value) { if (this->value_) { this->value_->setValue(value); } else {this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */470 inline void MultiType::setValue(const long& value) { if (this->value_) { this->value_->setValue(value); } else {this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */471 inline void MultiType::setValue(const unsigned long& value) { if (this->value_) { this->value_->setValue(value); } else {this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */472 inline void MultiType::setValue(const long long& value) { if (this->value_) { this->value_->setValue(value); } else {this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */473 inline void MultiType::setValue(const unsigned long long& value) { if (this->value_) { this->value_->setValue(value); } else {this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */474 inline void MultiType::setValue(const float& value) { if (this->value_) { this->value_->setValue(value); } else {this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */475 inline void MultiType::setValue(const double& value) { if (this->value_) { this->value_->setValue(value); } else {this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */476 inline void MultiType::setValue(const long double& value) { if (this->value_) { this->value_->setValue(value); } else {this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */477 inline void MultiType::setValue(const bool& value) { if (this->value_) { this->value_->setValue(value); } else {this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */478 inline void MultiType::setValue( void* const& value) { if (this->value_) { this->value_->setValue(value); } else {this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */479 inline void MultiType::setValue(const std::string& value) { if (this->value_) { this->value_->setValue(value); } else {this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */480 inline void MultiType::setValue(const orxonox::Vector2& value) { if (this->value_) { this->value_->setValue(value); } else {this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */481 inline void MultiType::setValue(const orxonox::Vector3& value) { if (this->value_) { this->value_->setValue(value); } else {this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */482 inline void MultiType::setValue(const orxonox::Vector4& value) { if (this->value_) { this->value_->setValue(value); } else {this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */483 inline void MultiType::setValue(const orxonox::ColourValue& value) { if (this->value_) { this->value_->setValue(value); } else {this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */484 inline void MultiType::setValue(const orxonox::Quaternion& value) { if (this->value_) { this->value_->setValue(value); } else {this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */485 inline void MultiType::setValue(const orxonox::Radian& value) { if (this->value_) { this->value_->setValue(value); } else {this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */486 inline void MultiType::setValue(const orxonox::Degree& value) { if (this->value_) { this->value_->setValue(value); } else {this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */487 488 inline void MultiType::setValue(const char* value) { if (this->value_) { this->value_->setValue(std::string(value)); } else {this->assignValue(std::string(value)); } } /** @brief Assigns the given value and converts it to the current type. */499 inline bool MultiType::setValue(const char& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 500 inline bool MultiType::setValue(const unsigned char& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 501 inline bool MultiType::setValue(const short& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 502 inline bool MultiType::setValue(const unsigned short& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 503 inline bool MultiType::setValue(const int& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 504 inline bool MultiType::setValue(const unsigned int& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 505 inline bool MultiType::setValue(const long& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 506 inline bool MultiType::setValue(const unsigned long& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 507 inline bool MultiType::setValue(const long long& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 508 inline bool MultiType::setValue(const unsigned long long& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 509 inline bool MultiType::setValue(const float& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 510 inline bool MultiType::setValue(const double& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 511 inline bool MultiType::setValue(const long double& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 512 inline bool MultiType::setValue(const bool& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 513 inline bool MultiType::setValue( void* const& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 514 inline bool MultiType::setValue(const std::string& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 515 inline bool MultiType::setValue(const orxonox::Vector2& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 516 inline bool MultiType::setValue(const orxonox::Vector3& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 517 inline bool MultiType::setValue(const orxonox::Vector4& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 518 inline bool MultiType::setValue(const orxonox::ColourValue& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 519 inline bool MultiType::setValue(const orxonox::Quaternion& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 520 inline bool MultiType::setValue(const orxonox::Radian& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 521 inline bool MultiType::setValue(const orxonox::Degree& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */ 522 523 inline bool MultiType::setValue(const char* value) { if (this->value_) { return this->value_->setValue(std::string(value)); } else { return this->assignValue(std::string(value)); } } /** @brief Assigns the given value and converts it to the current type. */ 489 524 490 525 #endif /* _MultiType_H__ */
Note: See TracChangeset
for help on using the changeset viewer.