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 RemoteSF_H
00027 #define RemoteSF_H
00028
00029 #include "H3DNetworkingUtils/Config.h"
00030 #include "H3DUtil/H3DMath.h"
00031 #include <H3D/X3DChildNode.h>
00032 #include <H3DUtil/Threads.h>
00033 #include <H3D/X3DTypes.h>
00034 #include "H3DNetworkingUtils/RemoteField.h"
00035 #include "H3DNetworkingUtils/BufferedSField.h"
00036
00037 #ifdef _WIN32
00038 #ifdef H3DNetworkingUtils_EXPORTS
00039 #include "H3DNetworkingUtils/BufferedSField.cpp"
00040 #endif
00041 #endif
00042
00043 namespace H3DNetworkingUtils {
00044
00058
00059 template <class S>
00060 class H3D_NETWORKING_UTILS_DLL_SPEC RemoteSF : public RemoteField {
00061 public:
00063 static H3D::H3DNodeDatabase database;
00064
00066 virtual void initialize();
00067
00069 class H3D_NETWORKING_UTILS_DLL_SPEC SFSender : public H3D::AutoUpdate< S > {
00070 public:
00071 SFSender() : send_on_change(false), x3d_type (H3D::X3DTypes::UNKNOWN_X3D_TYPE) {}
00072 virtual void update();
00073 virtual void setValue( const typename S::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
00090 auto_ptr<SFSender > toBeSent;
00091
00098 auto_ptr<BufferedSField<S> > received;
00099
00100 protected:
00104 RemoteSF(H3D::X3DTypes::X3DType t,
00105 H3D::Inst<SFSender> _toBeSent = 0,
00106 H3D::Inst< BufferedSField<S> > _received = 0);
00107
00109 virtual ~RemoteSF();
00110
00112 virtual void setSendOnChange(bool val) {toBeSent->send_on_change = val;}
00113
00118 virtual void checkForChange() {received->checkForChange(id);}
00119
00121 void writeField();
00122
00125 virtual void writeValue(const typename S::value_type & val ) = 0;
00126
00128 double readDouble() {return conP->readDouble();}
00129
00131 H3D::H3DFloat readH3DFloat() {return conP->readDouble();}
00132
00134 void writeDouble(const double & val) {conP->writeDouble(val);}
00135
00137 void writeH3DFloat(const H3D::H3DFloat & val) {conP->writeDouble(val);}
00138
00139 void lockWriteThread() {conP->lockWriteThread();}
00140 void unlockWriteThread() {conP->unlockWriteThread();}
00141 };
00142
00143 }
00144
00145 #endif
00146