Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 30, 2006, 1:50:25 PM (18 years ago)
Author:
rennerc
Message:

finished some SynchronizeableVars classes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/network/src/lib/network/synchronizeable_var/synchronizeable_vector.cc

    r7444 r7459  
    1616
    1717#include "synchronizeable_vector.h"
     18#include "converter.h"
    1819
    1920
     
    2223 * @todo this constructor is not jet implemented - do it
    2324*/
    24 SynchronizeableVector::SynchronizeableVector( Vector * ptrIn, Vector * ptrOut, std::string name, int permission, int priority) : SynchronizeableVar( ptrIn, ptrOut, name, 0, permission, priority )
     25SynchronizeableVector::SynchronizeableVector( Vector * ptrIn, Vector * ptrOut, std::string name, int permission, int priority) : SynchronizeableVar( ptrIn, ptrOut, name, 3*FLOATSIZE, permission, priority )
    2526{
    2627  this->vPtrIn = ptrIn;
     
    4445int SynchronizeableVector::writeToBuf( byte * buf, int maxLength )
    4546{
    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;
    4765}
    4866
     
    5573int SynchronizeableVector::readFromBuf( byte * buf, int maxLength )
    5674{
    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;
    5898}
Note: See TracChangeset for help on using the changeset viewer.