00001
00006 #pragma once
00007
00008 #include <boost/thread.hpp>
00009 #include <usml/ocean/boundary_model.h>
00010
00011 namespace usml {
00012 namespace ocean {
00013
00014 using boost::numeric::ublas::vector;
00015
00018
00023 class USML_DECLSPEC boundary_lock : public boundary_model {
00024
00025 private:
00026
00028 boost::mutex* _heightMutex ;
00029 boost::mutex* _reflect_lossMutex ;
00031 boundary_model* _other;
00032
00033 public:
00034
00040 boundary_lock(boundary_model* other) : _other(other)
00041 {
00042 _heightMutex = new boost::mutex();
00043 _reflect_lossMutex = new boost::mutex();
00044 }
00045
00055 virtual void height( const wposition& location, matrix<double>* rho,
00056 wvector* normal=NULL, bool quick_interp=false )
00057 {
00058
00059
00060 boost::lock_guard<boost::mutex> heightLock(*_heightMutex);
00061
00062 _other->height(location, rho, normal, quick_interp);
00063 }
00064
00074 virtual void height( const wposition1& location, double* rho,
00075 wvector1* normal=NULL, bool quick_interp=false )
00076 {
00077
00078 boost::lock_guard<boost::mutex> heightLock(*_heightMutex);
00079
00080 _other->height(location, rho, normal, quick_interp);
00081 }
00082
00092 virtual void reflect_loss(
00093 const wposition1& location,
00094 const seq_vector& frequencies, double angle,
00095 boost::numeric::ublas::vector<double>* amplitude, boost::numeric::ublas::vector<double>* phase=NULL )
00096 {
00097
00098 boost::lock_guard<boost::mutex> reflect_lossLock(*_reflect_lossMutex);
00099
00100 _other->reflect_loss( location, frequencies, angle, amplitude, phase ) ;
00101 }
00102
00106 virtual ~boundary_lock()
00107 {
00108 if (_heightMutex || _reflect_lossMutex)
00109 {
00110 delete _heightMutex;
00111 delete _reflect_lossMutex;
00112 _heightMutex = _reflect_lossMutex = NULL;
00113 }
00114 delete _other ;
00115 }
00116 };
00117
00119 }
00120 }