Equalizer
1.2.1
|
00001 00002 /* 00003 * Copyright (c) 2009, Philippe Robert <philippe.robert@gmail.com> 00004 * 00005 * Redistribution and use in source and binary forms, with or without 00006 * modification, are permitted provided that the following conditions are met: 00007 * 00008 * - Redistributions of source code must retain the above copyright notice, this 00009 * list of conditions and the following disclaimer. 00010 * - Redistributions in binary form must reproduce the above copyright notice, 00011 * this list of conditions and the following disclaimer in the documentation 00012 * and/or other materials provided with the distribution. 00013 * - Neither the name of Eyescale Software GmbH nor the names of its 00014 * contributors may be used to endorse or promote products derived from this 00015 * software without specific prior written permission. 00016 * 00017 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00018 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00019 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00020 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 00021 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00022 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00023 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00024 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00025 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00026 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00027 * POSSIBILITY OF SUCH DAMAGE. 00028 */ 00029 00030 #ifndef EQNBODY_DATAPROXY_H 00031 #define EQNBODY_DATAPROXY_H 00032 00033 #include <eq/eq.h> 00034 00035 namespace eqNbody 00036 { 00037 class SharedDataProxy : public co::Serializable 00038 { 00039 public: 00040 00041 SharedDataProxy(); 00042 00043 void init( const unsigned int offset, const unsigned int numBytes, 00044 float *pos, float *vel, float *col ); 00045 void init( float *pos, float *vel, float *col ); 00046 void exit(); 00047 00048 void markDirty(); 00049 00050 unsigned int getOffset() const {return _offset;} 00051 unsigned int getNumBytes() const {return _numBytes;} 00052 00053 float* getPosition() const {return _hPos;} 00054 float* getVelocity() const {return _hVel;} 00055 00056 protected: 00057 virtual void serialize( co::DataOStream& os, 00058 const uint64_t dirtyBits ); 00059 virtual void deserialize( co::DataIStream& is, 00060 const uint64_t dirtyBits ); 00061 virtual ChangeType getChangeType() const { return UNBUFFERED; } 00062 enum DirtyBits 00063 { 00064 DIRTY_DATA = co::Serializable::DIRTY_CUSTOM << 0 00065 }; 00066 00067 private: 00068 unsigned int _offset; // offset into the frameData's memory chunk 00069 unsigned int _numBytes; // number of bytes to be written 00070 00071 float* _hPos; // frameData's position data on the host 00072 float* _hVel; // frameData's velocity data on the host 00073 float* _hCol; // frameData's color data on the host 00074 }; 00075 } 00076 00077 #endif // EQNBODY_DATAPROXY_H 00078