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_HH_
00023 # define WIFI_FRAME_FILTER_SYNCHRONIZER_HH_
00024
00025 # include <utility>
00026
00027 # include <wipal/tool/valued_iterator.hh>
00028 # include <wipal/tool/iterable.hh>
00029 # include <wipal/wifi/addr_mapping.hh>
00030
00031 # include "linear_regression_synchronizer_fwd.hh"
00032
00033 namespace tool
00034 {
00035
00036 template <class I, class B1, class B2>
00037 struct types< wifi::frame::filter::internals::lr_sync_iterator<I, B1, B2> >
00038 {
00039 typedef wifi::frame::filter::
00040 synchronized_frame<typename I::value_type::value_type, mpf_class>
00041 value_type;
00042 };
00043
00044 template <class I, class B>
00045 struct types< wifi::frame::filter::linear_regression_synchronizer<I, B> >
00046 {
00047 typedef
00048 wifi::frame::filter::internals::lr_sync_iterator<I, B, bottom>
00049 iterator;
00050 };
00051
00052 }
00053
00054 namespace wifi
00055 {
00056 namespace frame
00057 {
00058 namespace filter
00059 {
00060
00061 template <class OriginalFrameType, class ImplType>
00062 struct synchronized_frame: public OriginalFrameType
00063 {
00064 typedef ImplType impl_type;
00065 typedef typename std::pair<impl_type, impl_type> coefs_type;
00066
00067 synchronized_frame(const OriginalFrameType&, const coefs_type&);
00068
00069 coefs_type coefs;
00070 };
00071
00072 namespace internals
00073 {
00074
00075 template <class I, class B, class Bottom = tool::bottom>
00076 struct lr_sync_iterator: WP_INHERIT(public tool::valued_iterator,
00077 lr_sync_iterator<I, B, Bottom>)
00078 {
00080
00081 typedef WP_GET_EXACT(Bottom, lr_sync_iterator<I, B, Bottom>)
00082 exact_type;
00083 typedef tool::valued_iterator<exact_type> super_type;
00084 typedef WP_TYPE(value_type, exact_type) value_type;
00086
00087 typedef linear_regression_synchronizer<I, B> iterable_type;
00088
00090 lr_sync_iterator(const iterable_type& iterable, bool end);
00091
00093
00094 bool equal(const exact_type&) const;
00095 void increment();
00097
00098 enum
00099 {
00102 acceptable_error_threshold = 106
00103 };
00104
00105 private:
00106 bool advance();
00107 bool update_value();
00108
00109 const iterable_type* iterable_;
00110 I win_;
00111 unsigned wpos_;
00112 };
00113
00114 }
00115
00116 template <class InputIterator, class Bottom = tool::bottom>
00117 struct linear_regression_synchronizer:
00118 WP_INHERIT(public tool::iterable,
00119 linear_regression_synchronizer<InputIterator, Bottom>)
00120 {
00121 linear_regression_synchronizer(const InputIterator& first,
00122 const InputIterator& last);
00123
00124 private:
00125 InputIterator first_;
00126 InputIterator last_;
00127
00128 friend class internals::
00129 lr_sync_iterator<InputIterator, Bottom, tool::bottom>;
00130 };
00131
00142 template <class U, class HT, template <class, class, class> class Int,
00143 class I1, class I2, class F>
00144 void
00145 provide_lr_synchronizer(const I1& first1, const I1& last1,
00146 const I2& first2, const I2& last2,
00147 tool::opt::list& options,
00148 F& func);
00149
00150 }
00151
00152 }
00153
00154 }
00155
00156 # include "linear_regression_synchronizer.hxx"
00157
00158 #endif