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_INTERSECTOR_HH_
00023 # define WIFI_FRAME_FILTER_INTERSECTOR_HH_
00024
00025 # include <set>
00026 # include <utility>
00027
00028 # include <trace-tools/tool/microseconds.hh>
00029 # include <trace-tools/tool/iterator_base.hh>
00030
00031 # include "intersector_fwd.hh"
00032
00033 namespace tool
00034 {
00035
00036 template <class I1, class I2, class B1, class B2>
00037 struct types< wifi::frame::filter::internals::intersector_iterator<I1, I2,
00038 B1, B2> >
00039 {
00040 typedef
00041 std::pair<typename I1::value_type, typename I2::value_type>
00042 value_type;
00043
00044 typedef
00045 wifi::frame::filter::intersector<I1, I2, B1>
00046 iterable_type;
00047 };
00048
00049 template <class I1, class I2, class B>
00050 struct types< wifi::frame::filter::intersector<I1, I2, B> >
00051 {
00052 typedef
00053 wifi::frame::filter::internals::intersector_iterator<I1, I2, B, bottom>
00054 iterator;
00055 };
00056
00057 }
00058
00059 namespace wifi
00060 {
00061 namespace frame
00062 {
00063 namespace filter
00064 {
00065
00066 namespace internals
00067 {
00068 template <class I1, class I2, class B, class Bottom = tool::bottom>
00069 struct intersector_iterator:
00070 tt_inherit(public tool::iterator_base,
00071 intersector_iterator<I1, I2, B, Bottom>)
00072 {
00073 typedef tt_get_exact(Bottom, intersector_iterator<I1, I2, B, Bottom>)
00074 exact_type;
00075
00076 typedef tt_type(iterable_type, exact_type)
00077 iterable_type;
00078
00079 intersector_iterator(iterable_type& i, bool end);
00080
00081 void increment();
00082
00083 private:
00084 typedef typename iterable_type::arrivals1_type arrivals1_type;
00085 typedef typename iterable_type::arrivals2_type arrivals2_type;
00086
00087 template <bool SwapResult, class ArrType, class RHSArrType>
00088 bool
00089 check(I1& frm,
00090 ArrType& frm_arrivals,
00091 RHSArrType& rhs_arrivals);
00092
00093 template <class ArrType>
00094 void
00095 cleanup_arrivals(const typename ArrType::iterator& frame,
00096 ArrType& arrivals);
00097 };
00098
00099 }
00100
00101
00102 template <class InputIterator1,
00103 class InputIterator2,
00104 class Bottom = tool::bottom>
00105 struct intersector:
00106 tt_inherit(public tool::iterable, intersector<InputIterator1,
00107 InputIterator2,
00108 Bottom>)
00109 {
00110 intersector(const InputIterator1& first1, const InputIterator1& last1,
00111 const InputIterator2& first2, const InputIterator2& last2);
00112
00113 private:
00114 typedef std::set<typename InputIterator1::value_type> arrivals1_type;
00115 typedef std::set<typename InputIterator2::value_type> arrivals2_type;
00116
00117 arrivals1_type arrivals1_;
00118 arrivals2_type arrivals2_;
00119
00120 InputIterator1 next1_;
00121 InputIterator1 last1_;
00122 InputIterator2 next2_;
00123 InputIterator2 last2_;
00124
00125 friend
00126 class internals::intersector_iterator<InputIterator1,
00127 InputIterator2,
00128 Bottom,
00129 tool::bottom>;
00130 };
00131
00132 }
00133
00134 }
00135
00136 }
00137
00138 # include "intersector.hxx"
00139
00140 #endif