Changeset 7401 for code/trunk/src/libraries/util/MultiType.h
- Timestamp:
- Sep 11, 2010, 12:34:00 AM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/doc (added) merged: 7290-7292,7296-7300,7302-7304,7306-7312,7315-7318,7323,7325,7327,7331-7332,7334-7335,7345-7347,7352-7353,7356-7357,7361,7363-7367,7371-7375,7388
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/util/MultiType.h
r7284 r7401 28 28 29 29 /** 30 @defgroup MultiType MultiType 31 @ingroup Util 32 */ 33 34 /** 30 35 @file 36 @ingroup MultiType 31 37 @brief Declaration of the MultiType and some helper constructs. 32 38 39 @anchor MultiTypeExamples 40 33 41 The MultiType can hold a value of one of the following types: 34 - all primitives 35 - all pointers 36 - st ring42 - all primitives (int, float, bool, etc.) 43 - all pointers (void* and T*) 44 - std::string 37 45 - Vector2, Vector3, Vector4 38 46 - Quaternion … … 40 48 - Radian, Degree 41 49 42 The MultiType has a "type" determined by the first assigned value, either through 43 - the constructor, 44 - the assignment operator= or 45 - setValue(value). 46 If you assign another value of another type, the MultiType keeps "it's" type and 47 converts the new value to this type. 50 The MultiType has an internal "type" determined by the first assigned value, using one of these ways: 51 - @ref orxonox::MultiType::MultiType "The constructor" 52 - The assignment operator= (orxonox::MultiType::operator=()) 53 - @ref orxonox::MultiType::setValue() "setValue(value)" 54 55 If you assign another value of another type, the MultiType keeps "its" type and 56 converts the new value to the old type. 48 57 49 58 If you want to change the type, there are three possibilities: 50 - convert<T>() set's the type to T and converts the currently assigned value51 - setType<T>() set's the type to T and resets the value59 - @ref orxonox::MultiType::convert "convert<T>()" sets the type to T and converts the currently assigned value 60 - @ref orxonox::MultiType::setType "setType<T>()" sets the type to T and resets the value to zero using zeroise<T>() 52 61 - setValue<T>(value) assigns a new value and changes the type to T. 53 62 54 @example 55 MultiType a = 10;; // a has now the type int and the value 10 63 Examples: 64 @code 65 MultiType a = 10; // a has now the type int and the value 10 56 66 a.setValue("3.14"); // a has still the type int and "3.14" gets converted, therefore the value is now 3 57 a.setValue<float>("3.14"); // a has now the type float and "3.14" gets converted to 3.14 58 a.convert<bool>(); // converts 3.14 to bool, which is true67 a.setValue<float>("3.14"); // a has now the type float and "3.14" gets converted to 3.14f 68 a.convert<bool>(); // converts 3.14f to bool, which is true 59 69 a = false; // assigns false, this is equivalent to a.setValue(false) 70 @endcode 71 72 You can pass a MultiType to a function as an argument, even if the argument is 73 not of type MultiType. This works, because the MultiType is automatically converted 74 to the right type. 75 76 Example: 77 @code 78 void myfunction(int value) 79 { 80 COUT(0) << "doubled value is " << (2 * value) << std::endl; 81 } 82 83 MultiType a = "50"; // Note: We assigned a string 84 myfunction(a); // a is converted to int and passed to the function, which prints "value is 100" 85 @endcode 86 87 Note however that it is of course quite expensive to convert values, especially std::string <-> value. 88 So if you can, always assign a value with the right type to avoid conversion. 60 89 61 90 @note … … 127 156 - Radian, Degree 128 157 129 The internal type of a MultiType is determined by the first assigned value, but can be 130 changed by using setType<T>(), convert<T>() or setValue<T>(value). If a value gets assigned 131 the normal way (operator=, setValue(value)), the value gets converted to the current internal 132 type of the MultiType. 158 For more information and some examples see the description @ref MultiTypeExamples "here". 159 160 @see MultiType.h 133 161 */ 134 162 class _UtilExport MultiType … … 153 181 virtual bool assimilate(const MultiType& other) = 0; 154 182 155 / ** @brief Returns the type of the current value. */183 /// Returns the type of the current value. 156 184 const MT_Type::Value& getType() const { return this->type_; } 157 185 158 / ** @brief Checks whether the value is a default one. */186 /// Checks whether the value is a default one. 159 187 bool hasDefaultValue() const { return this->bHasDefaultValue_; } 160 188 … … 237 265 virtual uint8_t getSize() const=0; 238 266 239 MT_Type::Value type_; // !< The type of the current value240 bool bHasDefaultValue_; // !< True if the last conversion wasn't successful267 MT_Type::Value type_; ///< The type of the current value 268 bool bHasDefaultValue_; ///< True if the last conversion wasn't successful 241 269 }; 242 270 243 271 public: 244 inline MultiType() : value_(0) {} / ** @brief Default constructor: Assigns no value and no type. The type will be determined by the first assignment of a value. */245 inline MultiType(const char& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */246 inline MultiType(const unsigned char& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */247 inline MultiType(const short& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */248 inline MultiType(const unsigned short& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */249 inline MultiType(const int& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */250 inline MultiType(const unsigned int& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */251 inline MultiType(const long& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */252 inline MultiType(const unsigned long& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */253 inline MultiType(const long long& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */254 inline MultiType(const unsigned long long& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */255 inline MultiType(const float& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */256 inline MultiType(const double& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */257 inline MultiType(const long double& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */258 inline MultiType(const bool& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */259 inline MultiType( void* const& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */260 inline MultiType(const std::string& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */261 inline MultiType(const orxonox::Vector2& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */262 inline MultiType(const orxonox::Vector3& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */263 inline MultiType(const orxonox::Vector4& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */264 inline MultiType(const orxonox::ColourValue& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */265 inline MultiType(const orxonox::Quaternion& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */266 inline MultiType(const orxonox::Radian& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */267 inline MultiType(const orxonox::Degree& value) : value_(0) { this->assignValue(value); } / ** @brief Constructor: Assigns the given value and sets the type. */268 inline MultiType(const orxonox::mbool& value) : value_(0) { this->assignValue((bool)value); } / ** @brief Constructor: Assigns the given mbool and converts it to bool. */269 inline MultiType(const char* value) : value_(0) { this->setValue(std::string(value)); } / ** @brief Constructor: Converts the char array to a std::string, assigns the value and sets the type. */270 inline MultiType(const MultiType& other) : value_(0) { this->setValue(other); } / ** @brief Copyconstructor: Assigns value and type of the other MultiType. */271 inline MultiType(MT_Type::Value type) : value_(0) { this->setType(type); } / ** @brief Constructor: Sets the type, the next assignment will determine the value. */272 273 / ** @brief Destructor: Deletes the MT_Value. */272 inline MultiType() : value_(0) {} ///< Default constructor: Assigns no value and no type. The type will be determined by the first assignment of a value. 273 inline MultiType(const char& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 274 inline MultiType(const unsigned char& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 275 inline MultiType(const short& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 276 inline MultiType(const unsigned short& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 277 inline MultiType(const int& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 278 inline MultiType(const unsigned int& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 279 inline MultiType(const long& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 280 inline MultiType(const unsigned long& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 281 inline MultiType(const long long& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 282 inline MultiType(const unsigned long long& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 283 inline MultiType(const float& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 284 inline MultiType(const double& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 285 inline MultiType(const long double& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 286 inline MultiType(const bool& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 287 inline MultiType( void* const& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 288 inline MultiType(const std::string& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 289 inline MultiType(const orxonox::Vector2& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 290 inline MultiType(const orxonox::Vector3& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 291 inline MultiType(const orxonox::Vector4& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 292 inline MultiType(const orxonox::ColourValue& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 293 inline MultiType(const orxonox::Quaternion& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 294 inline MultiType(const orxonox::Radian& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 295 inline MultiType(const orxonox::Degree& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type. 296 inline MultiType(const orxonox::mbool& value) : value_(0) { this->assignValue((bool)value); } ///< Constructor: Assigns the given mbool and converts it to bool. 297 inline MultiType(const char* value) : value_(0) { this->setValue(std::string(value)); } ///< Constructor: Converts the char array to a std::string, assigns the value and sets the type. 298 inline MultiType(const MultiType& other) : value_(0) { this->setValue(other); } ///< Copyconstructor: Assigns value and type of the other MultiType. 299 inline MultiType(MT_Type::Value type) : value_(0) { this->setType(type); } ///< Constructor: Sets the type, the next assignment will determine the value. 300 301 /// Destructor: Deletes the MT_Value. 274 302 inline ~MultiType() { if (this->value_) { delete this->value_; } } 275 303 276 template <typename V> inline MultiType& operator=(const V& value) { this->setValue(value); return (*this); } / ** @brief Assigns a new value. The value will be converted to the current type of the MultiType. */277 template <typename V> inline MultiType& operator=(V* value) { this->setValue(value); return (*this); } / ** @brief Assigns a pointer. */278 inline MultiType& operator=(const MultiType& other) { this->setValue(other); return (*this); } / ** @brief Assigns the value of the other MultiType and converts it to the current type of the MultiType. */279 inline MultiType& operator=(MT_Type::Value type) { this->setType(type); return (*this); } / ** @brief Resets the value and changes the type. */304 template <typename V> inline MultiType& operator=(const V& value) { this->setValue(value); return (*this); } ///< Assigns a new value. The value will be converted to the current type of the MultiType. 305 template <typename V> inline MultiType& operator=(V* value) { this->setValue(value); return (*this); } ///< Assigns a pointer. 306 inline MultiType& operator=(const MultiType& other) { this->setValue(other); return (*this); } ///< Assigns the value of the other MultiType and converts it to the current type of the MultiType. 307 inline MultiType& operator=(MT_Type::Value type) { this->setType(type); return (*this); } ///< Resets the value and changes the type. 280 308 281 309 inline bool setValue(const char& value); … … 303 331 inline bool setValue(const orxonox::Degree& value); 304 332 inline bool setValue(const char* value); 305 / ** @brief Assigns a pointer. */333 /// Assigns a pointer. 306 334 template <typename V> inline bool setValue(V* value) 307 335 { … … 311 339 return this->assignValue (static_cast<void*>(const_cast<typename Loki::TypeTraits<V>::UnqualifiedType*>(value))); 312 340 } 313 / ** @brief Assigns the value of the other MultiType and converts it to the current type. */341 /// Assigns the value of the other MultiType and converts it to the current type. 314 342 bool setValue(const MultiType& other) { if (this->value_) { return this->value_->assimilate(other); } else { if (other.value_) { this->value_ = other.value_->clone(); } return true; } } 315 / ** @brief Changes the type to T and assigns the new value (which might be of another type than T - it gets converted). */343 /// Changes the type to T and assigns the new value (which might be of another type than T - it gets converted). 316 344 template <typename T, typename V> inline bool setValue(const V& value) { this->setType<T>(); return this->setValue(value); } 317 345 318 346 319 / ** @brief Copies the other MultiType by assigning value and type. */347 /// Copies the other MultiType by assigning value and type. 320 348 inline void copy(const MultiType& other) { if (this == &other) { return; } if (this->value_) { delete this->value_; } this->value_ = (other.value_) ? other.value_->clone() : 0; } 321 349 322 template <typename T> inline bool convert() { return this->setValue<T>((typename Loki::TypeTraits<T>::UnqualifiedReferredType)(*this)); } /** @brief Converts the current value to type T. */ 323 inline bool convert(const MultiType& other) { return this->convert(other.getType()); } /** @brief Converts the current value to the type of the other MultiType. */ 350 /// Converts the current value to type T. 351 template <typename T> inline bool convert() { return this->setValue<T>((typename Loki::TypeTraits<T>::UnqualifiedReferredType)(*this)); } 352 /// Converts the current value to the type of the other MultiType. 353 inline bool convert(const MultiType& other) { return this->convert(other.getType()); } 324 354 bool convert(MT_Type::Value type); 325 355 326 / ** @brief Current content gets deleted. New type is MT_Type::Null */356 /// Current content gets deleted. New type is MT_Type::Null 327 357 inline void reset() { if (this->value_) delete this->value_; this->value_ = 0; } 328 / ** @brief Current content gets overridden with default zero value */358 /// Current content gets overridden with default zero value 329 359 inline void resetValue() { if (this->value_) this->value_->reset(); } 330 360 331 template <typename T> inline void setType() { this->assignValue(typename Loki::TypeTraits<T>::UnqualifiedReferredType()); } /** @brief Resets the value and changes the internal type to T. */ 332 inline void setType(const MultiType& other) { this->setType(other.getType()); } /** @brief Resets the value and changes the internal type to the type of the other MultiType. */ 333 inline void setType(MT_Type::Value type) { this->reset(); this->convert(type); this->resetValue(); } /** @brief Resets the value and changes the internal type to the given type. */ 334 335 /** @brief Returns the current type. */ 361 /// Resets the value and changes the internal type to T. 362 template <typename T> inline void setType() { this->assignValue(typename Loki::TypeTraits<T>::UnqualifiedReferredType()); } 363 /// Resets the value and changes the internal type to the type of the other MultiType. 364 inline void setType(const MultiType& other) { this->setType(other.getType()); } 365 /// Resets the value and changes the internal type to the given type. 366 inline void setType(MT_Type::Value type) { this->reset(); this->convert(type); this->resetValue(); } 367 368 /// Returns the current type. 336 369 inline MT_Type::Value getType() const { return (this->value_) ? this->value_->type_ : MT_Type::Null; } 337 / ** @brief Returns true if the current type equals the given type. */370 /// Returns true if the current type equals the given type. 338 371 inline bool isType(MT_Type::Value type) const { return (this->value_) ? (this->value_->type_ == type) : (type == MT_Type::Null); } 339 / ** @brief Returns true if the current type is T. */372 /// Returns true if the current type is T. 340 373 template <typename T> inline bool isType() const { return false; } // Only works for specialized values - see below 341 374 std::string getTypename() const; 342 375 343 / ** @brief Saves the value of the MT to a bytestream (pointed at by mem) and increases mem pointer by size of MT */376 /// Saves the value of the MT to a bytestream (pointed at by mem) and increases mem pointer by size of MT 344 377 inline void exportData(uint8_t*& mem) const { assert(sizeof(MT_Type::Value)<=8); *static_cast<uint8_t*>(mem) = this->getType(); mem+=sizeof(uint8_t); this->value_->exportData(mem); } 345 / ** @brief Loads the value of the MT from a bytestream (pointed at by mem) and increases mem pointer by size of MT */378 /// Loads the value of the MT from a bytestream (pointed at by mem) and increases mem pointer by size of MT 346 379 inline void importData(uint8_t*& mem) { assert(sizeof(MT_Type::Value)<=8); this->setType(static_cast<MT_Type::Value>(*static_cast<uint8_t*>(mem))); mem+=sizeof(uint8_t); this->value_->importData(mem); } 347 / ** @brief Saves the value of the MT to a bytestream and increases pointer to bytestream by size of MT */380 /// Saves the value of the MT to a bytestream and increases pointer to bytestream by size of MT 348 381 inline uint8_t*& operator << (uint8_t*& mem) { importData(mem); return mem; } 349 / ** @brief Loads the value of the MT to a bytestream and increases pointer to bytestream by size of MT */382 /// Loads the value of the MT to a bytestream and increases pointer to bytestream by size of MT 350 383 inline void operator >> (uint8_t*& mem) const { exportData(mem); } 351 384 inline uint32_t getNetworkSize() const { assert(this->value_); return this->value_->getSize() + sizeof(uint8_t); } 352 385 353 / ** @brief Checks whether the value is a default one. */386 /// Checks whether the value is a default one (assigned after a failed conversion) 354 387 bool hasDefaultValue() const { return this->value_->hasDefaultValue(); } 355 388 356 / ** @brief Checks if the MT contains no value. */389 /// Checks if the MT contains no value. 357 390 bool null() const { return (!this->value_); } 358 391 … … 380 413 operator orxonox::Radian() const; 381 414 operator orxonox::Degree() const; 382 / ** @brief Returns the current value, converted to a T* pointer. */415 /// Returns the current value, converted to a T* pointer. 383 416 template <class T> operator T*() const { return (static_cast<T*>(this->operator void*())); } 384 417 385 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. */386 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. */387 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. */388 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. */389 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. */390 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. */391 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. */392 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. */393 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. */394 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. */395 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. */396 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. */397 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. */398 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. */399 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. */400 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. */401 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. */402 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. */403 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. */404 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. */405 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. */406 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. */407 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. */408 409 inline char getChar() const { return this->operator char(); } / ** @brief Returns the current value, converted to the requested type. */410 inline unsigned char getUnsignedChar() const { return this->operator unsigned char(); } / ** @brief Returns the current value, converted to the requested type. */411 inline short getShort() const { return this->operator short(); } / ** @brief Returns the current value, converted to the requested type. */412 inline unsigned short getUnsignedShort() const { return this->operator unsigned short(); } / ** @brief Returns the current value, converted to the requested type. */413 inline int getInt() const { return this->operator int(); } / ** @brief Returns the current value, converted to the requested type. */414 inline unsigned int getUnsignedInt() const { return this->operator unsigned int(); } / ** @brief Returns the current value, converted to the requested type. */415 inline long getLong() const { return this->operator long(); } / ** @brief Returns the current value, converted to the requested type. */416 inline unsigned long getUnsignedLong() const { return this->operator unsigned long(); } / ** @brief Returns the current value, converted to the requested type. */417 inline long long getLongLong() const { return this->operator long long(); } / ** @brief Returns the current value, converted to the requested type. */418 inline unsigned long long getUnsignedLongLong() const { return this->operator unsigned long long(); } / ** @brief Returns the current value, converted to the requested type. */419 inline float getFloat() const { return this->operator float(); } / ** @brief Returns the current value, converted to the requested type. */420 inline double getDouble() const { return this->operator double(); } / ** @brief Returns the current value, converted to the requested type. */421 inline long double getLongDouble() const { return this->operator long double(); } / ** @brief Returns the current value, converted to the requested type. */422 inline bool getBool() const { return this->operator bool(); } / ** @brief Returns the current value, converted to the requested type. */423 inline void* getVoid() const { return this->operator void*(); } / ** @brief Returns the current value, converted to the requested type. */424 inline std::string getString() const { return this->operator std::string(); } / ** @brief Returns the current value, converted to the requested type. */425 inline orxonox::Vector2 getVector2() const { return this->operator orxonox::Vector2(); } / ** @brief Returns the current value, converted to the requested type. */426 inline orxonox::Vector3 getVector3() const { return this->operator orxonox::Vector3(); } / ** @brief Returns the current value, converted to the requested type. */427 inline orxonox::Vector4 getVector4() const { return this->operator orxonox::Vector4(); } / ** @brief Returns the current value, converted to the requested type. */428 inline orxonox::ColourValue getColourValue() const { return this->operator orxonox::ColourValue(); } / ** @brief Returns the current value, converted to the requested type. */429 inline orxonox::Quaternion getQuaternion() const { return this->operator orxonox::Quaternion(); } / ** @brief Returns the current value, converted to the requested type. */430 inline orxonox::Radian getRadian() const { return this->operator orxonox::Radian(); } / ** @brief Returns the current value, converted to the requested type. */431 inline orxonox::Degree getDegree() const { return this->operator orxonox::Degree(); } / ** @brief Returns the current value, converted to the requested type. */432 template <typename T> inline T* getPointer() const { return static_cast<T*>(this->getVoid()); } / ** @brief Returns the current value, converted to a T* pointer. */418 inline bool getValue(char* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 419 inline bool getValue(unsigned char* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 420 inline bool getValue(short* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 421 inline bool getValue(unsigned short* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 422 inline bool getValue(int* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 423 inline bool getValue(unsigned int* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 424 inline bool getValue(long* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 425 inline bool getValue(unsigned long* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 426 inline bool getValue(long long* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 427 inline bool getValue(unsigned long long* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 428 inline bool getValue(float* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 429 inline bool getValue(double* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 430 inline bool getValue(long double* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 431 inline bool getValue(bool* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 432 inline bool getValue(void** value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 433 inline bool getValue(std::string* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 434 inline bool getValue(orxonox::Vector2* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 435 inline bool getValue(orxonox::Vector3* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 436 inline bool getValue(orxonox::Vector4* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 437 inline bool getValue(orxonox::ColourValue* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 438 inline bool getValue(orxonox::Quaternion* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 439 inline bool getValue(orxonox::Radian* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 440 inline bool getValue(orxonox::Degree* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match. 441 442 inline char getChar() const { return this->operator char(); } ///< Returns the current value, converted to the requested type. 443 inline unsigned char getUnsignedChar() const { return this->operator unsigned char(); } ///< Returns the current value, converted to the requested type. 444 inline short getShort() const { return this->operator short(); } ///< Returns the current value, converted to the requested type. 445 inline unsigned short getUnsignedShort() const { return this->operator unsigned short(); } ///< Returns the current value, converted to the requested type. 446 inline int getInt() const { return this->operator int(); } ///< Returns the current value, converted to the requested type. 447 inline unsigned int getUnsignedInt() const { return this->operator unsigned int(); } ///< Returns the current value, converted to the requested type. 448 inline long getLong() const { return this->operator long(); } ///< Returns the current value, converted to the requested type. 449 inline unsigned long getUnsignedLong() const { return this->operator unsigned long(); } ///< Returns the current value, converted to the requested type. 450 inline long long getLongLong() const { return this->operator long long(); } ///< Returns the current value, converted to the requested type. 451 inline unsigned long long getUnsignedLongLong() const { return this->operator unsigned long long(); } ///< Returns the current value, converted to the requested type. 452 inline float getFloat() const { return this->operator float(); } ///< Returns the current value, converted to the requested type. 453 inline double getDouble() const { return this->operator double(); } ///< Returns the current value, converted to the requested type. 454 inline long double getLongDouble() const { return this->operator long double(); } ///< Returns the current value, converted to the requested type. 455 inline bool getBool() const { return this->operator bool(); } ///< Returns the current value, converted to the requested type. 456 inline void* getVoid() const { return this->operator void*(); } ///< Returns the current value, converted to the requested type. 457 inline std::string getString() const { return this->operator std::string(); } ///< Returns the current value, converted to the requested type. 458 inline orxonox::Vector2 getVector2() const { return this->operator orxonox::Vector2(); } ///< Returns the current value, converted to the requested type. 459 inline orxonox::Vector3 getVector3() const { return this->operator orxonox::Vector3(); } ///< Returns the current value, converted to the requested type. 460 inline orxonox::Vector4 getVector4() const { return this->operator orxonox::Vector4(); } ///< Returns the current value, converted to the requested type. 461 inline orxonox::ColourValue getColourValue() const { return this->operator orxonox::ColourValue(); } ///< Returns the current value, converted to the requested type. 462 inline orxonox::Quaternion getQuaternion() const { return this->operator orxonox::Quaternion(); } ///< Returns the current value, converted to the requested type. 463 inline orxonox::Radian getRadian() const { return this->operator orxonox::Radian(); } ///< Returns the current value, converted to the requested type. 464 inline orxonox::Degree getDegree() const { return this->operator orxonox::Degree(); } ///< Returns the current value, converted to the requested type. 465 template <typename T> inline T* getPointer() const { return static_cast<T*>(this->getVoid()); } ///< Returns the current value, converted to a T* pointer. 433 466 434 467 private: 435 inline bool assignValue(const char& value) { if (this->value_ && this->value_->type_ == MT_Type::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. */436 inline bool assignValue(const unsigned char& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedChar) { 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. */437 inline bool assignValue(const short& value) { if (this->value_ && this->value_->type_ == MT_Type::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. */438 inline bool assignValue(const unsigned short& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedShort) { 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. */439 inline bool assignValue(const int& value) { if (this->value_ && this->value_->type_ == MT_Type::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. */440 inline bool assignValue(const unsigned int& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedInt) { 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. */441 inline bool assignValue(const long& value) { if (this->value_ && this->value_->type_ == MT_Type::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. */442 inline bool assignValue(const unsigned long& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedLong) { 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. */443 inline bool assignValue(const long long& value) { if (this->value_ && this->value_->type_ == MT_Type::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. */444 inline bool assignValue(const unsigned long long& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedLongLong) { 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. */445 inline bool assignValue(const float& value) { if (this->value_ && this->value_->type_ == MT_Type::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. */446 inline bool assignValue(const double& value) { if (this->value_ && this->value_->type_ == MT_Type::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. */447 inline bool assignValue(const long double& value) { if (this->value_ && this->value_->type_ == MT_Type::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. */448 inline bool assignValue(const bool& value) { if (this->value_ && this->value_->type_ == MT_Type::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. */449 inline bool assignValue( void* const& value) { if (this->value_ && this->value_->type_ == MT_Type::VoidPointer) { 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. */450 inline bool assignValue(const std::string& value) { if (this->value_ && this->value_->type_ == MT_Type::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. */451 inline bool assignValue(const orxonox::Vector2& value) { if (this->value_ && this->value_->type_ == MT_Type::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. */452 inline bool assignValue(const orxonox::Vector3& value) { if (this->value_ && this->value_->type_ == MT_Type::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. */453 inline bool assignValue(const orxonox::Vector4& value) { if (this->value_ && this->value_->type_ == MT_Type::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. */454 inline bool assignValue(const orxonox::ColourValue& value) { if (this->value_ && this->value_->type_ == MT_Type::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. */455 inline bool assignValue(const orxonox::Quaternion& value) { if (this->value_ && this->value_->type_ == MT_Type::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. */456 inline bool assignValue(const orxonox::Radian& value) { if (this->value_ && this->value_->type_ == MT_Type::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. */457 inline bool assignValue(const orxonox::Degree& value) { if (this->value_ && this->value_->type_ == MT_Type::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. */458 459 / ** @brief Changes the value container. */468 inline bool assignValue(const char& value) { if (this->value_ && this->value_->type_ == MT_Type::Char) { return this->value_->setValue(value); } else { this->changeValueContainer<char>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 469 inline bool assignValue(const unsigned char& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedChar) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned char>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 470 inline bool assignValue(const short& value) { if (this->value_ && this->value_->type_ == MT_Type::Short) { return this->value_->setValue(value); } else { this->changeValueContainer<short>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 471 inline bool assignValue(const unsigned short& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedShort) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned short>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 472 inline bool assignValue(const int& value) { if (this->value_ && this->value_->type_ == MT_Type::Int) { return this->value_->setValue(value); } else { this->changeValueContainer<int>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 473 inline bool assignValue(const unsigned int& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedInt) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned int>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 474 inline bool assignValue(const long& value) { if (this->value_ && this->value_->type_ == MT_Type::Long) { return this->value_->setValue(value); } else { this->changeValueContainer<long>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 475 inline bool assignValue(const unsigned long& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedLong) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned long>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 476 inline bool assignValue(const long long& value) { if (this->value_ && this->value_->type_ == MT_Type::LongLong) { return this->value_->setValue(value); } else { this->changeValueContainer<long long>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 477 inline bool assignValue(const unsigned long long& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedLongLong) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned long long>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 478 inline bool assignValue(const float& value) { if (this->value_ && this->value_->type_ == MT_Type::Float) { return this->value_->setValue(value); } else { this->changeValueContainer<float>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 479 inline bool assignValue(const double& value) { if (this->value_ && this->value_->type_ == MT_Type::Double) { return this->value_->setValue(value); } else { this->changeValueContainer<double>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 480 inline bool assignValue(const long double& value) { if (this->value_ && this->value_->type_ == MT_Type::LongDouble) { return this->value_->setValue(value); } else { this->changeValueContainer<long double>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 481 inline bool assignValue(const bool& value) { if (this->value_ && this->value_->type_ == MT_Type::Bool) { return this->value_->setValue(value); } else { this->changeValueContainer<bool>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 482 inline bool assignValue( void* const& value) { if (this->value_ && this->value_->type_ == MT_Type::VoidPointer) { return this->value_->setValue(value); } else { this->changeValueContainer<void*>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 483 inline bool assignValue(const std::string& value) { if (this->value_ && this->value_->type_ == MT_Type::String) { return this->value_->setValue(value); } else { this->changeValueContainer<std::string>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 484 inline bool assignValue(const orxonox::Vector2& value) { if (this->value_ && this->value_->type_ == MT_Type::Vector2) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector2>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 485 inline bool assignValue(const orxonox::Vector3& value) { if (this->value_ && this->value_->type_ == MT_Type::Vector3) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector3>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 486 inline bool assignValue(const orxonox::Vector4& value) { if (this->value_ && this->value_->type_ == MT_Type::Vector4) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector4>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 487 inline bool assignValue(const orxonox::ColourValue& value) { if (this->value_ && this->value_->type_ == MT_Type::ColourValue) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::ColourValue>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 488 inline bool assignValue(const orxonox::Quaternion& value) { if (this->value_ && this->value_->type_ == MT_Type::Quaternion) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Quaternion>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 489 inline bool assignValue(const orxonox::Radian& value) { if (this->value_ && this->value_->type_ == MT_Type::Radian) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Radian>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 490 inline bool assignValue(const orxonox::Degree& value) { if (this->value_ && this->value_->type_ == MT_Type::Degree) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Degree>(value); return true; } } ///< Assigns a new value by changing type and creating a new container. 491 492 /// Changes the value container. 460 493 template <typename T> inline void changeValueContainer(const T& value) { if (this->value_) { delete this->value_; } this->createNewValueContainer<T>(value); } 461 / ** @brief Creates a new value container (works only with specialized types). */494 /// Creates a new value container (works only with specialized types). 462 495 template <typename T> void createNewValueContainer(const T& value) { /* STATIC ASSERT */ *****value; return false; } 463 496 … … 465 498 }; 466 499 467 / ** @brief Puts the MultiType on a stream by using the native << operator of the current type. */500 /// Puts the MultiType on a stream by using the native << operator of the current type. 468 501 _UtilExport inline std::ostream& operator<<(std::ostream& outstream, const MultiType& mt) { if (mt.value_) { mt.value_->toString(outstream); } return outstream; } 469 502 470 template <> inline bool MultiType::isType<char>() const { return (this->value_ && this->value_->type_ == MT_Type::Char); } /** @brief Returns true if the current type equals the given type. */ 471 template <> inline bool MultiType::isType<unsigned char>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedChar); } /** @brief Returns true if the current type equals the given type. */ 472 template <> inline bool MultiType::isType<short>() const { return (this->value_ && this->value_->type_ == MT_Type::Short); } /** @brief Returns true if the current type equals the given type. */ 473 template <> inline bool MultiType::isType<unsigned short>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedShort); } /** @brief Returns true if the current type equals the given type. */ 474 template <> inline bool MultiType::isType<int>() const { return (this->value_ && this->value_->type_ == MT_Type::Int); } /** @brief Returns true if the current type equals the given type. */ 475 template <> inline bool MultiType::isType<unsigned int>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedInt); } /** @brief Returns true if the current type equals the given type. */ 476 template <> inline bool MultiType::isType<long>() const { return (this->value_ && this->value_->type_ == MT_Type::Long); } /** @brief Returns true if the current type equals the given type. */ 477 template <> inline bool MultiType::isType<unsigned long>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedLong); } /** @brief Returns true if the current type equals the given type. */ 478 template <> inline bool MultiType::isType<long long>() const { return (this->value_ && this->value_->type_ == MT_Type::LongLong); } /** @brief Returns true if the current type equals the given type. */ 479 template <> inline bool MultiType::isType<unsigned long long>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedLongLong); } /** @brief Returns true if the current type equals the given type. */ 480 template <> inline bool MultiType::isType<float>() const { return (this->value_ && this->value_->type_ == MT_Type::Float); } /** @brief Returns true if the current type equals the given type. */ 481 template <> inline bool MultiType::isType<double>() const { return (this->value_ && this->value_->type_ == MT_Type::Double); } /** @brief Returns true if the current type equals the given type. */ 482 template <> inline bool MultiType::isType<long double>() const { return (this->value_ && this->value_->type_ == MT_Type::LongDouble); } /** @brief Returns true if the current type equals the given type. */ 483 template <> inline bool MultiType::isType<bool>() const { return (this->value_ && this->value_->type_ == MT_Type::Bool); } /** @brief Returns true if the current type equals the given type. */ 484 template <> inline bool MultiType::isType<void*>() const { return (this->value_ && this->value_->type_ == MT_Type::VoidPointer); } /** @brief Returns true if the current type equals the given type. */ 485 template <> inline bool MultiType::isType<std::string>() const { return (this->value_ && this->value_->type_ == MT_Type::String); } /** @brief Returns true if the current type equals the given type. */ 486 template <> inline bool MultiType::isType<orxonox::Vector2>() const { return (this->value_ && this->value_->type_ == MT_Type::Vector2); } /** @brief Returns true if the current type equals the given type. */ 487 template <> inline bool MultiType::isType<orxonox::Vector3>() const { return (this->value_ && this->value_->type_ == MT_Type::Vector3); } /** @brief Returns true if the current type equals the given type. */ 488 template <> inline bool MultiType::isType<orxonox::Vector4>() const { return (this->value_ && this->value_->type_ == MT_Type::Vector4); } /** @brief Returns true if the current type equals the given type. */ 489 template <> inline bool MultiType::isType<orxonox::ColourValue>() const { return (this->value_ && this->value_->type_ == MT_Type::ColourValue); } /** @brief Returns true if the current type equals the given type. */ 490 template <> inline bool MultiType::isType<orxonox::Quaternion>() const { return (this->value_ && this->value_->type_ == MT_Type::Quaternion); } /** @brief Returns true if the current type equals the given type. */ 491 template <> inline bool MultiType::isType<orxonox::Radian>() const { return (this->value_ && this->value_->type_ == MT_Type::Radian); } /** @brief Returns true if the current type equals the given type. */ 492 template <> inline bool MultiType::isType<orxonox::Degree>() const { return (this->value_ && this->value_->type_ == MT_Type::Degree); } /** @brief Returns true if the current type equals the given type. */ 493 494 template <> inline bool MultiType::convert<void>() { this->reset(); return true; } /** @brief Deletes the content, type becomes MT_Type::Null. */ 503 template <> inline bool MultiType::isType<char>() const { return (this->value_ && this->value_->type_ == MT_Type::Char); } ///< Returns true if the current type equals the given type. 504 template <> inline bool MultiType::isType<unsigned char>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedChar); } ///< Returns true if the current type equals the given type. 505 template <> inline bool MultiType::isType<short>() const { return (this->value_ && this->value_->type_ == MT_Type::Short); } ///< Returns true if the current type equals the given type. 506 template <> inline bool MultiType::isType<unsigned short>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedShort); } ///< Returns true if the current type equals the given type. 507 template <> inline bool MultiType::isType<int>() const { return (this->value_ && this->value_->type_ == MT_Type::Int); } ///< Returns true if the current type equals the given type. 508 template <> inline bool MultiType::isType<unsigned int>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedInt); } ///< Returns true if the current type equals the given type. 509 template <> inline bool MultiType::isType<long>() const { return (this->value_ && this->value_->type_ == MT_Type::Long); } ///< Returns true if the current type equals the given type. 510 template <> inline bool MultiType::isType<unsigned long>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedLong); } ///< Returns true if the current type equals the given type. 511 template <> inline bool MultiType::isType<long long>() const { return (this->value_ && this->value_->type_ == MT_Type::LongLong); } ///< Returns true if the current type equals the given type. 512 template <> inline bool MultiType::isType<unsigned long long>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedLongLong); } ///< Returns true if the current type equals the given type. 513 template <> inline bool MultiType::isType<float>() const { return (this->value_ && this->value_->type_ == MT_Type::Float); } ///< Returns true if the current type equals the given type. 514 template <> inline bool MultiType::isType<double>() const { return (this->value_ && this->value_->type_ == MT_Type::Double); } ///< Returns true if the current type equals the given type. 515 template <> inline bool MultiType::isType<long double>() const { return (this->value_ && this->value_->type_ == MT_Type::LongDouble); } ///< Returns true if the current type equals the given type. 516 template <> inline bool MultiType::isType<bool>() const { return (this->value_ && this->value_->type_ == MT_Type::Bool); } ///< Returns true if the current type equals the given type. 517 template <> inline bool MultiType::isType<void*>() const { return (this->value_ && this->value_->type_ == MT_Type::VoidPointer); } ///< Returns true if the current type equals the given type. 518 template <> inline bool MultiType::isType<std::string>() const { return (this->value_ && this->value_->type_ == MT_Type::String); } ///< Returns true if the current type equals the given type. 519 template <> inline bool MultiType::isType<orxonox::Vector2>() const { return (this->value_ && this->value_->type_ == MT_Type::Vector2); } ///< Returns true if the current type equals the given type. 520 template <> inline bool MultiType::isType<orxonox::Vector3>() const { return (this->value_ && this->value_->type_ == MT_Type::Vector3); } ///< Returns true if the current type equals the given type. 521 template <> inline bool MultiType::isType<orxonox::Vector4>() const { return (this->value_ && this->value_->type_ == MT_Type::Vector4); } ///< Returns true if the current type equals the given type. 522 template <> inline bool MultiType::isType<orxonox::ColourValue>() const { return (this->value_ && this->value_->type_ == MT_Type::ColourValue); } ///< Returns true if the current type equals the given type. 523 template <> inline bool MultiType::isType<orxonox::Quaternion>() const { return (this->value_ && this->value_->type_ == MT_Type::Quaternion); } ///< Returns true if the current type equals the given type. 524 template <> inline bool MultiType::isType<orxonox::Radian>() const { return (this->value_ && this->value_->type_ == MT_Type::Radian); } ///< Returns true if the current type equals the given type. 525 template <> inline bool MultiType::isType<orxonox::Degree>() const { return (this->value_ && this->value_->type_ == MT_Type::Degree); } ///< Returns true if the current type equals the given type. 526 527 /// Deletes the content, type becomes MT_Type::Null. 528 template <> inline bool MultiType::convert<void>() { this->reset(); return true; } 495 529 496 530 // Specialization to avoid ambiguities with the conversion operator 497 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. */498 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. */499 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. */500 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. */501 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. */502 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. */503 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. */504 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. */531 template <> inline bool MultiType::convert<std::string>() { return this->setValue<std::string> (this->operator std::string()); } ///< Converts the current value to the given type. 532 template <> inline bool MultiType::convert<orxonox::Vector2>() { return this->setValue<orxonox::Vector2> (this->operator orxonox::Vector2()); } ///< Converts the current value to the given type. 533 template <> inline bool MultiType::convert<orxonox::Vector3>() { return this->setValue<orxonox::Vector3> (this->operator orxonox::Vector3()); } ///< Converts the current value to the given type. 534 template <> inline bool MultiType::convert<orxonox::Vector4>() { return this->setValue<orxonox::Vector4> (this->operator orxonox::Vector4()); } ///< Converts the current value to the given type. 535 template <> inline bool MultiType::convert<orxonox::ColourValue>() { return this->setValue<orxonox::ColourValue>(this->operator orxonox::ColourValue()); } ///< Converts the current value to the given type. 536 template <> inline bool MultiType::convert<orxonox::Quaternion>() { return this->setValue<orxonox::Quaternion> (this->operator orxonox::Quaternion()); } ///< Converts the current value to the given type. 537 template <> inline bool MultiType::convert<orxonox::Radian>() { return this->setValue<orxonox::Radian> (this->operator orxonox::Radian()); } ///< Converts the current value to the given type. 538 template <> inline bool MultiType::convert<orxonox::Degree>() { return this->setValue<orxonox::Degree> (this->operator orxonox::Degree()); } ///< Converts the current value to the given type. 505 539 506 540 // Specialization to avoid ambiguities with the conversion operator 507 template <> inline bool MultiType::convert<const std::string&>() { return this->convert<std::string>(); } / ** @brief Converts the current value to the given type. */508 template <> inline bool MultiType::convert<const orxonox::Vector2&>() { return this->convert<orxonox::Vector2>(); } / ** @brief Converts the current value to the given type. */509 template <> inline bool MultiType::convert<const orxonox::Vector3&>() { return this->convert<orxonox::Vector3>(); } / ** @brief Converts the current value to the given type. */510 template <> inline bool MultiType::convert<const orxonox::Vector4&>() { return this->convert<orxonox::Vector4>(); } / ** @brief Converts the current value to the given type. */511 template <> inline bool MultiType::convert<const orxonox::ColourValue&>() { return this->convert<orxonox::ColourValue>(); } / ** @brief Converts the current value to the given type. */512 template <> inline bool MultiType::convert<const orxonox::Quaternion&>() { return this->convert<orxonox::Quaternion>(); } / ** @brief Converts the current value to the given type. */513 template <> inline bool MultiType::convert<const orxonox::Radian&>() { return this->convert<orxonox::Radian>(); } / ** @brief Converts the current value to the given type. */514 template <> inline bool MultiType::convert<const orxonox::Degree&>() { return this->convert<orxonox::Degree>(); } / ** @brief Converts the current value to the given type. */541 template <> inline bool MultiType::convert<const std::string&>() { return this->convert<std::string>(); } ///< Converts the current value to the given type. 542 template <> inline bool MultiType::convert<const orxonox::Vector2&>() { return this->convert<orxonox::Vector2>(); } ///< Converts the current value to the given type. 543 template <> inline bool MultiType::convert<const orxonox::Vector3&>() { return this->convert<orxonox::Vector3>(); } ///< Converts the current value to the given type. 544 template <> inline bool MultiType::convert<const orxonox::Vector4&>() { return this->convert<orxonox::Vector4>(); } ///< Converts the current value to the given type. 545 template <> inline bool MultiType::convert<const orxonox::ColourValue&>() { return this->convert<orxonox::ColourValue>(); } ///< Converts the current value to the given type. 546 template <> inline bool MultiType::convert<const orxonox::Quaternion&>() { return this->convert<orxonox::Quaternion>(); } ///< Converts the current value to the given type. 547 template <> inline bool MultiType::convert<const orxonox::Radian&>() { return this->convert<orxonox::Radian>(); } ///< Converts the current value to the given type. 548 template <> inline bool MultiType::convert<const orxonox::Degree&>() { return this->convert<orxonox::Degree>(); } ///< Converts the current value to the given type. 515 549 516 550 template <> _UtilExport void MultiType::createNewValueContainer(const char& value); … … 538 572 template <> _UtilExport void MultiType::createNewValueContainer(const orxonox::Degree& value); 539 573 540 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. */ 541 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. */ 542 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. */ 543 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. */ 544 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. */ 545 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. */ 546 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. */ 547 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. */ 548 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. */ 549 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. */ 550 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. */ 551 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. */ 552 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. */ 553 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. */ 554 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. */ 555 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. */ 556 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. */ 557 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. */ 558 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. */ 559 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. */ 560 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. */ 561 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. */ 562 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. */ 563 564 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. */ 574 inline bool MultiType::setValue(const char& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 575 inline bool MultiType::setValue(const unsigned char& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 576 inline bool MultiType::setValue(const short& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 577 inline bool MultiType::setValue(const unsigned short& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 578 inline bool MultiType::setValue(const int& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 579 inline bool MultiType::setValue(const unsigned int& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 580 inline bool MultiType::setValue(const long& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 581 inline bool MultiType::setValue(const unsigned long& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 582 inline bool MultiType::setValue(const long long& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 583 inline bool MultiType::setValue(const unsigned long long& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 584 inline bool MultiType::setValue(const float& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 585 inline bool MultiType::setValue(const double& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 586 inline bool MultiType::setValue(const long double& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 587 inline bool MultiType::setValue(const bool& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 588 inline bool MultiType::setValue( void* const& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 589 inline bool MultiType::setValue(const std::string& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 590 inline bool MultiType::setValue(const orxonox::Vector2& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 591 inline bool MultiType::setValue(const orxonox::Vector3& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 592 inline bool MultiType::setValue(const orxonox::Vector4& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 593 inline bool MultiType::setValue(const orxonox::ColourValue& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 594 inline bool MultiType::setValue(const orxonox::Quaternion& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 595 inline bool MultiType::setValue(const orxonox::Radian& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 596 inline bool MultiType::setValue(const orxonox::Degree& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type. 597 598 /// Assigns the given value and converts it to the current type. 599 inline bool MultiType::setValue(const char* value) { if (this->value_) { return this->value_->setValue(std::string(value)); } else { return this->assignValue(std::string(value)); } } 565 600 } 566 601
Note: See TracChangeset
for help on using the changeset viewer.