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 "unique_synchronizer.hh"
00028
00029 namespace wifi
00030 {
00031 namespace frame
00032 {
00033 namespace filter
00034 {
00035
00036 inline
00037 synchronized_unique_frame::
00038 synchronized_unique_frame(const tool::microseconds& timestamp1,
00039 const tool::microseconds& timestamp2,
00040 const coefs_type& c):
00041 t1 (timestamp1),
00042 t2 (timestamp2),
00043 coefs (c)
00044 {
00045 }
00046
00047 inline
00048 bool
00049 synchronized_unique_frame::
00050 operator == (const synchronized_unique_frame& rhs) const
00051 {
00052 return t1 == rhs.t1 and t2 == rhs.t2 and coefs == rhs.coefs;
00053 }
00054
00055 inline
00056 bool
00057 synchronized_unique_frame::
00058 operator != (const synchronized_unique_frame& rhs) const
00059 {
00060 return not (*this == rhs);
00061 }
00062
00063 namespace internals
00064 {
00065
00066 template <class I, class B1, class B2>
00067 u_sync_iterator<I, B1, B2>::
00068 u_sync_iterator(unique_synchronizer<I, B1>& i, bool end):
00069 i_ (&i),
00070 next_wpos_ (0),
00071 v_ ()
00072 {
00073 if (not end)
00074 increment();
00075 }
00076
00077 template <class I, class B1, class B2>
00078 bool
00079 u_sync_iterator<I, B1, B2>::equal(const exact_type& rhs) const
00080 {
00081 return
00082 i_ == rhs.i_ and next_wpos_ == rhs.next_wpos_ and v_ == rhs.v_;
00083 }
00084
00085 template <class I, class B1, class B2>
00086 void
00087 u_sync_iterator<I, B1, B2>::increment()
00088 {
00089 typedef typename value_type::impl_type impl_type;
00090
00091 const I& last = i_->last_;
00092 I& next = i_->next_;
00093 const size_t window_size = next->size();
00094
00095 if (next_wpos_ == window_size and next == last)
00096 {
00097 next_wpos_ = 0;
00098 v_ = boost::none_t ();
00099 return;
00100 }
00101
00102 v_ = value_type (next[next_wpos_].first.microseconds(),
00103 next[next_wpos_].second.microseconds(),
00104
00105
00106
00107
00108 std::make_pair(0, 0));
00109
00110
00111
00112
00113
00114 if (next_wpos_ < window_size / 2 or next == last)
00115 ++next_wpos_;
00116 else
00117 ++next;
00118 }
00119
00120 template <class I, class B1, class B2>
00121 const typename u_sync_iterator<I, B1, B2>::value_type&
00122 u_sync_iterator<I, B1, B2>::get() const
00123 {
00124 return v_.get();
00125 }
00126
00127 template <class I, class B1, class B2>
00128 const typename u_sync_iterator<I, B1, B2>::value_type*
00129 u_sync_iterator<I, B1, B2>::get_ptr() const
00130 {
00131 return v_.get_ptr();
00132 }
00133
00134 }
00135
00136
00137 template <class I, class B>
00138 unique_synchronizer<I, B>::
00139 unique_synchronizer(const I& first, const I& last):
00140 next_ (first),
00141 last_ (last)
00142 {
00143 }
00144
00145 }
00146 }
00147 }
00148
00149 #endif // ! WIFI_FRAME_FILTER_SYNCHRONIZER_HXX_