Changeset 2710 for code/trunk/src/network/synchronisable
- Timestamp:
- Feb 28, 2009, 7:46:37 PM (16 years ago)
- Location:
- code/trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:ignore deleted
- Property svn:mergeinfo changed
-
code/trunk/src/network/synchronisable/CMakeLists.txt
r2662 r2710 1 SET(SRC_FILES1 ADD_SOURCE_FILES(NETWORK_SRC_FILES 2 2 NetworkCallbackManager.cc 3 3 Synchronisable.cc … … 5 5 SynchronisableVariable.cc 6 6 ) 7 8 ADD_SOURCE_FILES(SRC_FILES) -
code/trunk/src/network/synchronisable/NetworkCallback.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/network/synchronisable/Synchronisable.cc
- Property svn:mergeinfo changed
/code/branches/buildsystem3/src/network/synchronisable/Synchronisable.cc (added) merged: 2706
r2662 r2710 236 236 return NULL; 237 237 } 238 239 240 /**241 * This function is used to register a variable to be synchronized242 * also counts the total datasize needed to save the variables243 * @param var pointer to the variable244 * @param size size of the datatype the variable consists of245 * @param t the type of the variable (DATA or STRING246 * @param mode same as in getData247 * @param cb callback object that should get called, if the value of the variable changes248 */249 250 /* void Synchronisable::registerVariable(void *var, int size, variableType t, uint8_t mode, NetworkCallbackBase *cb){251 assert( mode==variableDirection::toclient || mode==variableDirection::toserver || mode==variableDirection::serverMaster || mode==variableDirection::clientMaster);252 // create temporary synch.Var struct253 synchronisableVariable *temp = new synchronisableVariable;254 temp->size = size;255 temp->var = var;256 temp->mode = mode;257 temp->type = t;258 temp->callback = cb;259 if( ( mode & variableDirection::bidirectional ) )260 {261 if(t!=STRING)262 {263 temp->varBuffer = new uint8_t[size];264 memcpy(temp->varBuffer, temp->var, size); //now fill the buffer for the first time265 }266 else267 {268 temp->varBuffer=new std::string( *static_cast<std::string*>(var) );269 }270 temp->varReference = 0;271 }272 COUT(5) << "Syncronisable::registering var with size: " << temp->size << " and type: " << temp->type << std::endl;273 //std::cout << "push temp to syncList (at the bottom) " << datasize << std::endl;274 COUT(5) << "Syncronisable::objectID: " << objectID << " this: " << this << " name: " << this->getIdentifier()->getName() << " networkID: " << this->getIdentifier()->getNetworkID() << std::endl;275 syncList->push_back(temp);276 #ifndef NDEBUG277 std::list<synchronisableVariable *>::iterator it = syncList->begin();278 while(it!=syncList->end()){279 assert(*it!=var);280 it++;281 }282 #endif283 }*/284 238 285 239 - Property svn:mergeinfo changed
-
code/trunk/src/network/synchronisable/Synchronisable.h
- Property svn:mergeinfo changed
/code/branches/buildsystem3/src/network/synchronisable/Synchronisable.h (added) merged: 2671
r2662 r2710 153 153 uint32_t getSize(int32_t id, uint8_t mode=0x0); 154 154 bool updateData(uint8_t*& mem, uint8_t mode=0x0, bool forceCallback=false); 155 inlinebool isMyData(uint8_t* mem);156 inlinebool doSync(int32_t id, uint8_t mode=0x0);155 bool isMyData(uint8_t* mem); 156 bool doSync(int32_t id, uint8_t mode=0x0); 157 157 158 158 uint32_t objectID; - Property svn:mergeinfo changed
-
code/trunk/src/network/synchronisable/SynchronisableVariable.cc
r2662 r2710 362 362 { 363 363 double temp; 364 *(uint64_t*)(&temp) = *(uint64_t*)(mem);364 memcpy(&temp, mem, sizeof(uint64_t)); 365 365 *(long double*)(&this->variable_) = static_cast<const long double>(temp); 366 366 mem += SynchronisableVariable<const long double>::returnSize(); … … 370 370 { 371 371 double temp = static_cast<double>(this->variable_); 372 *(uint64_t*)(mem) = *(uint64_t*)(&temp);372 memcpy(mem, &temp, sizeof(uint64_t)); 373 373 mem += SynchronisableVariable<const long double>::returnSize(); 374 374 } … … 377 377 { 378 378 double temp = static_cast<double>(this->variable_); 379 return *(uint64_t*)(mem) == *(uint64_t*)(&temp);379 return memcmp(&temp, mem, sizeof(uint64_t))==0; 380 380 } 381 381 -
code/trunk/src/network/synchronisable/SynchronisableVariable.h
r2662 r2710 35 35 #include <string> 36 36 #include <cassert> 37 #include "util/Integers.h"38 37 #include "core/Core.h" 39 38 #include "core/CoreIncludes.h"
Note: See TracChangeset
for help on using the changeset viewer.