- Main Page
- Classes
- Files

- Search for |

# BufferedMField.h

Go to the documentation of this file.

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