00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00025
00026 #ifndef RemoteMF_H
00027 #define RemoteMF_H
00028
00029
00030 #include "H3DNetworkingUtils/Config.h"
00031 #include "H3DUtil/H3DMath.h"
00032 #include "H3D/X3DChildNode.h"
00033 #include "H3DUtil/Threads.h"
00034 #include "H3DNetworkingUtils/RemoteField.h"
00035 #include "H3DNetworkingUtils/BufferedMField.h"
00036
00037 #ifdef _WIN32
00038 #ifdef H3DNetworkingUtils_EXPORTS
00039 #include "H3DNetworkingUtils/BufferedMField.cpp"
00040 #endif
00041 #endif
00042
00043 namespace H3DNetworkingUtils {
00044
00058
00059 template <class M>
00060 class H3D_NETWORKING_UTILS_DLL_SPEC RemoteMF : public RemoteField {
00061 public:
00063 static H3D::H3DNodeDatabase database;
00064
00066 virtual void initialize();
00067
00069 class H3D_NETWORKING_UTILS_DLL_SPEC MFSender : public H3D::AutoUpdate< M > {
00070 public:
00071 MFSender() : send_on_change(false) {}
00072 virtual void update( );
00073 virtual void setValue( const std::vector<typename M::value_type> & val, int id = 0 );
00074 void setX3DType(H3D::X3DTypes::X3DType t) {x3d_type = t;}
00075 virtual H3D::X3DTypes::X3DType getX3DType() { return x3d_type; }
00076
00077 bool send_on_change;
00078 private:
00079 H3D::X3DTypes::X3DType x3d_type;
00080 };
00081
00082
00083
00088 auto_ptr<MFSender > toBeSent;
00089
00096 auto_ptr<BufferedMField<M> > received;
00097
00098 protected:
00103 RemoteMF(H3D::X3DTypes::X3DType t,
00104 H3D::Inst<MFSender> _toBeSent = 0,
00105 H3D::Inst< BufferedMField<M> > _received = 0);
00106
00107 virtual ~RemoteMF();
00108
00110 virtual void setSendOnChange(bool val) {toBeSent->send_on_change = val;}
00111
00116 virtual void checkForChange() {received->checkForChange(id);}
00117
00119 void writeField();
00120
00123 virtual void writeValue(std::vector<typename M::value_type> const & val ) = 0;
00124
00126 double readDouble() {return conP->readDouble();}
00127
00129 H3D::H3DFloat readH3DFloat() {return conP->readDouble();}
00130
00132 void writeDouble(const double & val) {conP->writeDouble(val);}
00133
00135 void writeH3DFloat(const H3DFloat & val) {conP->writeDouble(val);}
00136
00137 void lockWriteThread() {conP->lockWriteThread();}
00138
00139 void unlockWriteThread() {conP->unlockWriteThread();}
00140
00141 };
00142
00143 }
00144
00145 #endif
00146
00147
00148