Changeset 7559 in orxonox.OLD for branches/network/src/lib/network/synchronizeable_var
- Timestamp:
- May 10, 2006, 12:11:43 AM (18 years ago)
- Location:
- branches/network/src/lib/network/synchronizeable_var
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/network/synchronizeable_var/synchronizeable_quaternion.cc
r7459 r7559 46 46 int n = 0; 47 47 int res; 48 49 res = Converter::floatToByteArray( vPtrIn->v.x, buf , maxLength - n );48 49 res = Converter::floatToByteArray( vPtrIn->v.x, buf + n, maxLength - n ); 50 50 assert( res > 0 ); 51 51 n += res; 52 53 res = Converter::floatToByteArray( vPtrIn->v.y, buf , maxLength - n );52 53 res = Converter::floatToByteArray( vPtrIn->v.y, buf + n, maxLength - n ); 54 54 assert( res > 0 ); 55 55 n += res; 56 57 res = Converter::floatToByteArray( vPtrIn->v.z, buf , maxLength - n );56 57 res = Converter::floatToByteArray( vPtrIn->v.z, buf + n, maxLength - n ); 58 58 assert( res > 0 ); 59 59 n += res; 60 61 res = Converter::floatToByteArray( vPtrIn->w, buf , maxLength - n );60 61 res = Converter::floatToByteArray( vPtrIn->w, buf + n, maxLength - n ); 62 62 assert( res > 0 ); 63 63 n += res; 64 64 65 65 assert( 4*FLOATSIZE == n ); 66 66 67 67 return n; 68 68 } … … 77 77 { 78 78 assert( maxLength >= 4*FLOATSIZE ); 79 79 80 80 float x,y,z,w; 81 81 82 82 int res; 83 83 int n = 0; 84 84 85 85 res += Converter::byteArrayToFloat( buf + n, &x ); 86 86 assert( res > 0 ); 87 87 n += res; 88 88 89 89 res += Converter::byteArrayToFloat( buf + n, &x ); 90 90 assert( res > 0 ); 91 91 n += res; 92 92 93 93 res += Converter::byteArrayToFloat( buf + n, &x ); 94 94 assert( res > 0 ); 95 95 n += res; 96 96 97 97 res += Converter::byteArrayToFloat( buf + n, &w ); 98 98 assert( res > 0 ); 99 99 n += res; 100 100 101 101 *vPtrOut = Quaternion( Vector(x, y, z), w ); 102 102 103 103 assert( res == 4*FLOATSIZE ); 104 104 return res; -
branches/network/src/lib/network/synchronizeable_var/synchronizeable_var.cc
r7459 r7559 18 18 19 19 20 20 21 /** 21 22 * standard constructor … … 26 27 assert( ptrIn ); 27 28 assert( ptrOut ); 28 29 29 30 this->ptrIn = ptrIn; 30 31 this->ptrOut = ptrOut; … … 32 33 this->permission = permission; 33 34 this->priority = priority; 34 this->real _priority = priority;35 this->realPriority = priority; 35 36 this->name = name; 36 37 } -
branches/network/src/lib/network/synchronizeable_var/synchronizeable_var.h
r7508 r7559 9 9 #include <string> 10 10 #include "netdefs.h" 11 #include <assert.h> 11 12 12 13 class SynchronizeableVar { … … 15 16 SynchronizeableVar( void * ptrIn, void * ptrOut, std::string name, int length, int permission = 0, int priority = 0 ); 16 17 virtual ~SynchronizeableVar(); 17 18 18 19 /** 19 20 * check if synchronizeable wants to be informed on changes … … 21 22 */ 22 23 inline bool beWatched(){ return this->bWatched; } 23 24 24 25 /** 25 26 * write var data to byte buffer … … 29 30 */ 30 31 virtual int writeToBuf( byte * buf, int maxLength ) = 0; 31 32 32 33 /** 33 34 * read var data from byte buffer … … 37 38 */ 38 39 virtual int readFromBuf( byte * buf, int maxLength ) = 0; 39 40 40 41 /** 41 42 * check if writeToBuf will return the same size every time … … 43 44 */ 44 45 virtual bool hasStaticSize() = 0; 45 46 46 47 /** 47 48 * get size writeToBuf needs … … 49 50 */ 50 51 virtual int getSize(){ return length; } 51 52 52 53 /** 53 54 * check for permission to write … … 55 56 */ 56 57 inline bool checkPremission( int permission ){ return (permission & this->permission) != 0; } 57 58 58 59 /** 59 60 * get variable name … … 61 62 */ 62 63 inline std::string getName(){ return name; } 63 64 64 65 /** 65 66 * set variable name … … 67 68 */ 68 69 inline void setName( std::string name ) { this->name = name; } 69 70 70 71 /** 71 72 * get priority … … 73 74 */ 74 75 inline int getPriority() { return this->priority; } 75 76 76 77 /** 77 78 * set priority … … 79 80 */ 80 81 inline void setPriority( int p ) { this->priority = p; } 81 82 82 83 /** 83 84 * reset priority to variable specific default value 84 85 */ 85 inline void resetPriority() { this->priority = this->real _priority; }86 inline void resetPriority() { this->priority = this->realPriority; } 86 87 87 88 … … 95 96 int permission; //!< who is allowed to change this var 96 97 int priority; //!< priority assigned to var 97 int real _priority; //!< priority assigned to var, increased every time not sent98 99 98 int realPriority; //!< priority assigned to var, increased every time not sent 99 100 100 101 std::string name; //!< variable name (for debugging) 101 102 -
branches/network/src/lib/network/synchronizeable_var/synchronizeable_vector.cc
r7459 r7559 47 47 int n = 0; 48 48 int res; 49 50 res = Converter::floatToByteArray( vPtrIn->x, buf , maxLength - n );49 50 res = Converter::floatToByteArray( vPtrIn->x, buf + n, maxLength - n ); 51 51 assert( res > 0 ); 52 52 n += res; 53 54 res = Converter::floatToByteArray( vPtrIn->y, buf , maxLength - n );53 54 res = Converter::floatToByteArray( vPtrIn->y, buf + n, maxLength - n ); 55 55 assert( res > 0 ); 56 56 n += res; 57 58 res = Converter::floatToByteArray( vPtrIn->z, buf , maxLength - n );57 58 res = Converter::floatToByteArray( vPtrIn->z, buf + n, maxLength - n ); 59 59 assert( res > 0 ); 60 60 n += res; 61 61 62 62 assert( 3*FLOATSIZE == n ); 63 63 64 64 return n; 65 65 } … … 74 74 { 75 75 assert( maxLength >= 3*FLOATSIZE ); 76 76 77 77 float x,y,z; 78 78 79 79 int res; 80 80 int n = 0; 81 81 82 82 res += Converter::byteArrayToFloat( buf + n, &x ); 83 83 assert( res > 0 ); 84 84 n += res; 85 85 86 86 res += Converter::byteArrayToFloat( buf + n, &x ); 87 87 assert( res > 0 ); 88 88 n += res; 89 89 90 90 res += Converter::byteArrayToFloat( buf + n, &x ); 91 91 assert( res > 0 ); 92 92 n += res; 93 93 94 94 *vPtrOut = Vector( x, y, z ); 95 95 96 96 assert( res == 3*FLOATSIZE ); 97 97 return res;
Note: See TracChangeset
for help on using the changeset viewer.