Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 23, 2009, 8:19:58 PM (15 years ago)
Author:
scheusso
Message:

synchronisation of pointers to classes that inherit from Synchronisable are now possible
just use the normal registerVariable syntax

Location:
code/branches/presentation2/src/libraries/network/synchronisable
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/src/libraries/network/synchronisable/CMakeLists.txt

    r5781 r6123  
    1010  NetworkCallbackManager.h
    1111  Synchronisable.h
     12  SynchronisablePointer.h
    1213  SynchronisableVariable.h
    1314)
  • code/branches/presentation2/src/libraries/network/synchronisable/Synchronisable.h

    r5929 r6123  
    138138    Synchronisable(BaseObject* creator);
    139139    template <class T> void registerVariable(T& variable, uint8_t mode=0x1, NetworkCallbackBase *cb=0, bool bidirectional=false);
    140     //template <class T> void unregisterVariable(T& var);
    141140    void setPriority(unsigned int freq){ objectFrequency_ = freq; }
    142141
     
    187186    if (bidirectional)
    188187    {
    189       syncList.push_back(new SynchronisableVariableBidirectional<const T>(variable, mode, cb));
     188      syncList.push_back(new SynchronisableVariableBidirectional<T>(variable, mode, cb));
    190189      this->dataSize_ += syncList.back()->getSize(state_);
    191190    }
    192191    else
    193192    {
    194       syncList.push_back(new SynchronisableVariable<const T>(variable, mode, cb));
     193      syncList.push_back(new SynchronisableVariable<T>(variable, mode, cb));
    195194      if ( this->state_ == mode )
    196195        this->dataSize_ += syncList.back()->getSize(state_);
    197196    }
    198197  }
    199  
    200 
    201 
    202 //   template <class T> void Synchronisable::unregisterVariable(T& var){
    203 //     std::vector<SynchronisableVariableBase*>::iterator it = syncList.begin();
    204 //     while(it!=syncList.end()){
    205 //       if( ((*it)->getReference()) == &var ){
    206 //         delete (*it);
    207 //         syncList.erase(it);
    208 //         return;
    209 //       }
    210 //       else
    211 //         it++;
    212 //     }
    213 //     bool unregistered_nonexistent_variable = false;
    214 //     assert(unregistered_nonexistent_variable); //if we reach this point something went wrong:
    215 //     // the variable has not been registered before
    216 //   }
    217198
    218199 
  • code/branches/presentation2/src/libraries/network/synchronisable/SynchronisableVariable.h

    r5781 r6123  
    3535#include <cassert>
    3636#include <cstring>
    37 #include "util/Serialise.h"
     37#include "Serialise.h"
    3838#include "util/TypeTraits.h"
    3939#include "core/GameMode.h"
     
    143143    if ( this->callback_ != 0 )
    144144    {
    145       if( forceCallback || !checkEquality( this->variable_, mem ) )
    146         callback = true;
     145      callback = forceCallback || !checkEquality( this->variable_, mem );
    147146    }
    148147  // write the data
Note: See TracChangeset for help on using the changeset viewer.