Changeset 3332 for code/trunk/src/util
- Timestamp:
- Jul 21, 2009, 12:54:15 PM (15 years ago)
- Location:
- code/trunk/src/util
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/util/MultiType.h
r3301 r3332 77 77 #include <OgreColourValue.h> 78 78 79 #include "T emplateUtils.h"79 #include "TypeTraits.h" 80 80 81 81 namespace orxonox … … 303 303 inline bool setValue(const char* value); 304 304 /** @brief Assigns a pointer. */ 305 template <typename V> inline bool setValue(V* value) { if (this->value_) { return this->value_->setValue(static_cast<void*>(const_cast<typename TypeStripper<V>::RawType*>(value))); } else { return this->assignValue(static_cast<void*>(const_cast<typename TypeStripper<V>::RawType*>(value))); } } 305 template <typename V> inline bool setValue(V* value) 306 { 307 if (this->value_) 308 return this->value_->setValue(static_cast<void*>(const_cast<typename Loki::TypeTraits<V>::UnqualifiedType*>(value))); 309 else 310 return this->assignValue (static_cast<void*>(const_cast<typename Loki::TypeTraits<V>::UnqualifiedType*>(value))); 311 } 306 312 /** @brief Assigns the value of the other MultiType and converts it to the current type. */ 307 313 bool setValue(const MultiType& other) { if (this->value_) { return this->value_->assimilate(other); } else { if (other.value_) { this->value_ = other.value_->clone(); } return true; } } … … 322 328 inline void resetValue() { if (this->value_) this->value_->reset(); } 323 329 324 template <typename T> inline void setType() { this->assignValue(typename TypeStripper<T>::RawType()); } /** @brief Resets the value and changes the internal type to T. */325 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. */326 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. */330 template <typename T> inline void setType() { this->assignValue(typename Loki::TypeTraits<T>::UnqualifiedReferredType()); } /** @brief Resets the value and changes the internal type to T. */ 331 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. */ 332 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. */ 327 333 328 334 /** @brief Returns the current type. */ -
code/trunk/src/util/TemplateUtils.h
r3233 r3332 39 39 namespace orxonox 40 40 { 41 /**42 @brief43 Use TypeStripper to get rid of the const and the reference of type T44 @note45 Main use of this is when trying to instantiate type T as T().46 */47 template <class T> struct TypeStripper48 { typedef T RawType; };49 template <class T> struct TypeStripper<const T>50 { typedef T RawType; };51 template <class T> struct TypeStripper<const T&>52 { typedef T RawType; };53 54 55 41 /////////////////////////////////////////////////// 56 42 // Static detection of implicit type conversions //
Note: See TracChangeset
for help on using the changeset viewer.