dataProxy.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "dataProxy.h"
00019 #include "client.h"
00020
00021 namespace eqNbody
00022 {
00023
00024 DataProxy::DataProxy() : _offset(0), _numBytes(0)
00025 {
00026 _hPos = NULL;
00027 _hVel = NULL;
00028 _hCol = NULL;
00029 }
00030
00031 void DataProxy::serialize( eq::net::DataOStream& os, const uint64_t dirtyBits )
00032 {
00033 eq::Object::serialize( os, dirtyBits );
00034
00035 if( dirtyBits & DIRTY_DATA ) {
00036 os << _offset << _numBytes;
00037
00038 EQASSERT(_hPos != NULL);
00039 EQASSERT(_hVel != NULL);
00040
00041 os.write(_hPos+_offset, _numBytes);
00042 os.write(_hVel+_offset, _numBytes);
00043
00044 }
00045 }
00046
00047 void DataProxy::deserialize( eq::net::DataIStream& is, const uint64_t dirtyBits )
00048 {
00049 eq::Object::deserialize( is, dirtyBits );
00050
00051 if( dirtyBits & DIRTY_DATA ) {
00052 is >> _offset >> _numBytes;
00053
00054 EQASSERT(_hPos != NULL);
00055 EQASSERT(_hVel != NULL);
00056
00057 is.read(_hPos+_offset, _numBytes);
00058 is.read(_hVel+_offset, _numBytes);
00059
00060 }
00061 }
00062
00063 void DataProxy::init(const unsigned int offset, const unsigned int numBytes, float *pos, float *vel, float *col)
00064 {
00065 _offset = offset;
00066 _numBytes = numBytes;
00067
00068 _hPos = pos;
00069 _hVel = vel;
00070 _hCol = col;
00071
00072 setDirty( DIRTY_DATA );
00073 }
00074
00075 void DataProxy::init(float *pos, float *vel, float *col)
00076 {
00077 _hPos = pos;
00078 _hVel = vel;
00079 _hCol = col;
00080
00081 setDirty( DIRTY_DATA );
00082 }
00083
00084 void DataProxy::exit()
00085 {
00086 _offset = 0;
00087 _numBytes = 0;
00088
00089 _hPos = NULL;
00090 _hVel = NULL;
00091 _hCol = NULL;
00092 }
00093
00094 void DataProxy::markDirty()
00095 {
00096 setDirty( DIRTY_DATA );
00097 }
00098
00099 }
00100