- Timestamp:
- Feb 17, 2011, 5:47:22 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/forks/sandbox_light/src/libraries/util/MultiTypeValue.h
r7401 r7908 43 43 #include "MathConvert.h" 44 44 #include "MultiType.h" 45 #include "Serialise.h"46 45 47 46 namespace orxonox … … 155 154 inline void toString(std::ostream& outstream) const { outstream << this->value_; } 156 155 157 /// loads data from the bytestream (mem) into the MT and increases the bytestream pointer by the size of the data158 inline void importData( uint8_t*& mem ) { loadAndIncrease( /*(const T&)*/this->value_, mem ); }159 /// saves data from the MT into the bytestream (mem) and increases the bytestream pointer by the size of the data160 inline void exportData( uint8_t*& mem ) const { saveAndIncrease( /*(const T&)*/this->value_, mem ); }161 /// returns the size of the data that would be saved by exportData162 inline uint8_t getSize() const { return returnSize( this->value_ ); }163 164 156 T value_; ///< The stored value 165 157 }; 166 167 // Import / Export specialisation168 // ColourValue169 template <> inline void MT_Value<ColourValue>::importData( uint8_t*& mem )170 {171 loadAndIncrease( this->value_.r, mem );172 loadAndIncrease( this->value_.g, mem );173 loadAndIncrease( this->value_.b, mem );174 loadAndIncrease( this->value_.a, mem );175 }176 template <> inline void MT_Value<ColourValue>::exportData( uint8_t*& mem ) const177 {178 saveAndIncrease( this->value_.r, mem );179 saveAndIncrease( this->value_.g, mem );180 saveAndIncrease( this->value_.b, mem );181 saveAndIncrease( this->value_.a, mem );182 }183 template <> inline uint8_t MT_Value<ColourValue>::getSize() const184 {185 return 4*returnSize(this->value_.r);186 }187 // Ogre::Quaternion188 template <> inline void MT_Value<Ogre::Quaternion>::importData( uint8_t*& mem )189 {190 loadAndIncrease( this->value_.x, mem );191 loadAndIncrease( this->value_.y, mem );192 loadAndIncrease( this->value_.z, mem );193 loadAndIncrease( this->value_.w, mem );194 }195 template <> inline void MT_Value<Ogre::Quaternion>::exportData( uint8_t*& mem ) const196 {197 saveAndIncrease( this->value_.x, mem );198 saveAndIncrease( this->value_.y, mem );199 saveAndIncrease( this->value_.z, mem );200 saveAndIncrease( this->value_.w, mem );201 }202 template <> inline uint8_t MT_Value<Ogre::Quaternion>::getSize() const203 {204 return 4*returnSize(this->value_.x);205 }206 // Ogre::Vector2207 template <> inline void MT_Value<Ogre::Vector2>::importData( uint8_t*& mem )208 {209 loadAndIncrease( this->value_.x, mem );210 loadAndIncrease( this->value_.y, mem );211 }212 template <> inline void MT_Value<Ogre::Vector2>::exportData( uint8_t*& mem ) const213 {214 saveAndIncrease( this->value_.x, mem );215 saveAndIncrease( this->value_.y, mem );216 }217 template <> inline uint8_t MT_Value<Ogre::Vector2>::getSize() const218 {219 return 2*returnSize(this->value_.x);220 }221 // Ogre::Vector3222 template <> inline void MT_Value<Ogre::Vector3>::importData( uint8_t*& mem )223 {224 loadAndIncrease( this->value_.x, mem );225 loadAndIncrease( this->value_.y, mem );226 loadAndIncrease( this->value_.z, mem );227 }228 template <> inline void MT_Value<Ogre::Vector3>::exportData( uint8_t*& mem ) const229 {230 saveAndIncrease( this->value_.x, mem );231 saveAndIncrease( this->value_.y, mem );232 saveAndIncrease( this->value_.z, mem );233 }234 template <> inline uint8_t MT_Value<Ogre::Vector3>::getSize() const235 {236 return 3*returnSize(this->value_.x);237 }238 // Ogre::Vector4239 template <> inline void MT_Value<Ogre::Vector4>::importData( uint8_t*& mem )240 {241 loadAndIncrease( this->value_.x, mem );242 loadAndIncrease( this->value_.y, mem );243 loadAndIncrease( this->value_.z, mem );244 loadAndIncrease( this->value_.w, mem );245 }246 template <> inline void MT_Value<Ogre::Vector4>::exportData( uint8_t*& mem ) const247 {248 saveAndIncrease( this->value_.x, mem );249 saveAndIncrease( this->value_.y, mem );250 saveAndIncrease( this->value_.z, mem );251 saveAndIncrease( this->value_.w, mem );252 }253 template <> inline uint8_t MT_Value<Ogre::Vector4>::getSize() const254 {255 return 4*returnSize(this->value_.x);256 }257 template <> inline void MT_Value<void*>::importData( uint8_t*& mem )258 {259 assert(0);260 }261 template <> inline void MT_Value<void*>::exportData( uint8_t*& mem ) const262 {263 assert(0);264 }265 template <> inline uint8_t MT_Value<void*>::getSize() const266 {267 assert(0); return 0;268 }269 158 } 270 159
Note: See TracChangeset
for help on using the changeset viewer.