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. | |
Contact (const std::string &hostname, int port) | |
Constructor by hostname and port. | |
Contact (const std::string &carrier, const std::string &hostname, int port) | |
Constructor by socket. | |
Contact (const Contact &rhs) | |
Copy constructor. | |
Contact (Contact &&rhs) noexcept | |
Move constructor. | |
Contact & | operator= (const Contact &rhs) |
Copy assignment operator. | |
Contact & | operator= (Contact &&rhs) noexcept |
Move assignment operator. | |
std::string | getName () const |
Get the name associated with this Contact. | |
void | setName (const std::string &name) |
Set the name associated with this Contact. | |
std::string | getRegName () const |
Get the name associated with this Contact. | |
std::string | getHost () const |
Get the host name associated with this Contact for socket communication. | |
void | setHost (const std::string &hostname) |
Set the host name to be the input parameter. | |
int | getPort () const |
Get the port number associated with this Contact for socket communication. | |
void | setPort (int port) |
Set the port number to be the input parameter. | |
std::string | getCarrier () const |
Get the carrier associated with this Contact for socket communication. | |
void | setCarrier (const std::string &carrier) |
Set the carrier to use for this Contact. | |
const NestedContact & | getNested () const |
Get the NestedContact containing extra information for this Contact. | |
void | setNestedContact (const yarp::os::NestedContact &nestedContact) |
Sets the NestedContact containing extra information for this Contact. | |
bool | hasTimeout () const |
Check if this Contact has a timeout. | |
float | getTimeout () const |
Get timeout for this Address. | |
void | setTimeout (float timeout) |
Set timeout for this Contact. | |
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. | |
bool | isValid () const |
Checks if a Contact is tagged as valid. | |
std::string | toString () const |
Get a textual representation of the Contact. | |
std::string | toURI (bool includeCarrier=true) const |
Get a representation of the Contact as a URI. | |
Static Public Member Functions | |
static Contact | fromConfig (const Searchable &config) |
Factory method. | |
static Contact | fromString (const std::string &txt) |
Factory method. | |
static std::string | convertHostToIp (const char *name) |
If the host is a machine name, convert it to a plausible IP address. | |
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 89 of file Contact.cpp.
Constructor by hostname and port.
hostname | the hostname |
port | the port number |
Definition at line 76 of file Contact.cpp.
Constructor by socket.
carrier | the carrier |
hostname | the hostname |
port | the port number |
Definition at line 82 of file Contact.cpp.
|
noexcept |
|
virtual |
Destructor.
Definition at line 108 of file Contact.cpp.
If the host is a machine name, convert it to a plausible IP address.
name | the name to convert |
Definition at line 331 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 129 of file Contact.cpp.
Factory method.
Parse a textual representation of a Contact.
txt | the text to parse |
Definition at line 139 of file Contact.cpp.
std::string Contact::getCarrier | ( | ) | const |
Get the carrier associated with this Contact for socket communication.
Definition at line 250 of file Contact.cpp.
std::string Contact::getHost | ( | ) | const |
Get the host name associated with this Contact for socket communication.
Definition at line 228 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 205 of file Contact.cpp.
const NestedContact & Contact::getNested | ( | ) | const |
Get the NestedContact containing extra information for this Contact.
Definition at line 261 of file Contact.cpp.
int Contact::getPort | ( | ) | const |
Get the port number associated with this Contact for socket communication.
Definition at line 239 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 217 of file Contact.cpp.
float Contact::getTimeout | ( | ) | const |
Get timeout for this Address.
Definition at line 277 of file Contact.cpp.
bool Contact::hasTimeout | ( | ) | const |
Check if this Contact has a timeout.
Definition at line 272 of file Contact.cpp.
bool Contact::isValid | ( | ) | const |
Checks if a Contact is tagged as valid.
Definition at line 298 of file Contact.cpp.
Copy assignment operator.
rhs | the Contact to copy |
Definition at line 113 of file Contact.cpp.
Move assignment operator.
rhs | the Contact to be moved |
Definition at line 121 of file Contact.cpp.
Set the carrier to use for this Contact.
carrier | the new carrier |
Definition at line 255 of file Contact.cpp.
Set the host name to be the input parameter.
hostname | the new host name |
Definition at line 233 of file Contact.cpp.
Set the name associated with this Contact.
name | the new name |
Definition at line 222 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 266 of file Contact.cpp.
Set the port number to be the input parameter.
port | the new port number |
Definition at line 244 of file Contact.cpp.
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 288 of file Contact.cpp.
Set timeout for this Contact.
timeout | The timeout to set. |
Definition at line 282 of file Contact.cpp.
std::string Contact::toString | ( | ) | const |
Get a textual representation of the Contact.
Definition at line 303 of file Contact.cpp.
Get a representation of the Contact as a URI.
includeCarrier | if false do not include the carrier in the URI |
Definition at line 313 of file Contact.cpp.