4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Thorsten Horstmann <tho@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief MIHTypes public header */
26 #ifndef HH_SENF_Packets_80221Bundle_MIHTypes_
27 #define HH_SENF_Packets_80221Bundle_MIHTypes_ 1
30 #include <senf/Socket/Protocols/Raw/MACAddress.hh>
31 #include <senf/Socket/Protocols/INet/INet4Address.hh>
32 #include <senf/Socket/Protocols/INet/INet6Address.hh>
33 #include <boost/function_output_iterator.hpp>
34 #include <boost/iterator/filter_iterator.hpp>
35 #include <boost/variant.hpp>
37 //#include "MIHTypes.mpp"
38 ///////////////////////////////hh.p////////////////////////////////////////
43 : public boost::variant< boost::blank, senf::MACAddress, senf::INet4Address,
44 senf::INet6Address, std::string, senf::EUI64 >,
45 public boost::less_than_comparable<MIHFId>,
46 public boost::equality_comparable<MIHFId>
49 static MIHFId const Multicast; ///< The multicast (empty) MIHF Id
50 static MIHFId const None; ///< The multicast (empty) MIHF Id
51 enum Type { Empty, MACAddress, INet4Address, INet6Address, String, EUI64 };
53 MIHFId(); ///< Create empty instance.
54 MIHFId(senf::MACAddress const & addr); ///< Construct id with given MACAddress
55 MIHFId(senf::INet4Address const & addr); ///< Construct id with given INet4Address
56 MIHFId(senf::INet6Address const & addr); ///< Construct id with given INet6Address
57 MIHFId(std::string const & addr); ///< Construct id with given String
58 MIHFId(senf::EUI64 const & addr); ///< Construct id with given EUI64
61 bool operator==(MIHFId const & other) const;
62 bool operator<(MIHFId const & other) const;
65 struct GetTypeVisitor : public boost::static_visitor<Type> {
66 Type operator()(boost::blank const &) const { return Empty; }
67 Type operator()(senf::MACAddress const &) const { return MACAddress; }
68 Type operator()(senf::INet4Address const &) const { return INet4Address; }
69 Type operator()(senf::INet6Address const &) const { return INet6Address; }
70 Type operator()(std::string const & ) const { return String; }
71 Type operator()(senf::EUI64 const &) const { return EUI64; }
73 struct EqualsVisitor : public boost::static_visitor<bool> {
74 template <typename T, typename U>
75 bool operator()(T const &, U const &) const {
79 bool operator()( const T & lhs, const T & rhs ) const {
83 struct LessThanVisitor : public boost::static_visitor<bool> {
84 template <typename T, typename U>
85 bool operator()(T const &, U const &) const {
89 bool operator()( const T & lhs, const T & rhs ) const {
97 ///////////////////////////////hh.e////////////////////////////////////////
98 #include "MIHTypes.cci"
99 //#include "MIHTypes.ct"
100 //#include "MIHTypes.cti"
107 // comment-column: 40
108 // c-file-style: "senf"
109 // indent-tabs-mode: nil
110 // ispell-local-dictionary: "american"
111 // compile-command: "scons -u test"