include/trace-tools/wifi/frame/filter/intersector.hh

00001 /*
00002  * trace-tools - A library and a set of tools to manipulate wireless traces.
00003  * Copyright (C) 2007  Universite Pierre et Marie Curie - Paris 6
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License as published by
00007  * the Free Software Foundation; either version 2 of the License, or
00008  * (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00018  * MA  02110-1301  USA
00019  *
00020  * Author: Thomas Claveirole <thomas.claveirole@lip6.fr>
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 } // End of namespace tool.
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       } // End of namespace internals.
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     } // End of namespace wifi::frame::filter.
00133 
00134   } // End of namespace wifi::frame.
00135 
00136 } // End of namespace wifi.
00137 
00138 # include "intersector.hxx"
00139 
00140 #endif // ! WIFI_FRAME_FILTER_INTERSECTOR_HH_

Generated on Wed Sep 12 16:02:47 2007 for trace-tools by  doxygen 1.5.3