- Main Page
- Classes
- Files

- Search for |

# BufferedSField.h

Go to the documentation of this file.

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