00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef WIFI_FRAME_FILTER_SYNCHRONIZER_HXX_
00023 # define WIFI_FRAME_FILTER_SYNCHRONIZER_HXX_
00024
00025 # include <trace-tools/tool/linear_regression.hh>
00026
00027 # include "linear_regression_synchronizer.hh"
00028
00029 namespace wifi
00030 {
00031 namespace frame
00032 {
00033 namespace filter
00034 {
00035
00036 template <class OriginalFrameType, class ImplType>
00037 synchronized_frame<OriginalFrameType, ImplType>::
00038 synchronized_frame(const OriginalFrameType& orig,
00039 const coefs_type& coefs):
00040 OriginalFrameType (orig),
00041 coefs (coefs)
00042 {
00043 }
00044
00045 namespace internals
00046 {
00047
00048 template <class I, class B1, class B2>
00049 lr_sync_iterator<I, B1, B2>::
00050 lr_sync_iterator(linear_regression_synchronizer<I, B1>& i, bool end):
00051 i_ (&i),
00052 next_wpos_ (0),
00053 v_ ()
00054 {
00055 if (not end)
00056 increment();
00057 }
00058
00059 template <class I, class B1, class B2>
00060 bool
00061 lr_sync_iterator<I, B1, B2>::equal(const exact_type& rhs) const
00062 {
00063 return
00064 i_ == rhs.i_ and next_wpos_ == rhs.next_wpos_ and v_ == rhs.v_;
00065 }
00066
00067 template <class I, class B1, class B2>
00068 void
00069 lr_sync_iterator<I, B1, B2>::increment()
00070 {
00071 typedef typename value_type::impl_type impl_type;
00072
00073 typedef
00074 typename tool::lr::pair_with_microseconds<impl_type>
00075 adapter_type;
00076
00077 const I& last = i_->last_;
00078 I& next = i_->next_;
00079 const size_t window_size = next->size();
00080
00081 if (next_wpos_ == window_size and next == last)
00082 {
00083 next_wpos_ = 0;
00084 v_ = boost::none_t ();
00085 return;
00086 }
00087
00088 v_ =
00089 value_type (next[next_wpos_],
00090 tool::linear_regression<impl_type,
00091 adapter_type> (next->begin(),
00092 next->end()));
00093
00094 if (next_wpos_ < window_size / 2 or next == last)
00095 ++next_wpos_;
00096 else
00097 ++next;
00098 }
00099
00100 template <class I, class B1, class B2>
00101 const typename lr_sync_iterator<I, B1, B2>::value_type&
00102 lr_sync_iterator<I, B1, B2>::get() const
00103 {
00104 return v_.get();
00105 }
00106
00107 template <class I, class B1, class B2>
00108 const typename lr_sync_iterator<I, B1, B2>::value_type*
00109 lr_sync_iterator<I, B1, B2>::get_ptr() const
00110 {
00111 return v_.get_ptr();
00112 }
00113
00114 }
00115
00116
00117 template <class I, class B>
00118 linear_regression_synchronizer<I, B>::
00119 linear_regression_synchronizer(const I& first, const I& last):
00120 next_ (first),
00121 last_ (last)
00122 {
00123 }
00124
00125 }
00126 }
00127 }
00128
00129 #endif // ! WIFI_FRAME_FILTER_SYNCHRONIZER_HXX_