include/trace-tools/wifi/frame/filter/fast_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_FAST_INTERSECTOR_HH_
00023 # define WIFI_FRAME_FILTER_FAST_INTERSECTOR_HH_
00024 
00025 # include <utility>
00026 
00027 # include <trace-tools/tool/hash.hh>
00028 # include <trace-tools/tool/valued_iterator.hh>
00029 # include <trace-tools/tool/microseconds.hh>
00030 # include <trace-tools/tool/iterable.hh>
00031 # include <trace-tools/wifi/addr_mapping.hh>
00032 
00033 # include "fast_intersector_fwd.hh"
00034 
00035 namespace tool
00036 {
00037 
00038   template <class I1, class I2, class B1, class B2>
00039   struct types< wifi::frame::filter::internals::
00040                 fast_intersector_iterator<I1, I2, B1, B2> >
00041   {
00042     typedef
00043       std::pair<typename I1::value_type, typename I2::value_type>
00044       value_type;
00045 
00046     typedef
00047       wifi::frame::filter::fast_intersector<I1, I2, B1>
00048       iterable_type;
00049   };
00050 
00051   template <class I1, class I2, class B>
00052   struct types< wifi::frame::filter::fast_intersector<I1, I2, B> >
00053   {
00054     typedef wifi::frame::filter::internals::
00055       fast_intersector_iterator<I1, I2, B, bottom>
00056       iterator;
00057   };
00058 
00059 } // End of namespace tool.
00060 
00061 namespace wifi
00062 {
00063   namespace frame
00064   {
00065     namespace filter
00066     {
00067 
00068       namespace internals
00069       {
00070         template <class I1, class I2, class B, class Bottom = tool::bottom>
00071         struct fast_intersector_iterator:
00072           tt_inherit(public tool::valued_iterator,
00073                      fast_intersector_iterator<I1, I2, B, Bottom>)
00074         {
00075 
00077 
00078           typedef tt_get_exact(Bottom,
00079                                fast_intersector_iterator<I1, I2, B, Bottom>)
00080                                                         exact_type;
00081           typedef tool::valued_iterator<exact_type>     super_type;
00082           typedef tt_type(value_type, exact_type)       value_type;
00083           typedef tt_type(iterable_type, exact_type)    iterable_type;
00085 
00087           fast_intersector_iterator(const iterable_type& i, bool end);
00088 
00090 
00091           bool  equal(const fast_intersector_iterator& rhs) const;
00092           void  increment();
00094 
00095         private:
00096           bool  check();
00097 
00098           const iterable_type*  iterable_;
00099           I1                    next_;
00100           tool::microseconds    last_;
00101         };
00102 
00103       } // End of namespace internals.
00104 
00105 
00106       template <class InputIterator1,
00107                 class InputIterator2,
00108                 class Bottom = tool::bottom>
00109       struct fast_intersector:
00110         tt_inherit(public tool::iterable, fast_intersector<InputIterator1,
00111                                                            InputIterator2,
00112                                                            Bottom>)
00113       {
00114         fast_intersector(const InputIterator1& first1,
00115                          const InputIterator1& last1,
00116                          const InputIterator2& first2,
00117                          const InputIterator2& last2);
00118 
00119 # ifdef DONT_USE_HASH
00120         typedef std::set<typename InputIterator2::value_type>   arrivals_type;
00121 # else
00122         typedef
00123           tool::hash_set<typename InputIterator2::value_type>   arrivals_type;
00124 
00125         enum
00126         {
00136           hash_bucket_count = 1 << 25
00137         };
00138 # endif
00139 
00140       private:
00141         InputIterator1  first_;
00142         InputIterator1  last_;
00143         arrivals_type   arrivals_;
00144 
00145         friend
00146           class internals::fast_intersector_iterator<InputIterator1,
00147                                                      InputIterator2,
00148                                                      Bottom,
00149                                                      tool::bottom>;
00150       };
00151 
00152     } // End of namespace wifi::frame::filter.
00153 
00154   } // End of namespace wifi::frame.
00155 
00156 } // End of namespace wifi.
00157 
00158 # include "fast_intersector.hxx"
00159 
00160 #endif // ! WIFI_FRAME_FILTER_FAST_INTERSECTOR_HH_

Generated on Tue Nov 13 13:48:01 2007 for trace-tools by  doxygen 1.5.3-20071008