00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef WIFI_UNIQUE_ID_HH_
00023 # define WIFI_UNIQUE_ID_HH_
00024
00025 # include <ostream>
00026 # include <boost/optional.hpp>
00027
00028 # include <wipal/pcap/pkt.hh>
00029 # include <wipal/wifi/addr_mapping.hh>
00030 # include <wipal/tool/hash.hh>
00031
00032 namespace wpl
00033 {
00034
00035 namespace wifi
00036 {
00037
00039 namespace internals
00040 {
00041 struct tag1 {};
00042 struct tag2 {};
00043 struct tag3 {};
00044 struct tag4 {};
00045
00046 template <class Tag>
00047 struct empty
00048 {
00049 bool operator < (const empty& rhs) const;
00050 bool operator == (const empty& rhs) const;
00051 bool operator != (const empty& rhs) const;
00052 };
00053
00054 template <class T, class Tag = tag1>
00055 struct adapter
00056 {
00057 adapter(const T& v = T());
00058
00059 bool operator < (const adapter& rhs) const;
00060 bool operator == (const adapter& rhs) const;
00061 bool operator != (const adapter& rhs) const;
00062
00063 const T& value() const;
00064 T& value();
00065
00066 private:
00067 T v_;
00068 };
00069
00070 }
00071
00080 template < class Id1 = internals::empty<internals::tag1>,
00081 class Id2 = internals::empty<internals::tag2>,
00082 class Id3 = internals::empty<internals::tag3>,
00083 class Id4 = internals::empty<internals::tag4> >
00084 struct unique_id: private Id1, private Id2, private Id3, private Id4
00085 {
00096 unique_id(unsigned frame_id,
00097 const Id1& id1 = Id1 (),
00098 const Id2& id2 = Id2 (),
00099 const Id3& id3 = Id3 (),
00100 const Id4& id4 = Id4 ());
00101
00103
00104 bool operator < (const unique_id& rhs) const;
00105 bool operator == (const unique_id& rhs) const;
00106 bool operator != (const unique_id& rhs) const;
00108
00110 std::ostream& print(std::ostream&) const;
00111
00113 unsigned frame_id() const;
00114
00116
00117 const Id1& id1() const;
00118 const Id2& id2() const;
00119 const Id3& id3() const;
00120 const Id4& id4() const;
00122
00123 private:
00124 unsigned frame_id_;
00125 };
00126
00129 template <class Id1, class Id2, class Id3, class Id4>
00130 std::ostream&
00131 operator << (std::ostream&, const unique_id<Id1, Id2, Id3, Id4>&);
00132
00143 template <class UniqueId>
00144 struct unique_id_factory;
00145
00146 # define WP_UNIQUE_ID_DISSECT(F, D, HType, H) \
00147 dissector<HType> D = dissect<HeaderType, HType>(F); \
00148 const HType& H = D.hooks()
00149
00150 }
00151
00152 }
00153
00154
00155
00156
00157
00158 WP_HASH_NAMESPACE_BEGIN
00159
00160 template <class Tag>
00161 struct hash< wpl::wifi::internals::empty<Tag> >
00162 {
00163 size_t
00164 operator () (const wpl::wifi::internals::empty<Tag>&) const;
00165 };
00166
00167 template <class T, class Tag>
00168 struct hash< wpl::wifi::internals::adapter<T, Tag> >: public hash<T>
00169 {
00170 size_t
00171 operator () (const wpl::wifi::internals::adapter<T, Tag>&) const;
00172 };
00173
00174 template <class Id1, class Id2, class Id3, class Id4>
00175 struct hash< wpl::wifi::unique_id<Id1, Id2, Id3, Id4> >:
00176 public hash<Id1>,
00177 public hash<Id2>,
00178 public hash<Id3>,
00179 public hash<Id4>
00180 {
00181 size_t
00182 operator () (const wpl::wifi::unique_id<Id1, Id2, Id3, Id4>&) const;
00183 };
00184
00185 WP_HASH_NAMESPACE_END
00186
00187
00188 # include "unique_id.hxx"
00189
00190 #endif // ! WIFI_UNIQUE_ID_HH_