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 #ifndef BufferedMField_H
00028 #define BufferedMField_H
00029
00030 #include "H3DNetworkingUtils/Config.h"
00031 #include <H3D/MField.h>
00032 #include <deque>
00033 #include <vector>
00034
00035 namespace H3DNetworkingUtils {
00036
00053
00054 template <class M>
00055 class H3D_NETWORKING_UTILS_DLL_SPEC BufferedMField : public M {
00056 public:
00058 BufferedMField();
00059
00061 virtual void initialiseValue(const std::vector<typename M::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
00079 void setBufferStrategy(BufferReleaseStrategy b) {buffer_strategy = b;}
00080
00081 virtual void checkForChange(int id = 0);
00082
00083 virtual void setValue( std::vector<typename M::value_type> const & val, int id = 0 );
00084
00085 inline const std::vector<typename M::value_type> & getValue(int id = 0) {
00086 change_lock.lock();
00087 upToDate();
00088 temp_val = value;
00089 change_lock.unlock();
00090 return temp_val;
00091 }
00092
00093 virtual void update();
00094
00095 private:
00096 H3DUtil::MutexLock change_lock;
00097 BufferReleaseStrategy buffer_strategy;
00098 std::deque< std::vector<typename M::value_type> > temp_vals;
00099 std::vector<typename M::value_type> temp_val;
00100 H3D::X3DTypes::X3DType x3d_type;
00101
00102 };
00103
00104 }
00105
00106 #endif
00107
00108
00109