Changeset 7459 in orxonox.OLD for branches/network/src
- Timestamp:
- Apr 30, 2006, 1:50:25 PM (19 years ago)
- Location:
- branches/network/src/lib/network
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/network/synchronizeable.cc
r7445 r7459 121 121 void Synchronizeable::varChangeHandler( std::list<int> & id ) 122 122 { 123 #warning implement this124 123 } 125 124 -
branches/network/src/lib/network/synchronizeable_var/synchronizeable_bool.cc
r7446 r7459 43 43 int SynchronizeableBool::writeToBuf( byte * buf, int maxLength ) 44 44 { 45 #warning implement this 45 assert( maxLength >= 1 ); 46 47 buf[0] = ( *vPtrIn ) ? 1 : 0; 48 49 return 1; 46 50 } 47 51 … … 54 58 int SynchronizeableBool::readFromBuf( byte * buf, int maxLength ) 55 59 { 56 #warning implement this 60 assert( maxLength >= 1 ); 61 62 *vPtrOut = buf[0] != 0; 63 64 return 1; 57 65 } -
branches/network/src/lib/network/synchronizeable_var/synchronizeable_bool.h
r7444 r7459 18 18 virtual int readFromBuf( byte * buf, int maxLength ); 19 19 20 /** 21 * check if writeToBuf will return the same size every time 22 * @return true if same size every time 23 */ 24 virtual bool hasStaticSize(){ return true; }; 25 20 26 private: 21 27 bool * vPtrIn; //!< pointer to data (read) -
branches/network/src/lib/network/synchronizeable_var/synchronizeable_float.cc
r7444 r7459 16 16 17 17 #include "synchronizeable_float.h" 18 #include "converter.h" 18 19 19 20 … … 22 23 * @todo this constructor is not jet implemented - do it 23 24 */ 24 SynchronizeableFloat::SynchronizeableFloat( float * ptrIn, float * ptrOut, std::string name, int permission, int priority) : SynchronizeableVar( ptrIn, ptrOut, name, 0, permission, priority )25 SynchronizeableFloat::SynchronizeableFloat( float * ptrIn, float * ptrOut, std::string name, int permission, int priority) : SynchronizeableVar( ptrIn, ptrOut, name, FLOATSIZE, permission, priority ) 25 26 { 26 27 this->vPtrIn = ptrIn; … … 44 45 int SynchronizeableFloat::writeToBuf( byte * buf, int maxLength ) 45 46 { 46 #warning implement this 47 int res = Converter::floatToByteArray( *vPtrIn, buf, maxLength ); 48 49 assert( res == FLOATSIZE ); 50 51 return res; 47 52 } 48 53 … … 55 60 int SynchronizeableFloat::readFromBuf( byte * buf, int maxLength ) 56 61 { 57 #warning implement this 62 assert( maxLength >= FLOATSIZE ); 63 64 int res = Converter::byteArrayToFloat( buf, vPtrOut ); 65 66 assert( res == FLOATSIZE ); 67 68 return res; 58 69 } -
branches/network/src/lib/network/synchronizeable_var/synchronizeable_float.h
r7444 r7459 17 17 virtual int writeToBuf( byte * buf, int maxLength ); 18 18 virtual int readFromBuf( byte * buf, int maxLength ); 19 20 /** 21 * check if writeToBuf will return the same size every time 22 * @return true if same size every time 23 */ 24 virtual bool hasStaticSize(){ return true; }; 19 25 20 26 private: -
branches/network/src/lib/network/synchronizeable_var/synchronizeable_int.cc
r7444 r7459 16 16 17 17 #include "synchronizeable_int.h" 18 #include "converter.h" 18 19 19 20 … … 44 45 int SynchronizeableInt::writeToBuf( byte * buf, int maxLength ) 45 46 { 46 #warning implement this 47 int res = Converter::intToByteArray( *vPtrIn, buf, maxLength ); 48 49 assert( res == INTSIZE ); 50 51 return res; 47 52 } 48 53 … … 55 60 int SynchronizeableInt::readFromBuf( byte * buf, int maxLength ) 56 61 { 57 #warning implement this 62 assert( maxLength >= INTSIZE ); 63 64 int res = Converter::byteArrayToInt( buf, vPtrOut ); 65 66 assert( res == INTSIZE ); 67 68 return res; 58 69 } -
branches/network/src/lib/network/synchronizeable_var/synchronizeable_int.h
r7444 r7459 18 18 virtual int readFromBuf( byte * buf, int maxLength ); 19 19 20 /** 21 * check if writeToBuf will return the same size every time 22 * @return true if same size every time 23 */ 24 virtual bool hasStaticSize(){ return true; }; 25 20 26 private: 21 27 int * vPtrIn; //!< pointer to data (read) -
branches/network/src/lib/network/synchronizeable_var/synchronizeable_quaternion.cc
r7444 r7459 16 16 17 17 #include "synchronizeable_quaternion.h" 18 #include "converter.h" 18 19 19 20 20 21 /** 21 22 * standard constructor 22 * @todo this constructor is not jet implemented - do it 23 */ 24 SynchronizeableQuaternion::SynchronizeableQuaternion( Quaternion * ptrIn, Quaternion * ptrOut, std::string name, int permission, int priority) : SynchronizeableVar( ptrIn, ptrOut, name, 0, permission, priority ) 23 */ 24 SynchronizeableQuaternion::SynchronizeableQuaternion( Quaternion * ptrIn, Quaternion * ptrOut, std::string name, int permission, int priority) : SynchronizeableVar( ptrIn, ptrOut, name, 4*INTSIZE, permission, priority ) 25 25 { 26 26 this->vPtrIn = ptrIn; … … 31 31 /** 32 32 * standard deconstructor 33 */33 */ 34 34 SynchronizeableQuaternion::~SynchronizeableQuaternion () 35 35 { … … 44 44 int SynchronizeableQuaternion::writeToBuf( byte * buf, int maxLength ) 45 45 { 46 #warning implement this 46 int n = 0; 47 int res; 48 49 res = Converter::floatToByteArray( vPtrIn->v.x, buf, maxLength - n ); 50 assert( res > 0 ); 51 n += res; 52 53 res = Converter::floatToByteArray( vPtrIn->v.y, buf, maxLength - n ); 54 assert( res > 0 ); 55 n += res; 56 57 res = Converter::floatToByteArray( vPtrIn->v.z, buf, maxLength - n ); 58 assert( res > 0 ); 59 n += res; 60 61 res = Converter::floatToByteArray( vPtrIn->w, buf, maxLength - n ); 62 assert( res > 0 ); 63 n += res; 64 65 assert( 4*FLOATSIZE == n ); 66 67 return n; 47 68 } 48 69 … … 55 76 int SynchronizeableQuaternion::readFromBuf( byte * buf, int maxLength ) 56 77 { 57 #warning implement this 78 assert( maxLength >= 4*FLOATSIZE ); 79 80 float x,y,z,w; 81 82 int res; 83 int n = 0; 84 85 res += Converter::byteArrayToFloat( buf + n, &x ); 86 assert( res > 0 ); 87 n += res; 88 89 res += Converter::byteArrayToFloat( buf + n, &x ); 90 assert( res > 0 ); 91 n += res; 92 93 res += Converter::byteArrayToFloat( buf + n, &x ); 94 assert( res > 0 ); 95 n += res; 96 97 res += Converter::byteArrayToFloat( buf + n, &w ); 98 assert( res > 0 ); 99 n += res; 100 101 *vPtrOut = Quaternion( Vector(x, y, z), w ); 102 103 assert( res == 4*FLOATSIZE ); 104 return res; 58 105 } -
branches/network/src/lib/network/synchronizeable_var/synchronizeable_quaternion.h
r7444 r7459 19 19 virtual int writeToBuf( byte * buf, int maxLength ); 20 20 virtual int readFromBuf( byte * buf, int maxLength ); 21 22 /** 23 * check if writeToBuf will return the same size every time 24 * @return true if same size every time 25 */ 26 virtual bool hasStaticSize(){ return true; }; 21 27 22 28 private: -
branches/network/src/lib/network/synchronizeable_var/synchronizeable_string.cc
r7444 r7459 16 16 17 17 #include "synchronizeable_string.h" 18 #include "converter.h" 18 19 19 20 … … 44 45 int SynchronizeableString::writeToBuf( byte * buf, int maxLength ) 45 46 { 46 #warning implement this 47 int res = Converter::stringToByteArray( *vPtrIn, buf, maxLength ); 48 49 assert( res > 0 ); 50 51 return res; 47 52 } 48 53 … … 55 60 int SynchronizeableString::readFromBuf( byte * buf, int maxLength ) 56 61 { 57 #warning implement this 62 int res = Converter::byteArrayToString( buf, *vPtrOut, maxLength ); 63 64 assert( res > 0 ); 65 66 return res; 58 67 } -
branches/network/src/lib/network/synchronizeable_var/synchronizeable_string.h
r7444 r7459 20 20 virtual int readFromBuf( byte * buf, int maxLength ); 21 21 22 23 /** 24 * check if writeToBuf will return the same size every time 25 * @return true if same size every time 26 */ 27 virtual bool hasStaticSize(){ return false; }; 28 22 29 private: 23 30 std::string * vPtrIn; //!< pointer to data (read) -
branches/network/src/lib/network/synchronizeable_var/synchronizeable_var.cc
r7444 r7459 24 24 SynchronizeableVar::SynchronizeableVar ( void * ptrIn, void * ptrOut, std::string name, int length, int permission, int priority) 25 25 { 26 assert( ptrIn ); 27 assert( ptrOut ); 28 26 29 this->ptrIn = ptrIn; 27 30 this->ptrOut = ptrOut; … … 41 44 } 42 45 43 /**44 * write var data to byte buffer45 * @param buf pointer to write to46 * @param maxLength writeToBuf will not write more than maxLength bytes47 * @return number bytes written48 */49 int SynchronizeableVar::writeToBuf( byte * buf, int maxLength )50 {51 #warning implement this52 }53 54 /**55 * read var data from byte buffer56 * @param buf pointer to read from57 * @param maxLength readFromBuf will not read more than maxLength bytes58 * @return number bytes read59 */60 int SynchronizeableVar::readFromBuf( byte * buf, int maxLength )61 {62 #warning implement this63 } -
branches/network/src/lib/network/synchronizeable_var/synchronizeable_var.h
r7444 r7459 22 22 inline bool beWatched(){ return this->bWatched; } 23 23 24 virtual int writeToBuf( byte * buf, int maxLength ); 25 virtual int readFromBuf( byte * buf, int maxLength ); 24 /** 25 * write var data to byte buffer 26 * @param buf pointer to write to 27 * @param maxLength writeToBuf will not write more than maxLength bytes 28 * @return number bytes written 29 */ 30 virtual int writeToBuf( byte * buf, int maxLength ) = 0; 31 32 /** 33 * read var data from byte buffer 34 * @param buf pointer to read from 35 * @param maxLength readFromBuf will not read more than maxLength bytes 36 * @return number bytes read 37 */ 38 virtual int readFromBuf( byte * buf, int maxLength ) = 0; 39 40 /** 41 * check if writeToBuf will return the same size every time 42 * @return true if same size every time 43 */ 44 virtual bool hasStaticSize() = 0; 26 45 27 46 /** -
branches/network/src/lib/network/synchronizeable_var/synchronizeable_vector.cc
r7444 r7459 16 16 17 17 #include "synchronizeable_vector.h" 18 #include "converter.h" 18 19 19 20 … … 22 23 * @todo this constructor is not jet implemented - do it 23 24 */ 24 SynchronizeableVector::SynchronizeableVector( Vector * ptrIn, Vector * ptrOut, std::string name, int permission, int priority) : SynchronizeableVar( ptrIn, ptrOut, name, 0, permission, priority )25 SynchronizeableVector::SynchronizeableVector( Vector * ptrIn, Vector * ptrOut, std::string name, int permission, int priority) : SynchronizeableVar( ptrIn, ptrOut, name, 3*FLOATSIZE, permission, priority ) 25 26 { 26 27 this->vPtrIn = ptrIn; … … 44 45 int SynchronizeableVector::writeToBuf( byte * buf, int maxLength ) 45 46 { 46 #warning implement this 47 int n = 0; 48 int res; 49 50 res = Converter::floatToByteArray( vPtrIn->x, buf, maxLength - n ); 51 assert( res > 0 ); 52 n += res; 53 54 res = Converter::floatToByteArray( vPtrIn->y, buf, maxLength - n ); 55 assert( res > 0 ); 56 n += res; 57 58 res = Converter::floatToByteArray( vPtrIn->z, buf, maxLength - n ); 59 assert( res > 0 ); 60 n += res; 61 62 assert( 3*FLOATSIZE == n ); 63 64 return n; 47 65 } 48 66 … … 55 73 int SynchronizeableVector::readFromBuf( byte * buf, int maxLength ) 56 74 { 57 #warning implement this 75 assert( maxLength >= 3*FLOATSIZE ); 76 77 float x,y,z; 78 79 int res; 80 int n = 0; 81 82 res += Converter::byteArrayToFloat( buf + n, &x ); 83 assert( res > 0 ); 84 n += res; 85 86 res += Converter::byteArrayToFloat( buf + n, &x ); 87 assert( res > 0 ); 88 n += res; 89 90 res += Converter::byteArrayToFloat( buf + n, &x ); 91 assert( res > 0 ); 92 n += res; 93 94 *vPtrOut = Vector( x, y, z ); 95 96 assert( res == 3*FLOATSIZE ); 97 return res; 58 98 } -
branches/network/src/lib/network/synchronizeable_var/synchronizeable_vector.h
r7444 r7459 20 20 virtual int readFromBuf( byte * buf, int maxLength ); 21 21 22 /** 23 * check if writeToBuf will return the same size every time 24 * @return true if same size every time 25 */ 26 virtual bool hasStaticSize(){ return true; }; 27 22 28 private: 23 29 Vector * vPtrIn; //!< pointer to data (read)
Note: See TracChangeset
for help on using the changeset viewer.