include/trace-tools/wifi/frame/filter/linear_regression_synchronizer.hxx

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_HXX_
00023 # define WIFI_FRAME_FILTER_SYNCHRONIZER_HXX_
00024 
00025 # include <trace-tools/tool/linear_regression.hh>
00026 
00027 # include "linear_regression_synchronizer.hh"
00028 
00029 namespace wifi
00030 {
00031   namespace frame
00032   {
00033     namespace filter
00034     {
00035 
00036       template <class OriginalFrameType, class ImplType>
00037       synchronized_frame<OriginalFrameType, ImplType>::
00038       synchronized_frame(const OriginalFrameType&       orig,
00039                          const coefs_type&              coefs):
00040         OriginalFrameType (orig),
00041         coefs (coefs)
00042       {
00043       }
00044 
00045       namespace internals
00046       {
00047 
00048         template <class I, class B1, class B2>
00049         lr_sync_iterator<I, B1, B2>::
00050         lr_sync_iterator(linear_regression_synchronizer<I, B1>& i, bool end):
00051           i_ (&i),
00052           next_wpos_ (0),
00053           v_ ()
00054         {
00055           if (not end)
00056             increment();
00057         }
00058 
00059         template <class I, class B1, class B2>
00060         bool
00061         lr_sync_iterator<I, B1, B2>::equal(const exact_type& rhs) const
00062         {
00063           return
00064             i_ == rhs.i_ and next_wpos_ == rhs.next_wpos_ and v_ == rhs.v_;
00065         }
00066 
00067         template <class I, class B1, class B2>
00068         void
00069         lr_sync_iterator<I, B1, B2>::increment()
00070         {
00071           typedef typename value_type::impl_type        impl_type;
00072 
00073           typedef
00074             typename tool::lr::pair_with_microseconds<impl_type>
00075             adapter_type;
00076 
00077           const I&      last = i_->last_;
00078           I&            next = i_->next_;
00079           const size_t  window_size = next->size();
00080 
00081           if (next_wpos_ == window_size and next == last)
00082             {
00083               next_wpos_ = 0;
00084               v_ = boost::none_t ();
00085               return;
00086             }
00087 
00088           v_ =
00089             value_type (next[next_wpos_],
00090                         tool::linear_regression<impl_type,
00091                                                 adapter_type> (next->begin(),
00092                                                                next->end()));
00093 
00094           if (next_wpos_ < window_size / 2 or next == last)
00095             ++next_wpos_;
00096           else
00097             ++next;
00098         }
00099 
00100         template <class I, class B1, class B2>
00101         const typename lr_sync_iterator<I, B1, B2>::value_type&
00102         lr_sync_iterator<I, B1, B2>::get() const
00103         {
00104           return v_.get();
00105         }
00106 
00107         template <class I, class B1, class B2>
00108         const typename lr_sync_iterator<I, B1, B2>::value_type*
00109         lr_sync_iterator<I, B1, B2>::get_ptr() const
00110         {
00111           return v_.get_ptr();
00112         }
00113 
00114       } // End of namespace wifi::frame::filter::internals.
00115 
00116 
00117       template <class I, class B>
00118       linear_regression_synchronizer<I, B>::
00119       linear_regression_synchronizer(const I& first, const I& last):
00120         next_ (first),
00121         last_ (last)
00122       {
00123       }
00124 
00125     } // End of namespace wifi::frame::filter.
00126   } // End of namespace wifi::frame.
00127 } // End of namespace wifi.
00128 
00129 #endif // ! WIFI_FRAME_FILTER_SYNCHRONIZER_HXX_

Generated on Mon Sep 24 18:13:49 2007 for trace-tools by  doxygen 1.5.3