- Main Page
- Classes
- Files

- Search for |

# RemoteMF.h

Go to the documentation of this file.

    00001 /*****************************
    00002 File:      RemoteMF.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 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   // Public fields
    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