00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00025
00026
00027
00028 #ifndef BufferedSField_H
00029 #define BufferedSField_H
00030
00031 #include "H3DNetworkingUtils/Config.h"
00032 #include <H3D/SField.h>
00033 #include <deque>
00034
00035 namespace H3DNetworkingUtils {
00036
00053
00054 template <class S>
00055 class H3D_NETWORKING_UTILS_DLL_SPEC BufferedSField : public S {
00056 public:
00058 BufferedSField();
00059
00061 virtual void initialiseValue( const typename S::value_type empty ) {
00062 value = empty;
00063 }
00064
00065 void setX3DType(H3D::X3DTypes::X3DType t) {x3d_type = t;}
00066 virtual H3D::X3DTypes::X3DType getX3DType() { return x3d_type; }
00067
00068 enum BufferReleaseStrategy {NONE, SET_ONE_PER_CYCLE, SET_ALL};
00069
00078 void setBufferStrategy(BufferReleaseStrategy b) {buffer_strategy = b;}
00079
00080 virtual void checkForChange(int id = 0);
00081
00082 virtual void setValue(const typename S::value_type & val, int id = 0 );
00083
00084 inline const typename S::value_type & getValue(int id = 0) {
00085 change_lock.lock();
00086 upToDate();
00087 temp_val = value;
00088 change_lock.unlock();
00089 return temp_val;
00090 }
00091
00092 virtual void update();
00093
00094 private:
00095 H3DUtil::MutexLock change_lock;
00096 BufferReleaseStrategy buffer_strategy;
00097 std::deque<typename S::value_type> temp_vals;
00098 typename S::value_type temp_val;
00099 H3D::X3DTypes::X3DType x3d_type;
00100 };
00101
00102 }
00103
00104 #endif
00105