Changeset 3301 for code/trunk/src/util/MultiType.h
- Timestamp:
- Jul 18, 2009, 4:03:59 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/util/MultiType.h
r3280 r3301 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( (void*)value); } else { return this->assignValue((void*)value); } }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))); } } 306 306 /** @brief Assigns the value of the other MultiType and converts it to the current type. */ 307 307 bool setValue(const MultiType& other) { if (this->value_) { return this->value_->assimilate(other); } else { if (other.value_) { this->value_ = other.value_->clone(); } return true; } } … … 335 335 336 336 /** @brief Saves the value of the MT to a bytestream (pointed at by mem) and increases mem pointer by size of MT */ 337 inline void exportData(uint8_t*& mem) const { assert(sizeof(MT_Type::Value)<=8); * (uint8_t*)(mem) = this->getType(); mem+=sizeof(uint8_t); this->value_->exportData(mem); }337 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); } 338 338 /** @brief Loads the value of the MT from a bytestream (pointed at by mem) and increases mem pointer by size of MT */ 339 inline void importData(uint8_t*& mem) { assert(sizeof(MT_Type::Value)<=8); this->setType(static_cast<MT_Type::Value>(* (uint8_t*)mem)); mem+=sizeof(uint8_t); this->value_->importData(mem); }339 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); } 340 340 /** @brief Saves the value of the MT to a bytestream and increases pointer to bytestream by size of MT */ 341 341 inline uint8_t*& operator << (uint8_t*& mem) { importData(mem); return mem; } … … 371 371 operator orxonox::Degree() const; 372 372 /** @brief Returns the current value, converted to a T* pointer. */ 373 template <class T> operator T*() const { return ( (T*)this->operator void*()); }373 template <class T> operator T*() const { return (static_cast<T*>(this->operator void*())); } 374 374 375 375 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. */ … … 420 420 inline orxonox::Radian getRadian() const { return this->operator orxonox::Radian(); } /** @brief Returns the current value, converted to the requested type. */ 421 421 inline orxonox::Degree getDegree() const { return this->operator orxonox::Degree(); } /** @brief Returns the current value, converted to the requested type. */ 422 template <typename T> inline T* getPointer() const { return ((T*)this->getVoid());} /** @brief Returns the current value, converted to a T* pointer. */422 template <typename T> inline T* getPointer() const { return static_cast<T*>(this->getVoid()); } /** @brief Returns the current value, converted to a T* pointer. */ 423 423 424 424 private:
Note: See TracChangeset
for help on using the changeset viewer.