include/wipal/wifi/frame/filter/non_noisy_prism.hh

00001 /*
00002  * WiPal - 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_NON_NOISY_PRISM_HH_
00023 # define WIFI_FRAME_FILTER_NON_NOISY_PRISM_HH_
00024 
00025 # include <wipal/tool/iterator.hh>
00026 # include <wipal/tool/iterable.hh>
00027 
00028 /*---------------------.
00029 | Forward declarations |
00030 `---------------------*/
00031 
00032 namespace wifi
00033 {
00034   namespace frame
00035   {
00036     namespace filter
00037     {
00038 
00039      namespace internals
00040       {
00041         template <class, class, class>
00042         struct non_noisy_prism_iterator;
00043       }
00044 
00045       template <class, class>
00046       struct non_noisy_prism;
00047     }
00048   }
00049 }
00050 
00051 
00052 /*--------------.
00053 | Virtual types |
00054 `--------------*/
00055 
00056 namespace tool
00057 {
00058 
00065   template <class I, class B1, class B2>
00066   struct types< wifi::frame::filter::internals::
00067                 non_noisy_prism_iterator<I, B1, B2> >
00068   {
00069     typedef wifi::frame::filter::non_noisy_prism<I, B1> iterable_type;
00070     typedef typename I::value_type                      value_type;
00071   };
00072 
00078   template <class I, class B>
00079   struct types< wifi::frame::filter::non_noisy_prism<I, B> >
00080   {
00081     typedef
00082       wifi::frame::filter::internals::non_noisy_prism_iterator<I, B, bottom>
00083       iterator;
00084   };
00085 
00086 } // End of namespace tool.
00087 
00088 
00089 /*-------------.
00090 | Declarations |
00091 `-------------*/
00092 
00093 namespace wifi
00094 {
00095   namespace frame
00096   {
00097     namespace filter
00098     {
00099 
00100       namespace internals
00101       {
00102 
00104         template <class I, class B, class Bottom>
00105         struct non_noisy_prism_iterator:
00106           wp_inherit(public tool::iterator,
00107                      non_noisy_prism_iterator<I, B, Bottom>)
00108         {
00109 
00111 
00112           typedef wp_get_exact(Bottom, non_noisy_prism_iterator<I, B, Bottom>)
00113                                                         exact_type;
00114           typedef tool::iterator<exact_type>            super_type;
00115           typedef wp_type(value_type, exact_type)       value_type;
00116           typedef wp_type(iterable_type, exact_type)    iterable_type;
00118 
00120           non_noisy_prism_iterator(const iterable_type& i, bool end);
00121 
00123 
00124           bool          equal(const non_noisy_prism_iterator& rhs) const;
00125           void          increment();
00126 
00127           const value_type&     get() const;
00128           value_type&           get();
00129 
00130           const value_type*     get_ptr() const;
00131           value_type*           get_ptr();
00133 
00134         private:
00136           static bool           noisy(const void* frame, size_t caplen);
00137 
00139           void                  skip_noisy();
00140 
00141           const iterable_type*  iterable_;
00142           I                     current_;
00143         };
00144 
00145       } // End of namespace wifi::frame::filter::internals.
00146 
00147 
00149       template <class InputIterator, class Bottom = tool::bottom>
00150       struct non_noisy_prism: wp_inherit(public tool::iterable,
00151                                          non_noisy_prism<InputIterator, Bottom>)
00152       {
00154         non_noisy_prism(const InputIterator& begin, const InputIterator& end);
00155 
00157         template <class Iterable>
00158         non_noisy_prism(const Iterable& i);
00159 
00160       private:
00161         InputIterator           begin_;
00162         InputIterator           end_;
00163 
00164         friend class internals::non_noisy_prism_iterator<InputIterator,
00165                                                          Bottom, tool::bottom>;
00166       };
00167 
00168     } // End of namespace wifi::frame::filter.
00169 
00170   } // End of namespace wifi::frame.
00171 
00172 } // End of namespace wifi.
00173 
00174 # include "non_noisy_prism.hxx"
00175 
00176 #endif // ! WIFI_FRAME_FILTER_NON_NOISY_PRISM_HH_

Generated on Wed Jan 16 16:15:14 2008 for wipal by  doxygen 1.5.4