YARP
Yet Another Robot Platform
yarp::os::impl::NameClient Class Reference

Client for YARP name server. More...

#include <yarp/os/impl/NameClient.h>

Public Member Functions

virtual ~NameClient ()
 Destructor. More...
 
Contact getAddress ()
 The address of the name server. More...
 
Contact queryName (const std::string &name)
 Look up the address of a named port. More...
 
Contact registerName (const std::string &name)
 Register a port with a given name. More...
 
Contact registerName (const std::string &name, const Contact &suggest)
 Register a port with a given name and a partial address. More...
 
Contact unregisterName (const std::string &name)
 Register disassociation of name from port. More...
 
Contact probe (const std::string &cmd)
 Send a message to the name server, and interpret the result as an address. More...
 
std::string send (const std::string &cmd, bool multi=true, const ContactStyle &style=ContactStyle())
 Send a text message to the nameserver, and return the result. More...
 
bool send (yarp::os::Bottle &cmd, yarp::os::Bottle &reply)
 Send a message to the nameserver in Bottle format, and return the result. More...
 
void setFakeMode (bool fake=true)
 For testing, the nameclient can be set to use a "fake" name server rather than communicating with an external name server. More...
 
bool isFakeMode () const
 Check whether a fake name server is being used. More...
 
void setScan (bool allow=true)
 Control whether the name client should scan for the name server if the cached connection information for it is inaccurate. More...
 
void setSave (bool allow=true)
 Control whether the name client can save the address of the name server in a cache file. More...
 
bool didScan ()
 Check whether the name client scanned for the address of the name server. More...
 
bool didSave ()
 Check whether the name client saved the address of the name server. More...
 
bool updateAddress ()
 Force the name client to reread the cached location of the name server. More...
 
bool setContact (const yarp::os::Contact &contact)
 
void queryBypass (NameStore *store)
 
NameStoregetQueryBypass ()
 
std::string getMode ()
 
yarp::os::NodesgetNodes ()
 

Static Public Member Functions

static NameClientgetNameClient ()
 Get an instance of the name client. More...
 
static NameClientcreate ()
 
static Contact extractAddress (const std::string &txt)
 Extract an address from its text representation. More...
 
static Contact extractAddress (const Bottle &bot)
 

Detailed Description

Client for YARP name server.

There is one global client available from the getNameClient method. The protocol spoken by the name client is rather old; there are simpler ways of talking to the name server these days - it is now a regular port, that can read and respond to messages in the bottle format.

Definition at line 34 of file NameClient.h.

Constructor & Destructor Documentation

◆ ~NameClient()

NameClient::~NameClient ( )
virtual

Destructor.

Definition at line 120 of file NameClient.cpp.

Member Function Documentation

◆ create()

NameClient * NameClient::create ( )
static

Definition at line 134 of file NameClient.cpp.

◆ didSave()

bool NameClient::didSave ( )

Check whether the name client saved the address of the name server.

Returns
true iff the name client saved the address of the name server.

Definition at line 450 of file NameClient.cpp.

◆ didScan()

bool NameClient::didScan ( )

Check whether the name client scanned for the address of the name server.

Returns
true iff the name client scanned for the name server.

Definition at line 445 of file NameClient.cpp.

◆ extractAddress() [1/2]

Contact NameClient::extractAddress ( const Bottle bot)
static

Definition at line 289 of file NameClient.cpp.

◆ extractAddress() [2/2]

Contact NameClient::extractAddress ( const std::string &  txt)
static

Extract an address from its text representation.

Parameters
txtthe text representation of an address
Returns
the address corresponding to the text representation

Definition at line 273 of file NameClient.cpp.

◆ getAddress()

Contact NameClient::getAddress ( )

The address of the name server.

Returns
the address of the name server

Definition at line 140 of file NameClient.cpp.

◆ getMode()

std::string NameClient::getMode ( )

Definition at line 489 of file NameClient.cpp.

