Socket/Protocols/Raw: Add EUI64 data type
[senf.git] / Socket / Protocols / Raw / EUI64.hh
1 // $Id$
2 //
3 // Copyright (C) 2009 
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Stefan Bund <g0dil@berlios.de>
7 //
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.
12 //
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.
17 //
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.
22
23 /** \file
24     \brief EUI64 public header */
25
26 #ifndef HH_SENF_Socket_Protocols_Raw_EUI64_
27 #define HH_SENF_Socket_Protocols_Raw_EUI64_ 1
28
29 // Custom includes
30 #include <iostream>
31 #include <boost/cstdint.hpp>
32 #include <boost/array.hpp>
33 #include "../../../Utils/Tags.hh"
34 #include "../../../Utils/safe_bool.hh"
35
36 //#include "EUI64.mpp"
37 ///////////////////////////////hh.p////////////////////////////////////////
38
39 namespace senf {
40
41     class MACAddress;
42
43     /** \brief EUI-64 data type
44         
45         An EUI-64 is a 64 bit (8 octet) id. 
46      */
47     class EUI64
48         : public boost::array<boost::uint8_t,8>,
49           public senf::comparable_safe_bool<EUI64>
50     {
51     public:
52         ///////////////////////////////////////////////////////////////////////////
53         ///\name Structors and default members
54         ///@{
55
56         // default copy constructor
57         // default copy assignment
58         // default destructor
59         // no conversion constructors
60
61         explicit EUI64(boost::uint64_t v=0u);
62         explicit EUI64(senf::NoInit_t);
63
64         static EUI64 from_mac(MACAddress const & mac);
65         static EUI64 from_string(std::string const & s);
66         template <class InputIterator>
67         static EUI64 from_data(InputIterator i);
68
69         ///@}
70         ///////////////////////////////////////////////////////////////////////////
71
72         bool isMACCompatible() const;
73         bool boolean_test() const;
74         boost::uint64_t uint64() const;
75     };
76
77     std::ostream & operator<<(std::ostream & os, EUI64 const & v);
78     std::istream & operator>>(std::istream & is, EUI64 & v);
79
80 }
81
82 ///////////////////////////////hh.e////////////////////////////////////////
83 #include "EUI64.cci"
84 //#include "EUI64.ct"
85 #include "EUI64.cti"
86 #endif
87
88 \f
89 // Local Variables:
90 // mode: c++
91 // fill-column: 100
92 // comment-column: 40
93 // c-file-style: "senf"
94 // indent-tabs-mode: nil
95 // ispell-local-dictionary: "american"
96 // compile-command: "scons -u test"
97 // End: