include/trace-tools/wifi/frame/unique_id.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_UNIQUE_ID_HH_
00023 # define WIFI_FRAME_UNIQUE_ID_HH_
00024 
00025 # include <ostream>
00026 # include <boost/optional.hpp>
00027 
00028 # include <trace-tools/pcap/frame_descriptor.hh>
00029 # include <trace-tools/wifi/addr_mapping.hh>
00030 
00031 namespace wifi
00032 {
00033 
00034   namespace frame
00035   {
00036 
00038     namespace internals
00039     {
00040       struct tag1 {};
00041       struct tag2 {};
00042       struct tag3 {};
00043       struct tag4 {};
00044 
00045       template <class Tag>
00046       struct empty
00047       {
00048         bool operator  < (const empty& rhs) const;
00049         bool operator == (const empty& rhs) const;
00050         bool operator != (const empty& rhs) const;
00051       };
00052 
00053       template <class T, class Tag = tag1>
00054       struct adapter
00055       {
00056         adapter(const T& v = T());
00057 
00058         bool operator  < (const adapter& rhs) const;
00059         bool operator == (const adapter& rhs) const;
00060         bool operator != (const adapter& rhs) const;
00061 
00062       private:
00063         T       v_;
00064       };
00065 
00066     } // End of namespace wifi::frame::internals.
00067 
00076     template < class Id1 = internals::empty<internals::tag1>,
00077                class Id2 = internals::empty<internals::tag2>,
00078                class Id3 = internals::empty<internals::tag3>,
00079                class Id4 = internals::empty<internals::tag4> >
00080     struct unique_id: private Id1, private Id2, private Id3, private Id4
00081     {
00092       unique_id(unsigned        frame_id,
00093                 const Id1&      id1 = Id1 (),
00094                 const Id2&      id2 = Id2 (),
00095                 const Id3&      id3 = Id3 (),
00096                 const Id4&      id4 = Id4 ());
00097 
00099 
00100       bool              operator < (const unique_id& rhs) const;
00101       bool              operator == (const unique_id& rhs) const;
00102       bool              operator != (const unique_id& rhs) const;
00104 
00106       std::ostream&     print(std::ostream&) const;
00107 
00109       unsigned          frame_id() const;
00110 
00112 
00113       const Id1&        id1() const;
00114       const Id2&        id2() const;
00115       const Id3&        id3() const;
00116       const Id4&        id4() const;
00118 
00119     private:
00120       unsigned          frame_id_;
00121     };
00122 
00125     template <class Id1, class Id2, class Id3, class Id4>
00126     std::ostream&
00127     operator << (std::ostream&, const unique_id<Id1, Id2, Id3, Id4>&);
00128 
00136     template <class UniqueId, class HeaderType>
00137     boost::optional<UniqueId>
00138     make_unique_id(const pcapxx::frame_descriptor& desc,
00139                    addr_mapping&                mapping,
00140                    bool                         prism_noise_means_error);
00141 
00142     namespace internals
00143     {
00144 
00145       bool
00146       make_unique_id_handle_prism(const void*&  frame,
00147                                   size_t&       caplen,
00148                                   const pcapxx::frame_descriptor& desc,
00149                                   bool          noise_means_error);
00150 
00151     } // End of namespace wifi::frame::internals.
00152 
00153   } // End of namespace wifi::frame.
00154 
00155 } // End of namespace wifi.
00156 
00157 # include "unique_id.hxx"
00158 
00159 #endif // ! WIFI_FRAME_UNIQUE_ID_HH_

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