4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Thorsten Horstmann <tho@berlios.de>
29 \brief MIHTypes public header */
31 #ifndef HH_SENF_Packets_80221Bundle_MIHTypes_
32 #define HH_SENF_Packets_80221Bundle_MIHTypes_ 1
35 #include <senf/Socket/Protocols/Raw/MACAddress.hh>
36 #include <senf/Socket/Protocols/INet/INet4Address.hh>
37 #include <senf/Socket/Protocols/INet/INet6Address.hh>
38 #include <boost/function_output_iterator.hpp>
39 #include <boost/iterator/filter_iterator.hpp>
40 #include <boost/variant.hpp>
42 //#include "MIHTypes.mpp"
43 //-/////////////////////////////////////////////////////////////////////////////////////////////////
48 : public boost::variant< boost::blank, senf::MACAddress, senf::INet4Address,
49 senf::INet6Address, std::string, senf::EUI64 >,
50 public boost::less_than_comparable<MIHFId>,
51 public boost::equality_comparable<MIHFId>
54 static MIHFId const Multicast; ///< The multicast (empty) MIHF Id
55 enum Type { MulticastType, MACAddress, INet4Address, INet6Address, String, EUI64 };
57 MIHFId(); ///< Create multicast id.
58 MIHFId(senf::MACAddress const & addr); ///< Construct id with given MACAddress
59 MIHFId(senf::INet4Address const & addr); ///< Construct id with given INet4Address
60 MIHFId(senf::INet6Address const & addr); ///< Construct id with given INet6Address
61 MIHFId(std::string const & addr); ///< Construct id with given String
62 MIHFId(senf::EUI64 const & addr); ///< Construct id with given EUI64
65 bool operator==(MIHFId const & other) const;
66 bool operator<(MIHFId const & other) const;
69 struct GetTypeVisitor : public boost::static_visitor<Type> {
70 Type operator()(boost::blank const &) const { return MulticastType; }
71 Type operator()(senf::MACAddress const &) const { return MACAddress; }
72 Type operator()(senf::INet4Address const &) const { return INet4Address; }
73 Type operator()(senf::INet6Address const &) const { return INet6Address; }
74 Type operator()(std::string const & ) const { return String; }
75 Type operator()(senf::EUI64 const &) const { return EUI64; }
77 struct EqualsVisitor : public boost::static_visitor<bool> {
78 template <typename T, typename U>
79 bool operator()(T const &, U const &) const {
83 bool operator()( const T & lhs, const T & rhs ) const {
87 struct LessThanVisitor : public boost::static_visitor<bool> {
88 template <typename T, typename U>
89 bool operator()(T const &, U const &) const {
93 bool operator()( const T & lhs, const T & rhs ) const {
101 //-/////////////////////////////////////////////////////////////////////////////////////////////////
102 #include "MIHTypes.cci"
103 //#include "MIHTypes.ct"
104 //#include "MIHTypes.cti"
111 // comment-column: 40
112 // c-file-style: "senf"
113 // indent-tabs-mode: nil
114 // ispell-local-dictionary: "american"
115 // compile-command: "scons -u test"