Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 17, 2011, 5:47:22 AM (13 years ago)
Author:
rgrieder
Message:

Stripped down trunk to form a new light sandbox.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/forks/sandbox_light/src/libraries/util/MultiTypeValue.h

    r7401 r7908  
    4343#include "MathConvert.h"
    4444#include "MultiType.h"
    45 #include "Serialise.h"
    4645
    4746namespace orxonox
     
    155154        inline void toString(std::ostream& outstream) const { outstream << this->value_; }
    156155
    157         /// loads data from the bytestream (mem) into the MT and increases the bytestream pointer by the size of the data
    158         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 data
    160         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 exportData
    162         inline uint8_t getSize() const { return returnSize( this->value_ ); }
    163 
    164156        T value_; ///< The stored value
    165157    };
    166 
    167     // Import / Export specialisation
    168     // ColourValue
    169     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 ) const
    177     {
    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() const
    184     {
    185         return 4*returnSize(this->value_.r);
    186     }
    187     // Ogre::Quaternion
    188     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 ) const
    196     {
    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() const
    203     {
    204         return 4*returnSize(this->value_.x);
    205     }
    206     // Ogre::Vector2
    207     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 ) const
    213     {
    214         saveAndIncrease( this->value_.x, mem );
    215         saveAndIncrease( this->value_.y, mem );
    216     }
    217     template <> inline uint8_t MT_Value<Ogre::Vector2>::getSize() const
    218     {
    219         return 2*returnSize(this->value_.x);
    220     }
    221     // Ogre::Vector3
    222     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 ) const
    229     {
    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() const
    235     {
    236         return 3*returnSize(this->value_.x);
    237     }
    238     // Ogre::Vector4
    239     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 ) const
    247     {
    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() const
    254     {
    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 ) const
    262     {
    263         assert(0);
    264     }
    265     template <> inline uint8_t MT_Value<void*>::getSize() const
    266     {
    267         assert(0); return 0;
    268     }
    269158}
    270159
Note: See TracChangeset for help on using the changeset viewer.