Changeset 2990 for code/branches/netp3/src/util
- Timestamp:
- May 19, 2009, 9:35:10 PM (16 years ago)
- Location:
- code/branches/netp3
- Files:
-
- 8 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
code/branches/netp3
- Property svn:mergeinfo changed
/code/branches/netp2 (added) merged: 2835-2836,2861,2937-2938,2940-2941,2943-2945,2947-2949,2951,2953,2964-2965,2974-2976
- Property svn:mergeinfo changed
-
code/branches/netp3/src/util
- Property svn:mergeinfo changed
/code/branches/netp2/src/util (added) merged: 2861,2937,2949
- Property svn:mergeinfo changed
-
code/branches/netp3/src/util/Exception.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/netp3/src/util/Exception.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/netp3/src/util/MultiType.h
r2662 r2990 80 80 enum MT_Type 81 81 { 82 MT_null ,83 MT_char ,84 MT_uchar ,85 MT_short ,86 MT_ushort ,87 MT_int ,88 MT_uint ,89 MT_long ,90 MT_ulong ,91 MT_longlong ,92 MT_ulonglong ,93 MT_float ,94 MT_double ,95 MT_longdouble ,96 MT_bool ,97 MT_void ,98 MT_string ,99 MT_vector2 ,100 MT_vector3 ,101 MT_vector4 ,102 MT_colourvalue ,103 MT_quaternion ,104 MT_radian ,105 MT_degree 82 MT_null=0, 83 MT_char=1, 84 MT_uchar=2, 85 MT_short=3, 86 MT_ushort=4, 87 MT_int=5, 88 MT_uint=6, 89 MT_long=7, 90 MT_ulong=8, 91 MT_longlong=9, 92 MT_ulonglong=10, 93 MT_float=11, 94 MT_double=12, 95 MT_longdouble=13, 96 MT_bool=14, 97 MT_void=15, 98 MT_string=16, 99 MT_vector2=17, 100 MT_vector3=18, 101 MT_vector4=19, 102 MT_colourvalue=20, 103 MT_quaternion=21, 104 MT_radian=22, 105 MT_degree=23 106 106 }; 107 107 … … 223 223 224 224 virtual void toString(std::ostream& outstream) const = 0; 225 226 virtual void importData( uint8_t*& mem )=0; 227 virtual void exportData( uint8_t*& mem ) const=0; 228 virtual uint8_t getSize() const=0; 225 229 226 230 MT_Type type_; //!< The type of the current value … … 320 324 template <typename T> inline bool isType() const { return false; } // Only works for specialized values - see below 321 325 std::string getTypename() const; 326 327 /** @brief Saves the value of the MT to a bytestream (pointed at by mem) and increases mem pointer by size of MT */ 328 inline void exportData(uint8_t*& mem) const { assert(sizeof(MT_Type)<=8); *(uint8_t*)(mem) = this->getType(); mem+=sizeof(uint8_t); this->value_->exportData(mem); } 329 /** @brief Loads the value of the MT from a bytestream (pointed at by mem) and increases mem pointer by size of MT */ 330 inline void importData(uint8_t*& mem) { assert(sizeof(MT_Type)<=8); this->setType(static_cast<MT_Type>(*(uint8_t*)mem)); mem+=sizeof(uint8_t); this->value_->importData(mem); } 331 /** @brief Saves the value of the MT to a bytestream and increases pointer to bytestream by size of MT */ 332 inline uint8_t*& operator << (uint8_t*& mem) { importData(mem); return mem; } 333 /** @brief Loads the value of the MT to a bytestream and increases pointer to bytestream by size of MT */ 334 inline void operator >> (uint8_t*& mem) const { exportData(mem); } 335 inline uint32_t getNetworkSize() const { assert(this->value_); return this->value_->getSize() + sizeof(uint8_t); } 322 336 323 337 /** @brief Checks whether the value is a default one. */ -
code/branches/netp3/src/util/MultiTypeValue.h
r2171 r2990 40 40 #include "MathConvert.h" 41 41 #include "MultiType.h" 42 #include "Serialise.h" 43 #include <cassert> 42 44 43 45 namespace orxonox … … 147 149 /** @brief Puts the current value on the stream */ 148 150 inline void toString(std::ostream& outstream) const { outstream << this->value_; } 151 152 /** @brief loads data from the bytestream (mem) into the MT and increases the bytestream pointer by the size of the data */ 153 inline void importData( uint8_t*& mem ) { loadAndIncrease( /*(const T&)*/this->value_, mem ); } 154 /** @brief saves data from the MT into the bytestream (mem) and increases the bytestream pointer by the size of the data */ 155 inline void exportData( uint8_t*& mem ) const { saveAndIncrease( /*(const T&)*/this->value_, mem ); } 156 /** @brief returns the size of the data that would be saved by exportData */ 157 inline uint8_t getSize() const { return returnSize( this->value_ ); } 149 158 150 159 T value_; //!< The stored value 151 160 }; 161 162 // Import / Export specialisation 163 // ColourValue 164 template <> inline void MT_Value<ColourValue>::importData( uint8_t*& mem ) 165 { 166 loadAndIncrease( this->value_.r, mem ); 167 loadAndIncrease( this->value_.g, mem ); 168 loadAndIncrease( this->value_.b, mem ); 169 loadAndIncrease( this->value_.a, mem ); 170 } 171 template <> inline void MT_Value<ColourValue>::exportData( uint8_t*& mem ) const 172 { 173 saveAndIncrease( this->value_.r, mem ); 174 saveAndIncrease( this->value_.g, mem ); 175 saveAndIncrease( this->value_.b, mem ); 176 saveAndIncrease( this->value_.a, mem ); 177 } 178 template <> inline uint8_t MT_Value<ColourValue>::getSize() const 179 { 180 return 4*returnSize(this->value_.r); 181 } 182 // Ogre::Quaternion 183 template <> inline void MT_Value<Ogre::Quaternion>::importData( uint8_t*& mem ) 184 { 185 loadAndIncrease( this->value_.x, mem ); 186 loadAndIncrease( this->value_.y, mem ); 187 loadAndIncrease( this->value_.z, mem ); 188 loadAndIncrease( this->value_.w, mem ); 189 } 190 template <> inline void MT_Value<Ogre::Quaternion>::exportData( uint8_t*& mem ) const 191 { 192 saveAndIncrease( this->value_.x, mem ); 193 saveAndIncrease( this->value_.y, mem ); 194 saveAndIncrease( this->value_.z, mem ); 195 saveAndIncrease( this->value_.w, mem ); 196 }template <> inline uint8_t MT_Value<Ogre::Quaternion>::getSize() const 197 { 198 return 4*returnSize(this->value_.x); 199 } 200 // Ogre::Vector2 201 template <> inline void MT_Value<Ogre::Vector2>::importData( uint8_t*& mem ) 202 { 203 loadAndIncrease( this->value_.x, mem ); 204 loadAndIncrease( this->value_.y, mem ); 205 } 206 template <> inline void MT_Value<Ogre::Vector2>::exportData( uint8_t*& mem ) const 207 { 208 saveAndIncrease( this->value_.x, mem ); 209 saveAndIncrease( this->value_.y, mem ); 210 } 211 template <> inline uint8_t MT_Value<Ogre::Vector2>::getSize() const 212 { 213 return 2*returnSize(this->value_.x); 214 } 215 // Ogre::Vector3 216 template <> inline void MT_Value<Ogre::Vector3>::importData( uint8_t*& mem ) 217 { 218 loadAndIncrease( this->value_.x, mem ); 219 loadAndIncrease( this->value_.y, mem ); 220 loadAndIncrease( this->value_.z, mem ); 221 } 222 template <> inline void MT_Value<Ogre::Vector3>::exportData( uint8_t*& mem ) const 223 { 224 saveAndIncrease( this->value_.x, mem ); 225 saveAndIncrease( this->value_.y, mem ); 226 saveAndIncrease( this->value_.z, mem ); 227 } 228 template <> inline uint8_t MT_Value<Ogre::Vector3>::getSize() const 229 { 230 return 3*returnSize(this->value_.x); 231 } 232 // Ogre::Vector4 233 template <> inline void MT_Value<Ogre::Vector4>::importData( uint8_t*& mem ) 234 { 235 loadAndIncrease( this->value_.x, mem ); 236 loadAndIncrease( this->value_.y, mem ); 237 loadAndIncrease( this->value_.z, mem ); 238 loadAndIncrease( this->value_.w, mem ); 239 } 240 template <> inline void MT_Value<Ogre::Vector4>::exportData( uint8_t*& mem ) const 241 { 242 saveAndIncrease( this->value_.x, mem ); 243 saveAndIncrease( this->value_.y, mem ); 244 saveAndIncrease( this->value_.z, mem ); 245 saveAndIncrease( this->value_.w, mem ); 246 } 247 template <> inline uint8_t MT_Value<Ogre::Vector4>::getSize() const 248 { 249 return 4*returnSize(this->value_.x); 250 } 251 template <> inline void MT_Value<void*>::importData( uint8_t*& mem ) 252 { 253 assert(0); 254 } 255 template <> inline void MT_Value<void*>::exportData( uint8_t*& mem ) const 256 { 257 assert(0); 258 } 259 template <> inline uint8_t MT_Value<void*>::getSize() const 260 { 261 assert(0); return 0; 262 } 152 263 } 153 264 -
code/branches/netp3/src/util/SignalHandler.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/netp3/src/util/SignalHandler.h
- Property svn:mergeinfo changed (with no actual effect on merging)
Note: See TracChangeset
for help on using the changeset viewer.