Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 28, 2009, 11:19:06 PM (16 years ago)
Author:
scheusso
Message:
  • moved serialise functions from SynchronisableVariableSpecialisation.cc

to util/Serialise.h

  • made MultiType serialisable (use functions importData/exportData or

operator << / >> )

Location:
code/branches/netp2/src/network/synchronisable
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/netp2/src/network/synchronisable/SynchronisableSpecialisations.cc

    r2836 r2861  
    7171    registerVariable(variable.y, mode, cb, bidirectional);
    7272  }
    73   template <> void Synchronisable::registerVariable( Vector2& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
    74   {
    75     registerVariable( (const ColourValue&)variable, mode, cb, bidirectional);
    76   }
     73//   template <> void Synchronisable::registerVariable( Vector2& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
     74//   {
     75//     registerVariable( (const ColourValue&)variable, mode, cb, bidirectional);
     76//   }
    7777 
    7878  template <> void Synchronisable::registerVariable( const Vector3& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional)
  • code/branches/netp2/src/network/synchronisable/SynchronisableVariable.h

    r2836 r2861  
    2121 *
    2222 *   Author:
    23  *      Oliver Scheuss, (C) 2008
     23 *      Oliver Scheuss
    2424 *   Co-authors:
    2525 *      ...
     
    3535#include <string>
    3636#include <cassert>
     37#include "util/Serialise.h"
    3738#include "core/Core.h"
    3839#include "core/CoreIncludes.h"
     
    7980      virtual inline void* getReference(){ return (void *)&this->variable_; }
    8081    protected:
    81       inline bool checkEquality(uint8_t* mem);
    82       inline void setAndIncrease(uint8_t*& mem);
    83       inline void getAndIncrease(uint8_t*& mem);
    84       inline uint32_t returnSize();
     82//       inline bool checkEquality(uint8_t* mem);
     83//       inline void loadAndIncrease(uint8_t*& mem);
     84//       inline void saveAndIncrease(uint8_t*& mem);
     85//       inline uint32_t returnSize();
    8586     
    8687      T& variable_;
     
    126127    if ( state_ == this->mode_ )
    127128    {
    128       getAndIncrease( mem );
    129       return returnSize();
     129      saveAndIncrease( this->variable_, mem );
     130      return returnSize( this->variable_ );
    130131    }
    131132    else
     
    143144    if ( this->callback_ != 0 )
    144145    {
    145       if( forceCallback || !checkEquality( mem ) )
     146      if( forceCallback || !checkEquality( this->variable_, mem ) )
    146147        callback = true;
    147148    }
    148149  // write the data
    149     setAndIncrease( mem );
     150    loadAndIncrease( this->variable_, mem );
    150151  // now do a callback if neccessary
    151152    if ( callback )
     
    156157  {
    157158    if ( mode == this->mode_ )
    158       return returnSize();
     159      return returnSize( this->variable_ );
    159160    else
    160161      return 0;
    161162  }
    162163
    163   template <> _NetworkExport uint32_t SynchronisableVariable<const bool>::returnSize();
    164   template <> _NetworkExport void     SynchronisableVariable<const bool>::setAndIncrease(uint8_t*& mem);
    165   template <> _NetworkExport void     SynchronisableVariable<const bool>::getAndIncrease(uint8_t*& mem);
     164  /*template <> _NetworkExport uint32_t SynchronisableVariable<const bool>::returnSize();
     165  template <> _NetworkExport void     SynchronisableVariable<const bool>::loadAndIncrease(uint8_t*& mem);
     166  template <> _NetworkExport void     SynchronisableVariable<const bool>::saveAndIncrease(uint8_t*& mem);
    166167  template <> _NetworkExport bool     SynchronisableVariable<const bool>::checkEquality(uint8_t* mem);
    167168  template <> _NetworkExport uint32_t SynchronisableVariable<const unsigned char>::returnSize();
    168   template <> _NetworkExport void     SynchronisableVariable<const unsigned char>::setAndIncrease(uint8_t*& mem);
    169   template <> _NetworkExport void     SynchronisableVariable<const unsigned char>::getAndIncrease(uint8_t*& mem);
     169  template <> _NetworkExport void     SynchronisableVariable<const unsigned char>::loadAndIncrease(uint8_t*& mem);
     170  template <> _NetworkExport void     SynchronisableVariable<const unsigned char>::saveAndIncrease(uint8_t*& mem);
    170171  template <> _NetworkExport bool     SynchronisableVariable<const unsigned char>::checkEquality(uint8_t* mem);
    171172  template <> _NetworkExport uint32_t SynchronisableVariable<const short>::returnSize();
    172   template <> _NetworkExport void     SynchronisableVariable<const short>::setAndIncrease(uint8_t*& mem);
    173   template <> _NetworkExport void     SynchronisableVariable<const short>::getAndIncrease(uint8_t*& mem);
     173  template <> _NetworkExport void     SynchronisableVariable<const short>::loadAndIncrease(uint8_t*& mem);
     174  template <> _NetworkExport void     SynchronisableVariable<const short>::saveAndIncrease(uint8_t*& mem);
    174175  template <> _NetworkExport bool     SynchronisableVariable<const short>::checkEquality(uint8_t* mem);
    175176  template <> _NetworkExport uint32_t SynchronisableVariable<const unsigned short>::returnSize();
    176   template <> _NetworkExport void     SynchronisableVariable<const unsigned short>::setAndIncrease(uint8_t*& mem);
    177   template <> _NetworkExport void     SynchronisableVariable<const unsigned short>::getAndIncrease(uint8_t*& mem);
     177  template <> _NetworkExport void     SynchronisableVariable<const unsigned short>::loadAndIncrease(uint8_t*& mem);
     178  template <> _NetworkExport void     SynchronisableVariable<const unsigned short>::saveAndIncrease(uint8_t*& mem);
    178179  template <> _NetworkExport bool     SynchronisableVariable<const unsigned short>::checkEquality(uint8_t* mem);
    179180  template <> _NetworkExport uint32_t SynchronisableVariable<const int>::returnSize();
    180   template <> _NetworkExport void     SynchronisableVariable<const int>::setAndIncrease(uint8_t*& mem);
    181   template <> _NetworkExport void     SynchronisableVariable<const int>::getAndIncrease(uint8_t*& mem);
     181  template <> _NetworkExport void     SynchronisableVariable<const int>::loadAndIncrease(uint8_t*& mem);
     182  template <> _NetworkExport void     SynchronisableVariable<const int>::saveAndIncrease(uint8_t*& mem);
    182183  template <> _NetworkExport bool     SynchronisableVariable<const int>::checkEquality(uint8_t* mem);
    183184  template <> _NetworkExport uint32_t SynchronisableVariable<const unsigned int>::returnSize();
    184   template <> _NetworkExport void     SynchronisableVariable<const unsigned int>::setAndIncrease(uint8_t*& mem);
    185   template <> _NetworkExport void     SynchronisableVariable<const unsigned int>::getAndIncrease(uint8_t*& mem);
     185  template <> _NetworkExport void     SynchronisableVariable<const unsigned int>::loadAndIncrease(uint8_t*& mem);
     186  template <> _NetworkExport void     SynchronisableVariable<const unsigned int>::saveAndIncrease(uint8_t*& mem);
    186187  template <> _NetworkExport bool     SynchronisableVariable<const unsigned int>::checkEquality(uint8_t* mem);
    187188  template <> _NetworkExport uint32_t SynchronisableVariable<const long>::returnSize();
    188   template <> _NetworkExport void     SynchronisableVariable<const long>::setAndIncrease(uint8_t*& mem);
    189   template <> _NetworkExport void     SynchronisableVariable<const long>::getAndIncrease(uint8_t*& mem);
     189  template <> _NetworkExport void     SynchronisableVariable<const long>::loadAndIncrease(uint8_t*& mem);
     190  template <> _NetworkExport void     SynchronisableVariable<const long>::saveAndIncrease(uint8_t*& mem);
    190191  template <> _NetworkExport bool     SynchronisableVariable<const long>::checkEquality(uint8_t* mem);
    191192  template <> _NetworkExport uint32_t SynchronisableVariable<const unsigned long>::returnSize();
    192   template <> _NetworkExport void     SynchronisableVariable<const unsigned long>::setAndIncrease(uint8_t*& mem);
    193   template <> _NetworkExport void     SynchronisableVariable<const unsigned long>::getAndIncrease(uint8_t*& mem);
     193  template <> _NetworkExport void     SynchronisableVariable<const unsigned long>::loadAndIncrease(uint8_t*& mem);
     194  template <> _NetworkExport void     SynchronisableVariable<const unsigned long>::saveAndIncrease(uint8_t*& mem);
    194195  template <> _NetworkExport bool     SynchronisableVariable<const unsigned long>::checkEquality(uint8_t* mem);
    195196  template <> _NetworkExport uint32_t SynchronisableVariable<const long long>::returnSize();
    196   template <> _NetworkExport void     SynchronisableVariable<const long long>::setAndIncrease(uint8_t*& mem);
    197   template <> _NetworkExport void     SynchronisableVariable<const long long>::getAndIncrease(uint8_t*& mem);
     197  template <> _NetworkExport void     SynchronisableVariable<const long long>::loadAndIncrease(uint8_t*& mem);
     198  template <> _NetworkExport void     SynchronisableVariable<const long long>::saveAndIncrease(uint8_t*& mem);
    198199  template <> _NetworkExport bool     SynchronisableVariable<const long long>::checkEquality(uint8_t* mem);
    199200  template <> _NetworkExport uint32_t SynchronisableVariable<const unsigned long long>::returnSize();
    200   template <> _NetworkExport void     SynchronisableVariable<const unsigned long long>::setAndIncrease(uint8_t*& mem);
    201   template <> _NetworkExport void     SynchronisableVariable<const unsigned long long>::getAndIncrease(uint8_t*& mem);
     201  template <> _NetworkExport void     SynchronisableVariable<const unsigned long long>::loadAndIncrease(uint8_t*& mem);
     202  template <> _NetworkExport void     SynchronisableVariable<const unsigned long long>::saveAndIncrease(uint8_t*& mem);
    202203  template <> _NetworkExport bool     SynchronisableVariable<const unsigned long long>::checkEquality(uint8_t* mem);
    203204  template <> _NetworkExport uint32_t SynchronisableVariable<const float>::returnSize();
    204   template <> _NetworkExport void     SynchronisableVariable<const float>::setAndIncrease(uint8_t*& mem);
    205   template <> _NetworkExport void     SynchronisableVariable<const float>::getAndIncrease(uint8_t*& mem);
     205  template <> _NetworkExport void     SynchronisableVariable<const float>::loadAndIncrease(uint8_t*& mem);
     206  template <> _NetworkExport void     SynchronisableVariable<const float>::saveAndIncrease(uint8_t*& mem);
    206207  template <> _NetworkExport bool     SynchronisableVariable<const float>::checkEquality(uint8_t* mem);
    207208  template <> _NetworkExport uint32_t SynchronisableVariable<const double>::returnSize();
    208   template <> _NetworkExport void     SynchronisableVariable<const double>::setAndIncrease(uint8_t*& mem);
    209   template <> _NetworkExport void     SynchronisableVariable<const double>::getAndIncrease(uint8_t*& mem);
     209  template <> _NetworkExport void     SynchronisableVariable<const double>::loadAndIncrease(uint8_t*& mem);
     210  template <> _NetworkExport void     SynchronisableVariable<const double>::saveAndIncrease(uint8_t*& mem);
    210211  template <> _NetworkExport bool     SynchronisableVariable<const double>::checkEquality(uint8_t* mem);
    211212  template <> _NetworkExport uint32_t SynchronisableVariable<const long double>::returnSize();
    212   template <> _NetworkExport void     SynchronisableVariable<const long double>::setAndIncrease(uint8_t*& mem);
    213   template <> _NetworkExport void     SynchronisableVariable<const long double>::getAndIncrease(uint8_t*& mem);
     213  template <> _NetworkExport void     SynchronisableVariable<const long double>::loadAndIncrease(uint8_t*& mem);
     214  template <> _NetworkExport void     SynchronisableVariable<const long double>::saveAndIncrease(uint8_t*& mem);
    214215  template <> _NetworkExport bool     SynchronisableVariable<const long double>::checkEquality(uint8_t* mem);
    215216  template <> _NetworkExport uint32_t SynchronisableVariable<const std::string>::returnSize();
    216   template <> _NetworkExport void     SynchronisableVariable<const std::string>::setAndIncrease(uint8_t*& mem);
    217   template <> _NetworkExport void     SynchronisableVariable<const std::string>::getAndIncrease(uint8_t*& mem);
     217  template <> _NetworkExport void     SynchronisableVariable<const std::string>::loadAndIncrease(uint8_t*& mem);
     218  template <> _NetworkExport void     SynchronisableVariable<const std::string>::saveAndIncrease(uint8_t*& mem);
    218219  template <> _NetworkExport bool     SynchronisableVariable<const std::string>::checkEquality(uint8_t* mem);
    219220  template <> _NetworkExport uint32_t SynchronisableVariable<const Degree>::returnSize();
    220   template <> _NetworkExport void     SynchronisableVariable<const Degree>::setAndIncrease(uint8_t*& mem);
    221   template <> _NetworkExport void     SynchronisableVariable<const Degree>::getAndIncrease(uint8_t*& mem);
    222   template <> _NetworkExport bool     SynchronisableVariable<const Degree>::checkEquality(uint8_t* mem);
     221  template <> _NetworkExport void     SynchronisableVariable<const Degree>::loadAndIncrease(uint8_t*& mem);
     222  template <> _NetworkExport void     SynchronisableVariable<const Degree>::saveAndIncrease(uint8_t*& mem);
     223  template <> _NetworkExport bool     SynchronisableVariable<const Degree>::checkEquality(uint8_t* mem);*/
    223224
    224225
     
    249250      mem += sizeof(this->varReference_);
    250251  // now write the content
    251       SynchronisableVariable<T>::getAndIncrease( mem );
     252      saveAndIncrease( this->variable_, mem );
    252253//   mem += SynchronisableVariable<T>::getSize();
    253254      return SynchronisableVariableBidirectional::getSize(mode);
     
    268269          // apply data
    269270          mem += sizeof(varReference_);
    270           if ( SynchronisableVariableBidirectional<T>::checkEquality( mem )==true )
     271          if ( checkEquality( this->variable_, mem )==true )
    271272          {
    272             mem += SynchronisableVariable<T>::getSize( mode );
     273            mem += getSize( mode );
    273274            return;
    274275          }
     
    292293          this->varReference_ = *static_cast<uint8_t*>(mem);
    293294          mem += sizeof(varReference_);
    294           if ( SynchronisableVariable<T>::checkEquality( mem ) == false )
     295          if ( checkEquality( this->variable_, mem ) == false )
    295296          {
    296297            // value changed so remark for callback
     
    301302      }
    302303  // now write the data
    303       SynchronisableVariable<T>::setAndIncrease(mem);
     304      loadAndIncrease(this->variable_, mem);
    304305  // now do a callback if neccessary
    305306      if ( callback )
     
    310311    template <class T> inline uint32_t SynchronisableVariableBidirectional<T>::getSize(uint8_t mode)
    311312    {
    312       return SynchronisableVariable<T>::returnSize() + sizeof(varReference_);
     313      return returnSize( this->variable_ ) + sizeof(varReference_);
    313314    }
    314315 
     
    316317}
    317318
    318 #include "network/synchronisable/SynchronisableVariableSpecialisations.h"
     319//#include "network/synchronisable/SynchronisableVariableSpecialisations.h"
    319320
    320321#endif
Note: See TracChangeset for help on using the changeset viewer.