0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Types | Public Member Functions | Public Attributes | Private Attributes | List of all members
Hypertable::CommAddress Class Reference

Address abstraction to hold either proxy name or IPv4:port address. More...

#include <CommAddress.h>

Collaboration diagram for Hypertable::CommAddress:
Collaboration graph
[legend]

Public Types

enum  AddressType { NONE =0, PROXY, INET }
 Enumeration for address type. More...
 

Public Member Functions

 CommAddress ()
 Constructs an uninitialized CommAddress object. More...
 
 CommAddress (const sockaddr_in addr)
 Constructs a CommAddress object of type CommAddress::INET. More...
 
void set_proxy (const String &str)
 Sets address type to CommAddress::PROXY and proxy name to p. More...
 
void set_inet (sockaddr_in addr)
 Sets address type to CommAddress::INET and inet value to addr. More...
 
CommAddressoperator= (sockaddr_in addr)
 Sets address type to CommAddress::INET and inet value to addr. More...
 
bool operator== (const CommAddress &other) const
 Equality operator. More...
 
bool operator!= (const CommAddress &other) const
 Inequality operator. More...
 
bool operator< (const CommAddress &other) const
 Less than operator. More...
 
bool is_proxy () const
 Returns true if address is of type CommAddress::PROXY. More...
 
bool is_inet () const
 Returns true if address is of type CommAddress::INET. More...
 
bool is_set () const
 Returns true if address has been initialized. More...
 
void clear ()
 Clears address to uninitialized state. More...
 
String to_str () const
 Returns string representation of address. More...
 

Public Attributes

String proxy
 Proxy name. More...
 
InetAddr inet
 IPv4:port address. More...
 

Private Attributes

int32_t m_type
 Address type. More...
 

Detailed Description

Address abstraction to hold either proxy name or IPv4:port address.

Proxy names are string mnemonics referring to IPv4:port addresses and are defined or modified via Comm::add_proxy method. Most Comm methods that operate on an address are abstracted to accept either a proxy name (translated internally) or an IPv4:port address. The CommAddress class is used to facilitate that abstraction.

Definition at line 52 of file CommAddress.h.

Constructor & Destructor Documentation

Hypertable::CommAddress::CommAddress ( )
inline

Constructs an uninitialized CommAddress object.

Definition at line 65 of file CommAddress.h.

Hypertable::CommAddress::CommAddress ( const sockaddr_in  addr)
inline

Constructs a CommAddress object of type CommAddress::INET.

Parameters
addrIPv4:port address

Definition at line 70 of file CommAddress.h.

Member Function Documentation

void Hypertable::CommAddress::clear ( )
inline

Clears address to uninitialized state.

Sets address type to CommAddress::NONE

Definition at line 164 of file CommAddress.h.

bool Hypertable::CommAddress::is_inet ( ) const
inline

Returns true if address is of type CommAddress::INET.

Returns
true if address is of type CommAddress::INET, false otherwise

Definition at line 153 of file CommAddress.h.

bool Hypertable::CommAddress::is_proxy ( ) const
inline

Returns true if address is of type CommAddress::PROXY.

Returns
true if address is of type CommAddress::PROXY, false otherwise

Definition at line 147 of file CommAddress.h.

bool Hypertable::CommAddress::is_set ( ) const
inline

Returns true if address has been initialized.

Returns
true if address is of type CommAddress::PROXY or CommAddress::INET, false otherwise

Definition at line 159 of file CommAddress.h.

bool Hypertable::CommAddress::operator!= ( const CommAddress other) const
inline

Inequality operator.

Returns the exact opposite of what is returned by operator==

Parameters
otherobject to compare to
Returns
true if addresses are not equal, false otherwise

Definition at line 117 of file CommAddress.h.

bool Hypertable::CommAddress::operator< ( const CommAddress other) const
inline

Less than operator.

If address types differ, then an integer less than comparison of the AddressType values (m_type) is returned. If addresses are of type CommAddress::PROXY, then string less than comparison of the proxy members is returned. If addresses are of type CommAddress::INET then Inet::operator< is used to compare the IP addresses, and if addresses are of type CommAddress::NONE, false is returned.

Parameters
otherobject on right-hand side of comparison
Returns
true if address is less than other, false otherwise

Definition at line 132 of file CommAddress.h.

CommAddress& Hypertable::CommAddress::operator= ( sockaddr_in  addr)
inline

Sets address type to CommAddress::INET and inet value to addr.

Parameters
addrIPv4:port address
Returns
reference to this CommAddress object

Definition at line 89 of file CommAddress.h.

bool Hypertable::CommAddress::operator== ( const CommAddress other) const
inline

Equality operator.

If address is of type CommAddress::PROXY, std::string::compare is used to compare proxy members. If address is of type CommAddress::INET, InetAddr::operator== is used to compare inet members. If both addresses are of type CommAddress::NONE, true is returned. false is returned if the addresses are of different types.

Parameters
otherobject to compare to
Returns
true if addresses are equal, false otherwise

Definition at line 102 of file CommAddress.h.

void Hypertable::CommAddress::set_inet ( sockaddr_in  addr)
inline

Sets address type to CommAddress::INET and inet value to addr.

Parameters
addrIPv4:port address

Definition at line 82 of file CommAddress.h.

void Hypertable::CommAddress::set_proxy ( const String str)
inline

Sets address type to CommAddress::PROXY and proxy name to p.

Parameters
strproxy name

Definition at line 76 of file CommAddress.h.

String CommAddress::to_str ( ) const

Returns string representation of address.

If address is of type CommAddress::PROXY, the proxy is returned. If address is of type CommAddress::INET, InetAddr::format is used to return a string representation of inet. If address is of type CommAddress::NONE, the string "[NULL]" is returned.

Returns
string representation of address

Definition at line 34 of file CommAddress.cc.

Member Data Documentation

InetAddr Hypertable::CommAddress::inet

IPv4:port address.

Definition at line 176 of file CommAddress.h.

int32_t Hypertable::CommAddress::m_type
private

Address type.

Definition at line 179 of file CommAddress.h.

String Hypertable::CommAddress::proxy

Proxy name.

Definition at line 175 of file CommAddress.h.


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