Protocols::Transports::NodeAddress Class Reference

#include <NodeAddress.h> [code]

Collaboration diagram for Protocols::Transports::NodeAddress:

Collaboration graph
[legend]
List of all members.

Detailed Description

Encapulates a node address: host name / IP address : port.

A NodeAddress object can store host name or a host address (IP) and a port. If the host name is set, then the IP address is null. If the IP address is set, then the hostname is null. The Connection classes would know what to do in each case.

Todo:
Host name and address are exclusive now. It might make sence to allow both to be set at the same time for example when you have a connected connection one might want to query both the name and the address.
Todo:
Maybe a solution to the above would be to encapsulate the lookup function in this class and allow multiple addresses for one name. For reverse lookups we could have alliases for a single IP.
Todo:
Maybe make a generic class out of this one by adding a protocol field?

Definition at line 46 of file NodeAddress.h.

Public Member Functions

 NodeAddress (const QHostAddress &hostAddress=QHostAddress::Null, quint16 hostPort=0)
 NodeAddress (const QString &hostName, quint16 hostPort)
 NodeAddress (const QString &hostNameAndPort)
 Constructs a NodeAddress from a string.
 ~NodeAddress ()
bool operator== (const NodeAddress &nodeAddress) const
bool operator!= (const NodeAddress &nodeAddress) const
bool operator< (const NodeAddress &nodeAddress) const
bool isNull () const
QString hostName () const
QHostAddress hostAddress () const
quint16 hostPort () const
void setHostName (const QString &hostName)
void setHostAddress (const QHostAddress &hostAddress)
void setHostPort (quint16 hostPort)
QString toString () const

Static Public Attributes

static const NodeAddress Null = NodeAddress()

Private Attributes

QString hostName_
QHostAddress hostAddress_
quint16 hostPort_


Constructor & Destructor Documentation

NodeAddress::NodeAddress const QHostAddress &  hostAddress = QHostAddress::Null,
quint16  hostPort = 0
 

Definition at line 31 of file NodeAddress.cpp.

NodeAddress::NodeAddress const QString &  hostName,
quint16  hostPort
 

Definition at line 37 of file NodeAddress.cpp.

NodeAddress::NodeAddress const QString &  addressPortString  ) 
 

Constructs a NodeAddress from a string.

This constructor constructs a NodeAddress object by parsing the addressPortString. The following formats can now be parsed:

domain_name:port IPv4_address:port (e.g. 192.168.0.1:1234)

Todo:
Add support for parsing IPv6:port addreses (they use : and .)
Todo:
Check for ':' for the port, but have in mind it's ok

Definition at line 53 of file NodeAddress.cpp.

NodeAddress::~NodeAddress  ) 
 

Definition at line 73 of file NodeAddress.cpp.


Member Function Documentation

QHostAddress Protocols::Transports::NodeAddress::hostAddress  )  const [inline]
 

Definition at line 96 of file NodeAddress.h.

QString Protocols::Transports::NodeAddress::hostName  )  const [inline]
 

Definition at line 93 of file NodeAddress.h.

quint16 Protocols::Transports::NodeAddress::hostPort  )  const [inline]
 

Definition at line 99 of file NodeAddress.h.

bool Protocols::Transports::NodeAddress::isNull  )  const [inline]
 

Definition at line 90 of file NodeAddress.h.

bool Protocols::Transports::NodeAddress::operator!= const NodeAddress nodeAddress  )  const [inline]
 

Definition at line 87 of file NodeAddress.h.

bool NodeAddress::operator< const NodeAddress nodeAddress  )  const
 

Definition at line 82 of file NodeAddress.cpp.

bool NodeAddress::operator== const NodeAddress nodeAddress  )  const
 

Definition at line 77 of file NodeAddress.cpp.

void Protocols::Transports::NodeAddress::setHostAddress const QHostAddress &  hostAddress  )  [inline]
 

Definition at line 109 of file NodeAddress.h.

void Protocols::Transports::NodeAddress::setHostName const QString &  hostName  )  [inline]
 

Definition at line 103 of file NodeAddress.h.

void Protocols::Transports::NodeAddress::setHostPort quint16  hostPort  )  [inline]
 

Definition at line 112 of file NodeAddress.h.

QString NodeAddress::toString  )  const
 

Definition at line 93 of file NodeAddress.cpp.


Member Data Documentation

QHostAddress Protocols::Transports::NodeAddress::hostAddress_ [private]
 

Definition at line 74 of file NodeAddress.h.

QString Protocols::Transports::NodeAddress::hostName_ [private]
 

Definition at line 73 of file NodeAddress.h.

quint16 Protocols::Transports::NodeAddress::hostPort_ [private]
 

Definition at line 75 of file NodeAddress.h.

const NodeAddress NodeAddress::Null = NodeAddress() [static]
 

Definition at line 70 of file NodeAddress.h.


The documentation for this class was generated from the following files: