A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
uan-address.h
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2009 University of Washington
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Leonard Tracy <lentracy@gmail.com>
19  */
20 
21 #ifndef UAN_ADDRESS_H
22 #define UAN_ADDRESS_H
23 
24 #include "ns3/address.h"
25 #include <iostream>
26 
27 namespace ns3 {
28 
38 {
39 public:
40  UanAddress ();
45  UanAddress (uint8_t addr);
46  virtual ~UanAddress ();
47 
52  static UanAddress ConvertFrom (const Address &address);
53 
58  static bool IsMatchingType (const Address &address);
59 
63  operator Address () const;
64 
69  void CopyFrom (const uint8_t *pBuffer);
70 
75  void CopyTo (uint8_t *pBuffer);
76 
80  uint8_t GetAsInt (void) const;
81 
85  static UanAddress GetBroadcast (void);
86 
90  static UanAddress Allocate ();
91 
92 
93 private:
94  uint8_t m_address;
95 
96  static uint8_t GetType (void);
97  Address ConvertTo (void) const;
98 
99  friend bool operator == (const UanAddress &a, const UanAddress &b);
100  friend bool operator != (const UanAddress &a, const UanAddress &b);
101  friend std::ostream& operator<< (std::ostream& os, const UanAddress & address);
102  friend std::istream& operator>> (std::istream& is, UanAddress & address);
103 
104 };
105 
106 
110 bool operator == (const UanAddress &a, const UanAddress &b);
111 
115 bool operator != (const UanAddress &a, const UanAddress &b);
116 
120 std::ostream& operator<< (std::ostream& os, const UanAddress & address);
121 
125 std::istream& operator>> (std::istream& is, UanAddress & address);
126 
127 } // namespace ns3
128 
129 #endif /* UAN_ADDRESS_H */
std::istream & operator>>(std::istream &is, Angles &a)
Definition: angles.cc:49
static bool IsMatchingType(const Address &address)
Definition: uan-address.cc:68
void CopyFrom(const uint8_t *pBuffer)
Sets address to address stored in parameter.
Definition: uan-address.cc:79
a polymophic address class
Definition: address.h:86
friend std::ostream & operator<<(std::ostream &os, const UanAddress &address)
Writes param address to stream os as 8 bit integer.
Definition: uan-address.cc:123
static UanAddress ConvertFrom(const Address &address)
Definition: uan-address.cc:54
friend bool operator!=(const UanAddress &a, const UanAddress &b)
Returns true if byte address a is unequal to byte address b.
Definition: uan-address.cc:117
static UanAddress GetBroadcast(void)
Definition: uan-address.cc:92
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:43
uint8_t GetAsInt(void) const
Definition: uan-address.cc:63
friend bool operator==(const UanAddress &a, const UanAddress &b)
Returns true if byte address a is equal to byte address b.
Definition: uan-address.cc:111
void CopyTo(uint8_t *pBuffer)
Writes address to buffer parameter.
Definition: uan-address.cc:85
static UanAddress Allocate()
Allocates UanAddress from 0-254 (will wrap back to 0 if more than 255 are allocated) ...
Definition: uan-address.cc:97
friend std::istream & operator>>(std::istream &is, UanAddress &address)
Inputs param address from stream is as 8 bit integer.
Definition: uan-address.cc:129