Represents how to reach a part of a YARP network. More...
#include <yarp/os/Contact.h>
Public Member Functions | |
Contact (const std::string &name=std::string(), const std::string &carrier=std::string(), const std::string &hostname=std::string(), int port=-1) | |
Constructor. More... | |
Contact (const std::string &hostname, int port) | |
Constructor by hostname and port. More... | |
Contact (const std::string &carrier, const std::string &hostname, int port) | |
Constructor by socket. More... | |
Contact (const Contact &rhs) | |
Copy constructor. More... | |
Contact (Contact &&rhs) noexcept | |
Move constructor. More... | |
virtual | ~Contact () |
Destructor. More... | |
Contact & | operator= (const Contact &rhs) |
Copy assignment operator. More... | |
Contact & | operator= (Contact &&rhs) noexcept |
Move assignment operator. More... | |
std::string | getName () const |
Get the name associated with this Contact. More... | |
void | setName (const std::string &name) |
Set the name associated with this Contact. More... | |
std::string | getRegName () const |
Get the name associated with this Contact. More... | |
std::string | getHost () const |
Get the host name associated with this Contact for socket communication. More... | |
void | setHost (const std::string &hostname) |
Set the host name to be the input parameter. More... | |
int | getPort () const |
Get the port number associated with this Contact for socket communication. More... | |
void | setPort (int port) |
Set the port number to be the input parameter. More... | |
std::string | getCarrier () const |
Get the carrier associated with this Contact for socket communication. More... | |
void | setCarrier (const std::string &carrier) |
Set the carrier to use for this Contact. More... | |
const NestedContact & | getNested () const |
Get the NestedContact containing extra information for this Contact. More... | |
void | setNestedContact (const yarp::os::NestedContact &nestedContact) |
Sets the NestedContact containing extra information for this Contact. More... | |
bool | hasTimeout () const |
Check if this Contact has a timeout. More... | |
float | getTimeout () const |
Get timeout for this Address. More... | |
void | setTimeout (float timeout) |
Set timeout for this Contact. More... | |
void | setSocket (const std::string &carrier, const std::string &hostname, int port) |
Set information to a Contact about how to reach it using socket communication. More... | |
bool | isValid () const |
Checks if a Contact is tagged as valid. More... | |
std::string | toString () const |
Get a textual representation of the Contact. More... | |
std::string | toURI (bool includeCarrier=true) const |
Get a representation of the Contact as a URI. More... | |
Static Public Member Functions | |
static Contact | fromConfig (const Searchable &config) |
Factory method. More... | |
static Contact | fromString (const std::string &txt) |
Factory method. More... | |
static std::string | convertHostToIp (const char *name) |
If the host is a machine name, convert it to a plausible IP address. More... | |
Represents how to reach a part of a YARP network.
May contain complete or partial information about network parameters. Use the constructors or the factory methods (Contact::fromString, Contact::fromConfig) to create Contact objects.
Contact::Contact | ( | const std::string & | name = std::string() , |
const std::string & | carrier = std::string() , |
||
const std::string & | hostname = std::string() , |
||
int | port = -1 |
||
) |
Constructor.
name | the name |
carrier | the carrier |
hostname | the hostname |
port | the port number |
Definition at line 92 of file Contact.cpp.
Contact::Contact | ( | const std::string & | hostname, |
int | port | ||
) |
Constructor by hostname and port.
hostname | the hostname |
port | the port number |
Definition at line 79 of file Contact.cpp.
Contact::Contact | ( | const std::string & | carrier, |
const std::string & | hostname, | ||
int | port | ||
) |
Constructor by socket.
carrier | the carrier |
hostname | the hostname |
port | the port number |
Definition at line 85 of file Contact.cpp.
Contact::Contact | ( | const Contact & | rhs | ) |
|
noexcept |
|
virtual |
Destructor.
Definition at line 111 of file Contact.cpp.
|
static |
If the host is a machine name, convert it to a plausible IP address.
name | the name to convert |
Definition at line 334 of file Contact.cpp.
|
static |
Factory method.
Returns a Contact configured from the information in config.
config | a Property, Bottle, or other Searchable containing the Contact configuration. Key names include "name", "ip", "port_number", "carrier" |
Definition at line 132 of file Contact.cpp.
|
static |
Factory method.
Parse a textual representation of a Contact.
txt | the text to parse |
Definition at line 142 of file Contact.cpp.
std::string Contact::getCarrier | ( | ) | const |
Get the carrier associated with this Contact for socket communication.
Definition at line 253 of file Contact.cpp.
std::string Contact::getHost | ( | ) | const |
Get the host name associated with this Contact for socket communication.
Definition at line 231 of file Contact.cpp.
std::string Contact::getName | ( | ) | const |
Get the name associated with this Contact.
If the name is not set, it is generated from hostname and port.
Definition at line 208 of file Contact.cpp.
const NestedContact & Contact::getNested | ( | ) | const |
Get the NestedContact containing extra information for this Contact.
Definition at line 264 of file Contact.cpp.
int Contact::getPort | ( | ) | const |
Get the port number associated with this Contact for socket communication.
Definition at line 242 of file Contact.cpp.
std::string Contact::getRegName | ( | ) | const |
Get the name associated with this Contact.
The regName is not generated and is set only using setName, or one of the factory methods (byName, byConfig, and fromString).
Definition at line 220 of file Contact.cpp.
float Contact::getTimeout | ( | ) | const |
Get timeout for this Address.
Definition at line 280 of file Contact.cpp.
bool Contact::hasTimeout | ( | ) | const |
Check if this Contact has a timeout.
Definition at line 275 of file Contact.cpp.
bool Contact::isValid | ( | ) | const |
Checks if a Contact is tagged as valid.
Definition at line 301 of file Contact.cpp.
Copy assignment operator.
rhs | the Contact to copy |
Definition at line 116 of file Contact.cpp.
Move assignment operator.
rhs | the Contact to be moved |
Definition at line 124 of file Contact.cpp.
void Contact::setCarrier | ( | const std::string & | carrier | ) |
Set the carrier to use for this Contact.
carrier | the new carrier |
Definition at line 258 of file Contact.cpp.
void Contact::setHost | ( | const std::string & | hostname | ) |
Set the host name to be the input parameter.
hostname | the new host name |
Definition at line 236 of file Contact.cpp.
void Contact::setName | ( | const std::string & | name | ) |
Set the name associated with this Contact.
name | the new name |
Definition at line 225 of file Contact.cpp.
void Contact::setNestedContact | ( | const yarp::os::NestedContact & | nestedContact | ) |
Sets the NestedContact containing extra information for this Contact.
nestedContact | the nested Contact |
Definition at line 269 of file Contact.cpp.
void Contact::setPort | ( | int | port | ) |
Set the port number to be the input parameter.
port | the new port number |
Definition at line 247 of file Contact.cpp.
void Contact::setSocket | ( | const std::string & | carrier, |
const std::string & | hostname, | ||
int | port | ||
) |
Set information to a Contact about how to reach it using socket communication.
carrier | the carrier (network protocol) to use |
hostname | the name of the host machine (usually expressed as an IP address) |
port | the number of the socket port to use |
Definition at line 291 of file Contact.cpp.
void Contact::setTimeout | ( | float | timeout | ) |
Set timeout for this Contact.
timeout | The timeout to set. |
Definition at line 285 of file Contact.cpp.
std::string Contact::toString | ( | ) | const |
Get a textual representation of the Contact.
Definition at line 306 of file Contact.cpp.
std::string Contact::toURI | ( | bool | includeCarrier = true | ) | const |
Get a representation of the Contact as a URI.
includeCarrier | if false do not include the carrier in the URI |
Definition at line 316 of file Contact.cpp.