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 "linear_regression_synchronizer.hh"
00026
00027 # include <trace-tools/tool/linear_regression.hh>
00028 # include <trace-tools/tool/window.hh>
00029 # include <trace-tools/wifi/frame/filter/intersector.hh>
00030
00031 namespace wifi
00032 {
00033 namespace frame
00034 {
00035 namespace filter
00036 {
00037
00038 template <class OriginalFrameType, class ImplType>
00039 synchronized_frame<OriginalFrameType, ImplType>::
00040 synchronized_frame(const OriginalFrameType& orig,
00041 const coefs_type& coefs):
00042 OriginalFrameType (orig),
00043 coefs (coefs)
00044 {
00045 }
00046
00047 namespace internals
00048 {
00049
00050 template <class I, class B1, class B2>
00051 lr_sync_iterator<I, B1, B2>::
00052 lr_sync_iterator(const iterable_type& iterable, bool end):
00053 super_type (),
00054 iterable_ (&iterable),
00055 next_ (end ? iterable.last_ : iterable.first_),
00056 next_wpos_ (0)
00057 {
00058 if (not end)
00059 increment();
00060 }
00061
00062 template <class I, class B1, class B2>
00063 bool
00064 lr_sync_iterator<I, B1, B2>::equal(const exact_type& rhs) const
00065 {
00066 if (not rhs.value())
00067 return not this->value();
00068 return next_wpos_ == rhs.next_wpos_ and next_ == rhs.next_;
00069 }
00070
00071 template <class I, class B1, class B2>
00072 void
00073 lr_sync_iterator<I, B1, B2>::increment()
00074 {
00075 typedef typename value_type::impl_type impl_type;
00076
00077 typedef
00078 typename tool::lr::pair_with_microseconds<impl_type>
00079 adapter_type;
00080
00081 const I& last = iterable_->last_;
00082 const size_t window_size = next_->size();
00083
00084 if (next_wpos_ == window_size and next_ == last)
00085 {
00086 this->value() = boost::none_t ();
00087 return;
00088 }
00089
00090 this->value() =
00091 value_type (next_[next_wpos_],
00092 tool::linear_regression<impl_type,
00093 adapter_type> (next_->begin(),
00094 next_->end()));
00095
00096 if (next_wpos_ < window_size / 2)
00097 ++next_wpos_;
00098 else
00099 {
00100 if (next_ != last)
00101 ++next_;
00102 if (next_ == last)
00103 ++next_wpos_;
00104 }
00105 }
00106
00107 }
00108
00109 template <class I, class B>
00110 linear_regression_synchronizer<I, B>::
00111 linear_regression_synchronizer(const I& first, const I& last):
00112 first_ (first),
00113 last_ (last)
00114 {
00115 }
00116
00117 namespace internals
00118 {
00119
00120 template <class F>
00121 struct provide_lr_synchronizer
00122 {
00123 enum { window_size = 3 };
00124
00125 provide_lr_synchronizer(F& func): func_ (func)
00126 {
00127 }
00128
00129 template <class Intersector>
00130 void
00131 operator () (const Intersector& i)
00132 {
00133 typedef typename Intersector::const_iterator i_iterator;
00134 typedef tool::window_maker<i_iterator, window_size> window_maker;
00135 typedef typename window_maker::const_iterator w_iterator;
00136 typedef linear_regression_synchronizer<w_iterator> synchronizer;
00137
00138 window_maker w (i.begin(), i.end());
00139 synchronizer s (w.begin(), w.end());
00140
00141 func_(s);
00142 }
00143
00144 private:
00145 F& func_;
00146 };
00147
00148 }
00149
00150 template <class U, class HT, template <class, class, class> class Int,
00151 class I1, class I2, class F>
00152 void
00153 provide_lr_synchronizer(const I1& first1, const I1& last1,
00154 const I2& first2, const I2& last2,
00155 addr_mapping& mapping,
00156 F& func,
00157 bool filter_prism,
00158 tool::endian::endianness phy_end)
00159 {
00160 internals::provide_lr_synchronizer<F> func2 (func);
00161
00162 provide_intersector<U, HT, Int>(first1, last1,
00163 first2, last2,
00164 mapping, func2, filter_prism, phy_end);
00165 }
00166
00167
00168 }
00169
00170 }
00171
00172 }
00173
00174 #endif // ! WIFI_FRAME_FILTER_SYNCHRONIZER_HXX_