include/trace-tools/wifi/frame/filter/unique_synchronizer.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_SYNCHRONIZER_HH_
00023 # define WIFI_FRAME_FILTER_SYNCHRONIZER_HH_
00024 
00025 # include <boost/optional.hpp>
00026 # include <gmpxx.h>
00027 
00028 # include <trace-tools/tool/microseconds.hh>
00029 # include <trace-tools/tool/iterator.hh>
00030 # include <trace-tools/tool/iterable.hh>
00031 
00032 # include "unique_synchronizer_fwd.hh"
00033 
00034 namespace tool
00035 {
00036 
00037   template <class I, class B1, class B2>
00038   struct types< wifi::frame::filter::internals::u_sync_iterator<I, B1, B2> >
00039   {
00040     typedef
00041       wifi::frame::filter::synchronized_unique_frame
00042       value_type;
00043   };
00044 
00045   template <class I, class B>
00046   struct types< wifi::frame::filter::unique_synchronizer<I, B> >
00047   {
00048     typedef
00049       wifi::frame::filter::internals::u_sync_iterator<I, B, bottom>
00050       iterator;
00051   };
00052 
00053 } // End of namespace tool.
00054 
00055 namespace wifi
00056 {
00057   namespace frame
00058   {
00059     namespace filter
00060     {
00061 
00062       struct synchronized_unique_frame
00063       {
00064         typedef mpf_class                       impl_type;
00065         typedef std::pair<impl_type, impl_type> coefs_type;
00066 
00067         synchronized_unique_frame(const tool::microseconds&,
00068                                   const tool::microseconds&,
00069                                   const coefs_type&);
00070 
00071         bool    operator == (const synchronized_unique_frame&) const;
00072         bool    operator != (const synchronized_unique_frame&) const;
00073 
00074         tool::microseconds      t1;
00075         tool::microseconds      t2;
00076         coefs_type              coefs;
00077       };
00078 
00079       namespace internals
00080       {
00081 
00082         template <class I, class B, class Bottom = tool::bottom>
00083         struct u_sync_iterator:
00084           tt_inherit(public tool::iterator, u_sync_iterator<I, B, Bottom>)
00085         {
00086           typedef tt_get_exact(Bottom, u_sync_iterator<I, B, Bottom>)
00087                                                                 exact_type;
00088           typedef tt_type(value_type, exact_type)               value_type;
00089 
00090           u_sync_iterator(unique_synchronizer<I, B>&, bool);
00091 
00092           bool                  equal(const exact_type&) const;
00093           void                  increment();
00094           const value_type&     get() const;
00095           const value_type*     get_ptr() const;
00096 
00097         private:
00098           typedef boost::optional<value_type>   optional_value;
00099 
00100           unique_synchronizer<I, B>*    i_;
00101           unsigned                      next_wpos_;
00102           optional_value                v_;
00103         };
00104 
00105       } // End of namespace wifi::frame::filter::internals.
00106 
00107       template <class InputIterator, class Bottom = tool::bottom>
00108       struct unique_synchronizer:
00109         tt_inherit(public tool::iterable,
00110                    unique_synchronizer<InputIterator, Bottom>)
00111       {
00112         unique_synchronizer(const InputIterator& first,
00113                             const InputIterator& last);
00114 
00115       private:
00116         InputIterator   next_;
00117         InputIterator   last_;
00118 
00119         friend
00120           class internals::u_sync_iterator<InputIterator, Bottom, tool::bottom>;
00121       };
00122 
00123     } // End of namespace wifi::frame::filter.
00124   } // End of namespace wifi::frame.
00125 } // End of namespace wifi.
00126 
00127 # include "unique_synchronizer.hxx"
00128 
00129 #endif // ! WIFI_FRAME_FILTER_SYNCHRONIZER_HH_

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