Search:

SENF Extensible Network Framework

  • Home
  • Download
  • Wiki
  • BerliOS
  • ChangeLog
  • Browse SVN
  • Bug Tracker
  • Overview
  • Examples
  • HowTos
  • Glossary
  • PPI
  • Packets
  • Scheduler
  • Socket
  • Utils
  • Console
  • Daemon
  • Logger
  • Termlib
  • Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

80221Bundle/MIHTypes.hh

Go to the documentation of this file.
00001 // $Id: MIHTypes.hh 1742 2010-11-04 14:51:56Z g0dil $
00002 //
00003 // Copyright (C) 2009
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     Thorsten Horstmann <tho@berlios.de>
00007 //
00008 // This program is free software; you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation; either version 2 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the
00020 // Free Software Foundation, Inc.,
00021 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00026 #ifndef HH_SENF_Packets_80221Bundle_MIHTypes_
00027 #define HH_SENF_Packets_80221Bundle_MIHTypes_ 1
00028 
00029 // Custom includes
00030 #include <senf/Socket/Protocols/Raw/MACAddress.hh>
00031 #include <senf/Socket/Protocols/INet/INet4Address.hh>
00032 #include <senf/Socket/Protocols/INet/INet6Address.hh>
00033 #include <boost/function_output_iterator.hpp>
00034 #include <boost/iterator/filter_iterator.hpp>
00035 #include <boost/variant.hpp>
00036 
00037 //#include "MIHTypes.mpp"
00038 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00039 
00040 namespace senf {
00041 
00042     class MIHFId
00043         : public boost::variant< boost::blank, senf::MACAddress, senf::INet4Address,
00044                 senf::INet6Address, std::string, senf::EUI64 >,
00045           public boost::less_than_comparable<MIHFId>,
00046           public boost::equality_comparable<MIHFId>
00047     {
00048     public:
00049         static MIHFId const Multicast; 
00050         enum Type { MulticastType, MACAddress, INet4Address, INet6Address, String, EUI64 };
00051 
00052         MIHFId();                                   
00053         MIHFId(senf::MACAddress const & addr);      
00054         MIHFId(senf::INet4Address const & addr);    
00055         MIHFId(senf::INet6Address const & addr);    
00056         MIHFId(std::string const & addr);           
00057         MIHFId(senf::EUI64 const & addr);           
00058 
00059         Type type() const;
00060         bool operator==(MIHFId const & other) const;
00061         bool operator<(MIHFId const & other) const;
00062 
00063     private:
00064         struct GetTypeVisitor : public boost::static_visitor<Type> {
00065             Type operator()(boost::blank const &) const { return MulticastType; }
00066             Type operator()(senf::MACAddress const &) const { return MACAddress; }
00067             Type operator()(senf::INet4Address const &) const { return INet4Address; }
00068             Type operator()(senf::INet6Address const &) const { return INet6Address; }
00069             Type operator()(std::string const & ) const { return String; }
00070             Type operator()(senf::EUI64 const &) const { return EUI64; }
00071         };
00072         struct EqualsVisitor : public boost::static_visitor<bool> {
00073             template <typename T, typename U>
00074             bool operator()(T const &, U const &) const {
00075                 return false;
00076             }
00077             template <typename T>
00078             bool operator()( const T & lhs, const T & rhs ) const {
00079                 return lhs == rhs;
00080             }
00081         };
00082         struct LessThanVisitor : public boost::static_visitor<bool> {
00083             template <typename T, typename U>
00084             bool operator()(T const &, U const &) const {
00085                 return false;
00086             }
00087             template <typename T>
00088             bool operator()( const T & lhs, const T & rhs ) const {
00089                 return lhs < rhs;
00090             }
00091         };
00092     };
00093 
00094 }
00095 
00096 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00097 #include "MIHTypes.cci"
00098 //#include "MIHTypes.ct"
00099 //#include "MIHTypes.cti"
00100 #endif
00101 
00102 
00103 // Local Variables:
00104 // mode: c++
00105 // fill-column: 100
00106 // comment-column: 40
00107 // c-file-style: "senf"
00108 // indent-tabs-mode: nil
00109 // ispell-local-dictionary: "american"
00110 // compile-command: "scons -u test"
00111 // End:

Contact: senf-dev@lists.berlios.de | © 2006-2010 Fraunhofer Institute for Open Communication Systems, Network Research