|
YARP
Yet Another Robot Platform
|
|
Go to the documentation of this file.
22 #define HELPER(x) (*((NameClient*)((x)->system_resource)))
31 yAssert(system_resource !=
nullptr);
32 HELPER(
this).setContact(contact);
33 this->contact = contact;
38 if (system_resource !=
nullptr) {
40 system_resource =
nullptr;
53 return registerContact(
Contact(name));
59 yCDebug(YARPNAMESPACE,
"Registering contact: %s", contact.
toURI().c_str());
61 yCDebug(YARPNAMESPACE,
"Registered address: %s", address.
toURI().c_str());
69 bool publish = (
cat.find(
'+') != std::string::npos);
70 bool subscribe = (
cat.find(
'-') != std::string::npos);
76 connectPortToTopic(c2, c1, style);
80 connectPortToTopic(c1, c2, style);
94 bool publish = (
cat.find(
'+') != std::string::npos);
95 bool subscribe = (
cat.find(
'-') != std::string::npos);
100 disconnectPortFromTopic(c2, c1, style);
103 disconnectPortFromTopic(c1, c2, style);
127 nic.
send(command, reply);
128 return reply.
size() > 0;
140 nic.
send(command, reply);
153 if (useDetectedServer) {
156 nic.
send(
"ping",
false);
176 Contact srv = getNameServerContact();
177 std::string cmd0 =
"NAME_SERVER";
183 for (
size_t i = 0; i < in.
size(); i++) {
188 std::string result = nic.
send(cmd0,
true, style);
194 return !result.empty();
A dummy connection to test yarp::os::Portable implementations.
A simple collection of objects that can be described and transmitted in a portable way.
std::string toString() const override
Gives a human-readable textual representation of the bottle.
virtual bool read(ConnectionReader &reader)=0
Read this object from a network connection.
Contact queryName(const std::string &name) override
Map from port name to contact information.
size_type size() const
Gets the number of elements in the bottle.
bool didSave()
Check whether the name client saved the address of the name server.
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.
Contact queryName(const std::string &name)
Look up the address of a named port.
Contact registerName(const std::string &name)
Register a port with a given name.
Contact registerName(const std::string &name) override
Record contact information to tie to a port name.
ConnectionReader & getReader(ConnectionWriter *replyWriter=nullptr)
Get the dummy ConnectionReader loaded with whatever was written the ConnectionWriter since it was las...
Interface implemented by all objects that can write themselves to the network, such as Bottle objects...
Contact registerContact(const Contact &contact) override
Record contact information (should include a port name).
virtual Contact detectNameServer(bool useDetectedServer, bool &scanNeeded, bool &serverUsed) override
Find a name server for this NameSpace, if applicable.
std::string getNamespace(bool refresh=false)
Contact unregisterName(const std::string &name)
Register disassociation of name from port.
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
bool write(ConnectionWriter &writer) const override
Output a representation of the bottle to a network connection.
void setScan(bool allow=true)
Control whether the name client should scan for the name server if the cached connection information ...
ConnectionWriter & getWriter()
Get the dummy ConnectionWriter loaded with whatever was written the ConnectionWriter since it was las...
static NameClient * create()
virtual bool setProperty(const std::string &name, const std::string &key, const Value &value) override
Associate a key/value pair with a named port.
bool didScan()
Check whether the name client scanned for the address of the name server.
virtual Value * getProperty(const std::string &name, const std::string &key) override
Get the value of a named key from a named port.
bool updateAddress()
Force the name client to reread the cached location of the name server.
virtual bool write(ConnectionWriter &writer) const =0
Write this object to a network connection.
void addString(const char *str)
Places a string in the bottle, at the end of the list.
virtual bool writeToNameServer(PortWriter &cmd, PortReader &reply, const ContactStyle &style) override
Write a message to a name server for this NameSpace, if applicable.
static Value * makeValue(const std::string &txt)
Create a Value from a text description.
Client for YARP name server.
An interface to the operating system, including Port based communication.
#define yCDebug(component,...)
void cat(Vector &a, const Vector &b)
void setSave(bool allow=true)
Control whether the name client can save the address of the name server in a cache file.
bool read(ConnectionReader &reader) override
Set the bottle's value based on input from a network connection.
Contact getAddress()
The address of the name server.
Contact unregisterName(const std::string &name) override
Disassociate contact information from a port name.
void add(const Value &value)
Add a Value to the bottle, at the end of the list.
std::string toString() const override
Return a standard text representation of the content of the object.
A single value (typically within a Bottle).
Small helper class to help deal with legacy YARP configuration files.
#define YARP_OS_LOG_COMPONENT(name, name_string)
The components from which ports and connections are built.
void setFakeMode(bool fake=true)
For testing, the nameclient can be set to use a "fake" name server rather than communicating with an ...
YarpNameSpace(const Contact &contact)
Contact unregisterContact(const Contact &contact) override
Disassociate contact information (should include a port name).