GNet::ResolverInfo Class Reference

A class that holds a host/service name pair and optionally the results of a name-to-address lookup, ie. More...

#include <gresolverinfo.h>

List of all members.

Public Member Functions

 ResolverInfo (const std::string &host, const std::string &service)
 Constructor.
 ResolverInfo (const std::string &host_and_service)
 Implicit constructor. Throws if an invalid format.
 ResolverInfo (const char *host_and_service)
 Implicit constructor. Throws if an invalid format.
std::string host () const
 Returns the remote host name, as passed in to the constructor.
std::string service () const
 Returns the remote service name, as passed in to the constructor.
void update (const Address &address, const std::string &canonical_name)
 Updates the address and canonical name, typically after doing a name lookup on host() and service().
bool hasAddress () const
 Returns true after update() has been called.
Address address () const
 Returns the remote address.
std::string name () const
 Returns the remote canonical name.
std::string str () const
 Returns a string representation of the host and service names that can be passed to the Resolver's resolveReq() method.
std::string displayString (bool simple=false) const
 Returns a string representation for logging and debug.
G::DateTime::EpochTime updateTime () const
 Returns the time of the last update().


Detailed Description

A class that holds a host/service name pair and optionally the results of a name-to-address lookup, ie.

the remote address and canonical host name. The actual name lookup is done externally, and the results are deposited into the ResolverInfo object with update().

This class can be used to minimise the amount of name lookup performed when the same host/service name is used repeatedly. See GNet::ClientPtr for an example of this.

Definition at line 48 of file gresolverinfo.h.


Constructor & Destructor Documentation

GNet::ResolverInfo::ResolverInfo ( const std::string &  host,
const std::string &  service 
)

Constructor.

Definition at line 54 of file gresolverinfo.cpp.

GNet::ResolverInfo::ResolverInfo ( const std::string &  host_and_service  ) 

Implicit constructor. Throws if an invalid format.

Definition at line 36 of file gresolverinfo.cpp.

GNet::ResolverInfo::ResolverInfo ( const char *  host_and_service  ) 

Implicit constructor. Throws if an invalid format.

Definition at line 45 of file gresolverinfo.cpp.


Member Function Documentation

std::string GNet::ResolverInfo::host (  )  const

Returns the remote host name, as passed in to the constructor.

Definition at line 63 of file gresolverinfo.cpp.

Referenced by GNet::Resolver::resolve(), and GNet::SimpleClient::updateResolverInfo().

std::string GNet::ResolverInfo::service (  )  const

Returns the remote service name, as passed in to the constructor.

Definition at line 68 of file gresolverinfo.cpp.

Referenced by GNet::Resolver::resolve(), and GNet::SimpleClient::updateResolverInfo().

void GNet::ResolverInfo::update ( const Address address,
const std::string &  canonical_name 
)

Updates the address and canonical name, typically after doing a name lookup on host() and service().

Definition at line 83 of file gresolverinfo.cpp.

References G::DateTime::now().

bool GNet::ResolverInfo::hasAddress (  )  const

Returns true after update() has been called.

Definition at line 73 of file gresolverinfo.cpp.

Referenced by GNet::SimpleClient::connect(), displayString(), and GNet::SimpleClient::updateResolverInfo().

GNet::Address GNet::ResolverInfo::address (  )  const

Returns the remote address.

Definition at line 78 of file gresolverinfo.cpp.

Referenced by displayString(), and GNet::SimpleClient::writeEvent().

std::string GNet::ResolverInfo::name (  )  const

Returns the remote canonical name.

Returns the empty string if not available.

Definition at line 91 of file gresolverinfo.cpp.

Referenced by displayString().

std::string GNet::ResolverInfo::str (  )  const

Returns a string representation of the host and service names that can be passed to the Resolver's resolveReq() method.

Definition at line 96 of file gresolverinfo.cpp.

Referenced by GNet::SimpleClient::connect().

std::string GNet::ResolverInfo::displayString ( bool  simple = false  )  const

G::DateTime::EpochTime GNet::ResolverInfo::updateTime (  )  const

Returns the time of the last update().

Used in cacheing. Returns zero if not update()d.

Definition at line 118 of file gresolverinfo.cpp.


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

Generated on Fri Apr 18 15:56:13 2008 for E-MailRelay by  doxygen 1.5.5