dataProxy.cpp

00001 /*
00002  * Copyright (c) 2009, Philippe Robert <probert@eyescale.ch> 
00003  *
00004  * This library is free software; you can redistribute it and/or modify it under
00005  * the terms of the GNU Lesser General Public License version 2.1 as published
00006  * by the Free Software Foundation.
00007  *  
00008  * This library is distributed in the hope that it will be useful, but WITHOUT
00009  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00010  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00011  * details.
00012  * 
00013  * You should have received a copy of the GNU Lesser General Public License
00014  * along with this library; if not, write to the Free Software Foundation, Inc.,
00015  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
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             //os.write(_hCol+_offset, _numBytes);           
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             //is.read(_hCol+_offset, _numBytes);
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 
Generated on Mon Aug 10 18:58:32 2009 for Equalizer 0.9 by  doxygen 1.5.8