#include <ControllerInfo.hpp>
Public Member Functions | |
ControllerInfo () | |
Empty contructor does nothing. | |
ControllerInfo (const std::wstring &host, in_port_t port) throw (ConnectionException, UnexpectedException) | |
Constructs a Controller info with the given name and port. | |
ControllerInfo (const ControllerInfo &ci) throw (ConnectionException, UnexpectedException) | |
Copy contructor. | |
~ControllerInfo () | |
Frees addrinfo. | |
DriverSocket * | connect (AbstractControllerPool &pool) throw (ConnectionException, UnexpectedException) |
Tries to connect to this controller and returns the connected socket, or throw ConnectionException in case of failure. | |
ControllerInfo & | operator= (const ControllerInfo &ci) |
Copy operator. | |
bool | operator< (const ControllerInfo &ci) const |
Less than operator used by ControllerPoolManager. | |
bool | operator== (const ControllerInfo &ci) const |
Comparison operator, uses < operator. | |
const SocketAddress & | getSocketAddress () const |
Returns the socket address associated to this controller. | |
operator std::wstring () const | |
Cast to wstring operator to ease printing (for debug/traces). | |
Friends | |
std::wostream & | operator<< (std::wostream &ostr, const ControllerInfo &ci) |
Pretty printer for controller info. |
This class holds the socket address to connect to and send/receive pings to/from, plus the original hostname (for debug)
CarobNS::ControllerInfo::ControllerInfo | ( | const std::wstring & | host, | |
in_port_t | port | |||
) | throw (ConnectionException, UnexpectedException) |
Constructs a Controller info with the given name and port.
This constructor is the one used at init time, by the user. It will determine the socket address to connect to and to send/receive pings to/from, which will be the first one returned by getaddrinfo()
host | hostname as a string. Can be either qualified name or numeric | |
port | host port |
ConnectionException | if the given hostname cannot be resolved |
CarobNS::ControllerInfo::ControllerInfo | ( | const ControllerInfo & | ci | ) | throw (ConnectionException, UnexpectedException) |
Copy contructor.
Calls = operator
ci | original controller to copy from |
ConnectionException | in case of memory allocation failure |
DriverSocket* CarobNS::ControllerInfo::connect | ( | AbstractControllerPool & | pool | ) | throw (ConnectionException, UnexpectedException) |
Tries to connect to this controller and returns the connected socket, or throw ConnectionException in case of failure.
Warning: Property of the created socket is transfered to caller, it is its job to delete it!
pool | the controller pool that manages us, in order to register the socket |
CarobNS::ControllerInfo::operator std::wstring | ( | ) | const |
Cast to wstring operator to ease printing (for debug/traces).
ControllerInfo& CarobNS::ControllerInfo::operator= | ( | const ControllerInfo & | ci | ) |
Copy operator.
ci | controller to copy informations from |
ConnectionException | in case of memory allocation failure |
std::wostream& operator<< | ( | std::wostream & | ostr, | |
const ControllerInfo & | ci | |||
) | [friend] |
Pretty printer for controller info.
Prints: <given/original hostname> (<resolved name/port>)
ostr | the wide stream to print to | |
ci | controller info to be pretty printed to ostr |