- Main Page
- Classes
- Files

- Search for |

# RemoteSF.h

Go to the documentation of this file.

    00001 /*****************************
    00002 File:      RemoteSF.h
    00003 Language:   C++ (header)
    00004 Project:    H3DNetworkingUtils
    00005 The contents of this file are subject to the Mozilla Public License
    00006 Version 1.1 (the "License"); you may not use this file except in
    00007 compliance with the License. You may obtain a copy of the License at
    00008 http://www.mozilla.org/MPL/
    00009
    00010 Software distributed under the License is distributed on an "AS IS"
    00011 basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
    00012 License for the specific language governing rights and limitations
    00013 under the License.
    00014
    00015 The Original Code is H3DNetworkingUtils v1.0.
    00016
    00017 The Initial Developer of the Original Code is CSIRO.
    00018 Portions created by the Initial Developer are Copyright (C) 1009 CSIRO. All Rights Reserved.
    00019 Contributor(s):
    00020     Chris Gunn  <Chris.Gunn@csiro.au> <ChrisJGunn@gmail.com>
    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   // Public fields
    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