◆ getNameClient()

NameClient & NameClient::getNameClient ( )
static

Get an instance of the name client.

This is a global singleton, created on demand.

Returns
the name client

Definition at line 128 of file NameClient.cpp.

◆ getNodes()

yarp::os::Nodes & NameClient::getNodes ( )

Definition at line 494 of file NameClient.cpp.

◆ getQueryBypass()

NameStore * NameClient::getQueryBypass ( )

Definition at line 484 of file NameClient.cpp.

◆ isFakeMode()

bool NameClient::isFakeMode ( ) const

Check whether a fake name server is being used.

Returns
true iff a fake name server is being used.

Definition at line 430 of file NameClient.cpp.

◆ probe()

Contact NameClient::probe ( const std::string &  cmd)

Send a message to the name server, and interpret the result as an address.

Parameters
cmdthe message to send (in text form)
Returns
the address extracted from the reply, all errors result in a non-valid address.

Definition at line 267 of file NameClient.cpp.

◆ queryBypass()

void NameClient::queryBypass ( NameStore store)

Definition at line 479 of file NameClient.cpp.

◆ queryName()

Contact NameClient::queryName ( const std::string &  name)

Look up the address of a named port.

Parameters
namethe name of the port
Returns
the address associated with the port

Definition at line 146 of file NameClient.cpp.

◆ registerName() [1/2]

Contact NameClient::registerName ( const std::string &  name)

Register a port with a given name.

Parameters
namethe name of the port
Returns
the address associated with the port

Definition at line 166 of file NameClient.cpp.

◆ registerName() [2/2]

Contact NameClient::registerName ( const std::string &  name,
const Contact suggest 
)

Register a port with a given name and a partial address.

Parameters
namethe name of the port
suggesta partially completed address
Returns
the address associated with the port

Definition at line 171 of file NameClient.cpp.

◆ send() [1/2]

std::string NameClient::send ( const std::string &  cmd,
bool  multi = true,
const ContactStyle style = ContactStyle() 
)

Send a text message to the nameserver, and return the result.

Parameters
cmdthe message to send.
multiwhether to expect a multi-line response.
Returns
the reply from the name server.

Definition at line 302 of file NameClient.cpp.

◆ send() [2/2]

bool NameClient::send ( yarp::os::Bottle cmd,
yarp::os::Bottle reply 
)

Send a message to the nameserver in Bottle format, and return the result.

Parameters
[in]cmdthe message to send.
[out]thereply from the name server.
Returns
true on success.

Definition at line 407 of file NameClient.cpp.

◆ setContact()

bool NameClient::setContact ( const yarp::os::Contact contact)

Definition at line 468 of file NameClient.cpp.

◆ setFakeMode()

void NameClient::setFakeMode ( bool  fake = true)

For testing, the nameclient can be set to use a "fake" name server rather than communicating with an external name server.

Parameters
fakewhether to use a fake name server

Definition at line 425 of file NameClient.cpp.

◆ setSave()

void NameClient::setSave ( bool  allow = true)

Control whether the name client can save the address of the name server in a cache file.

Parameters
allowtrue if the name client may save the name server address.

Definition at line 440 of file NameClient.cpp.

◆ setScan()

void NameClient::setScan ( bool  allow = true)

Control whether the name client should scan for the name server if the cached connection information for it is inaccurate.

Parameters
allowtrue if the name client may scan for the name server.

Definition at line 435 of file NameClient.cpp.

◆ unregisterName()

Contact NameClient::unregisterName ( const std::string &  name)

Register disassociation of name from port.

Parameters
namethe name to remove
Returns
the new result of queries for that name (should be empty)

Definition at line 260 of file NameClient.cpp.

◆ updateAddress()

bool NameClient::updateAddress ( )

Force the name client to reread the cached location of the name server.

Returns
true if the address for the name server was found.

Definition at line 455 of file NameClient.cpp.


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