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
Files:
4 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
  • code/branches/presentation2/src/libraries/util/Serialise.h

    r5738 r6123  
    4040namespace orxonox{
    4141   
    42 // general template declaration
    43    
    4442    /** @brief returns the size of the variable in a datastream */
    45     template <class T> inline uint32_t returnSize( const T& );
     43    template <class T> inline uint32_t returnSize( const T& variable );
    4644    /** @brief loads the value of a variable out of the bytestream and increases the mem pointer */
    47     template <class T> inline void loadAndIncrease( const T&, uint8_t*& );
     45    template <class T> inline void loadAndIncrease( const T& variable, uint8_t*& mem );
    4846    /** @brief saves the value of a variable into the bytestream and increases the mem pointer */
    49     template <class T> inline void saveAndIncrease( const T&, uint8_t*& );
     47    template <class T> inline void saveAndIncrease( const T& variable, uint8_t*& mem );
    5048    /** @brief checks whether the variable of type T is the same as in the bytestream */
    51     template <class T> inline  bool checkEquality( const T&, uint8_t* );
     49    template <class T> inline bool checkEquality( const T& variable, uint8_t* mem );
    5250
    5351// =================== Template specialisation stuff =============
     
    471469        return variable==Degree(*r);
    472470    }
    473    
    474    
    475471}
    476472
Note: See TracChangeset for help on using the changeset viewer.