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_HXX_
00023 # define WIFI_UNIQUE_ID_HXX_
00024
00025 # include "unique_id.hh"
00026
00027 namespace wpl
00028 {
00029
00030 namespace wifi
00031 {
00032
00033 namespace internals
00034 {
00035
00036 template <class Tag>
00037 bool
00038 empty<Tag>::operator < (const empty&) const
00039 {
00040 return false;
00041 }
00042
00043 template <class Tag>
00044 bool
00045 empty<Tag>::operator == (const empty&) const
00046 {
00047 return true;
00048 }
00049
00050 template <class Tag>
00051 bool
00052 empty<Tag>::operator != (const empty&) const
00053 {
00054 return false;
00055 }
00056
00057 template <class T, class Tag>
00058 adapter<T, Tag>::adapter(const T& v): v_ (v)
00059 {
00060 }
00061
00062 template <class T, class Tag>
00063 bool
00064 adapter<T, Tag>::operator < (const adapter& rhs) const
00065 {
00066 return v_ < rhs.v_;
00067 }
00068
00069 template <class T, class Tag>
00070 bool
00071 adapter<T, Tag>::operator == (const adapter& rhs) const
00072 {
00073 return v_ == rhs.v_;
00074 }
00075
00076 template <class T, class Tag>
00077 bool
00078 adapter<T, Tag>::operator != (const adapter& rhs) const
00079 {
00080 return not (*this == rhs);
00081 }
00082
00083 template <class T, class Tag>
00084 const T&
00085 adapter<T, Tag>::value() const
00086 {
00087 return v_;
00088 }
00089
00090 template <class T, class Tag>
00091 T&
00092 adapter<T, Tag>::value()
00093 {
00094 return v_;
00095 }
00096
00097 }
00098
00099
00100
00101
00102
00103 template <class Id1, class Id2, class Id3, class Id4>
00104 unique_id<Id1, Id2, Id3, Id4>::unique_id(unsigned frame_id,
00105 const Id1& id1,
00106 const Id2& id2,
00107 const Id3& id3,
00108 const Id4& id4):
00109 Id1 (id1),
00110 Id2 (id2),
00111 Id3 (id3),
00112 Id4 (id4),
00113 frame_id_ (frame_id)
00114 {
00115 }
00116
00117 template <class Id1, class Id2, class Id3, class Id4>
00118 bool
00119 unique_id<Id1, Id2, Id3, Id4>::operator < (const unique_id& rhs) const
00120 {
00121 const Id1& l1 = id1(), r1 = rhs.id1();
00122 const Id2& l2 = id2(), r2 = rhs.id2();
00123 const Id3& l3 = id3(), r3 = rhs.id3();
00124 const Id4& l4 = id4(), r4 = rhs.id4();
00125
00126 if (l1 != r1)
00127 return l1 < r1;
00128 if (l2 != r2)
00129 return l2 < r2;
00130 if (l3 != r3)
00131 return l3 < r3;
00132 return l4 < r4;
00133 }
00134
00135 template <class Id1, class Id2, class Id3, class Id4>
00136 bool
00137 unique_id<Id1, Id2, Id3, Id4>::operator == (const unique_id& rhs) const
00138 {
00139 return (id1() == rhs.id1() and id2() == rhs.id2() and
00140 id3() == rhs.id3() and id4() == rhs.id4());
00141 }
00142
00143 template <class Id1, class Id2, class Id3, class Id4>
00144 bool
00145 unique_id<Id1, Id2, Id3, Id4>::operator != (const unique_id& rhs) const
00146 {
00147 return not (*this == rhs);
00148 }
00149
00150 template <class Id1, class Id2, class Id3, class Id4>
00151 std::ostream&
00152 unique_id<Id1, Id2, Id3, Id4>::print(std::ostream& os) const
00153 {
00154 return os << frame_id_;
00155 }
00156
00157 template <class Id1, class Id2, class Id3, class Id4>
00158 unsigned
00159 unique_id<Id1, Id2, Id3, Id4>::frame_id() const
00160 {
00161 return frame_id_;
00162 }
00163
00164 template <class Id1, class Id2, class Id3, class Id4>
00165 const Id1&
00166 unique_id<Id1, Id2, Id3, Id4>::id1() const
00167 {
00168 return static_cast<const Id1&> (*this);
00169 }
00170
00171 template <class Id1, class Id2, class Id3, class Id4>
00172 const Id2&
00173 unique_id<Id1, Id2, Id3, Id4>::id2() const
00174 {
00175 return static_cast<const Id2&> (*this);
00176 }
00177
00178 template <class Id1, class Id2, class Id3, class Id4>
00179 const Id3&
00180 unique_id<Id1, Id2, Id3, Id4>::id3() const
00181 {
00182 return static_cast<const Id3&> (*this);
00183 }
00184
00185 template <class Id1, class Id2, class Id3, class Id4>
00186 const Id4&
00187 unique_id<Id1, Id2, Id3, Id4>::id4() const
00188 {
00189 return static_cast<const Id4&> (*this);
00190 }
00191
00192 template <class Id1, class Id2, class Id3, class Id4>
00193 std::ostream&
00194 operator << (std::ostream& os, const unique_id<Id1, Id2, Id3, Id4>& ui)
00195 {
00196 return ui.print(os);
00197 }
00198
00199 }
00200
00201 }
00202
00203 WP_HASH_NAMESPACE_BEGIN
00204
00205 template <class Tag>
00206 size_t
00207 hash< wpl::wifi::internals::empty<Tag> >::
00208 operator () (const wpl::wifi::internals::empty<Tag>&) const
00209 {
00210 return 0;
00211 }
00212
00213 template <class T, class Tag>
00214 size_t
00215 hash< wpl::wifi::internals::adapter<T, Tag> >::
00216 operator () (const wpl::wifi::internals::adapter<T, Tag>& a) const
00217 {
00218 return hash<T>::operator () (a.value());
00219 }
00220
00221 template <class Id1, class Id2, class Id3, class Id4>
00222 size_t
00223 hash< wpl::wifi::unique_id<Id1, Id2, Id3, Id4> >::
00224 operator () (const wpl::wifi::unique_id<Id1, Id2, Id3, Id4>& i) const
00225 {
00226 return (hash<Id1>::operator () (i.id1()) ^
00227 hash<Id2>::operator () (i.id2()) ^
00228 hash<Id3>::operator () (i.id3()) ^
00229 hash<Id4>::operator () (i.id4()));
00230 }
00231
00232 WP_HASH_NAMESPACE_END
00233
00234 #endif // ! WIFI_UNIQUE_ID_HXX_