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_WINDOWED_MERGE_HH_
00023 # define WIFI_FRAME_FILTER_WINDOWED_MERGE_HH_
00024
00025 # include <wipal/tool/iterator.hh>
00026 # include <wipal/tool/iterable.hh>
00027 # include <wipal/wifi/addr_mapping.hh>
00028
00029
00030
00031
00032 namespace wifi
00033 {
00034 namespace frame
00035 {
00036 namespace filter
00037 {
00038
00039 namespace internals
00040 {
00041 template <class, class, class, class, class>
00042 struct windowed_merge_iterator;
00043 }
00044
00045 template <class, class, class, class>
00046 struct windowed_merge;
00047
00048 }
00049 }
00050 }
00051
00052
00053
00054
00055
00056
00057 namespace tool
00058 {
00059
00060 template <class HT, class I1, class I2, class B1, class B2>
00061 struct types< wifi::frame::filter::internals::
00062 windowed_merge_iterator<HT, I1, I2, B1, B2> >
00063 {
00064 typedef typename I1::value_type value_type;
00065 typedef wifi::frame::filter::windowed_merge<HT, I1, I2, B1> iterable_type;
00066 };
00067
00068 template <class HT, class I1, class I2, class B>
00069 struct types< wifi::frame::filter::windowed_merge<HT, I1, I2, B> >
00070 {
00071 typedef wifi::frame::filter::internals::
00072 windowed_merge_iterator<HT, I1, I2, B, bottom>
00073 iterator;
00074 };
00075
00076 }
00077
00078
00079
00080
00081
00082
00083 namespace wifi
00084 {
00085 namespace frame
00086 {
00087 namespace filter
00088 {
00089
00090 namespace internals
00091 {
00092 template <class HT,
00093 class I1, class I2,
00094 class B, class Bottom = tool::bottom>
00095 struct windowed_merge_iterator:
00096 WP_INHERIT(public tool::valued_iterator,
00097 windowed_merge_iterator<HT, I1, I2, B, Bottom>)
00098 {
00099
00101
00102 typedef WP_GET_EXACT(Bottom, windowed_merge_iterator<HT, I1, I2,
00103 B, Bottom>)
00104 exact_type;
00105 typedef tool::iterator<exact_type> super_type;
00106 typedef WP_TYPE(value_type, exact_type) value_type;
00107 typedef WP_TYPE(iterable_type, exact_type) iterable_type;
00109
00111 windowed_merge_iterator(const iterable_type& i, bool end);
00112
00114
00115 bool equal(const windowed_merge_iterator& rhs) const;
00116 void increment();
00118
00119 private:
00120 typedef std::deque<typename I1::value_type> window1_type;
00121 typedef std::deque<typename I2::value_type> window2_type;
00122
00124 int first_packet() const;
00125
00127 void update_current();
00128
00134 template <class WindowType, class I>
00135 static
00136 unsigned
00137 fill(WindowType& w,
00138 I& i,
00139 const I& last,
00140 size_t n);
00141
00142 typedef typename window1_type::iterator win1_iterator;
00143 typedef typename window2_type::iterator win2_iterator;
00144 typedef std::pair<win1_iterator, win2_iterator> match_type;
00145 typedef boost::optional<match_type> optional_match;
00146
00147 optional_match match();
00148
00149 enum
00150 {
00151 window_size =
00152
00153 #ifdef WP_WMERGE_WINDOW_SIZE
00154 WP_WMERGE_WINDOW_SIZE
00155 #else // ! WP_WMERGE_WINDOW_SIZE
00156 3
00157 #endif // WP_WMERGE_WINDOW_SIZE
00158 };
00159
00160 const iterable_type* iterable_;
00161
00162 I1 next1_;
00163 I2 next2_;
00164
00165 window1_type win1_;
00166 window2_type win2_;
00167
00168 int current_;
00169 # ifdef WP_ENABLE_INFO
00170 unsigned lhs_total_;
00171 unsigned rhs_total_;
00172 unsigned shared_;
00173 unsigned total_;
00174 double sync_error_;
00175 # endif // WP_ENABLE_INFO
00176 };
00177
00178 }
00179
00180
00181 template <class HeaderType,
00182 class InputIterator1,
00183 class InputIterator2,
00184 class Bottom = tool::bottom>
00185 struct windowed_merge:
00186 WP_INHERIT(public tool::iterable, windowed_merge<HeaderType,
00187 InputIterator1,
00188 InputIterator2,
00189 Bottom>)
00190 {
00191 windowed_merge(const InputIterator1& first1,
00192 const InputIterator1& last1,
00193 const InputIterator2& first2,
00194 const InputIterator2& last2,
00195 tool::endian::endianness phy_end);
00196
00197 private:
00198 tool::endian::endianness phy_end_;
00199
00200 InputIterator1 first1_;
00201 InputIterator1 last1_;
00202 InputIterator2 first2_;
00203 InputIterator2 last2_;
00204
00205 friend
00206 class internals::windowed_merge_iterator<HeaderType,
00207 InputIterator1,
00208 InputIterator2,
00209 Bottom,
00210 tool::bottom>;
00211 };
00212
00213 }
00214
00215 }
00216
00217 }
00218
00219 # include "windowed_merge.hxx"
00220
00221 #endif