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();
void cat(Vector &a, const Vector &b)
A simple collection of objects that can be described and transmitted in a portable way.
void add(const Value &value)
Add a Value to the bottle, at the end of the list.
size_type size() const
Gets the number of elements in the bottle.
bool read(ConnectionReader &reader) override
Set the bottle's value based on input from a network connection.
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 addString(const char *str)
Places a string in the bottle, at the end of the list.
std::string toString() const override
Gives a human-readable textual representation of the bottle.
A dummy connection to test yarp::os::Portable implementations.
ConnectionWriter & getWriter()
Get the dummy ConnectionWriter loaded with whatever was written the ConnectionWriter since it was las...
ConnectionReader & getReader()
Get the dummy ConnectionReader loaded with whatever was written the ConnectionWriter since it was las...
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
virtual bool read(ConnectionReader &reader)=0
Read this object from a network connection.
Interface implemented by all objects that can write themselves to the network, such as Bottle objects...
virtual bool write(ConnectionWriter &writer) const =0
Write this object to a network connection.
A single value (typically within a Bottle).
static Value * makeValue(const std::string &txt)
Create a Value from a text description.
std::string toString() const override
Return a standard text representation of the content of the object.
Contact registerName(const std::string &name) override
Record contact information to tie to a port name.
virtual Value * getProperty(const std::string &name, const std::string &key) override
Get the value of a named key from a named port.
Contact unregisterName(const std::string &name) override
Disassociate contact information from a port name.
Contact unregisterContact(const Contact &contact) override
Disassociate contact information (should include a port name).
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.
virtual bool setProperty(const std::string &name, const std::string &key, const Value &value) override
Associate a key/value pair with a named port.
Contact queryName(const std::string &name) override
Map from port name to contact information.
virtual bool writeToNameServer(PortWriter &cmd, PortReader &reply, const ContactStyle &style) override
Write a message to a name server for this NameSpace, if applicable.
YarpNameSpace(const Contact &contact)
Client for YARP name server.
Contact unregisterName(const std::string &name)
Register disassociation of name from port.
bool didScan()
Check whether the name client scanned for the address of the name server.
static NameClient * create()
bool didSave()
Check whether the name client saved the address of the name server.
Contact getAddress()
The address of the name server.
bool updateAddress()
Force the name client to reread the cached location 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.
void setFakeMode(bool fake=true)
For testing, the nameclient can be set to use a "fake" name server rather than communicating with an ...
void setScan(bool allow=true)
Control whether the name client should scan for the name server if the cached connection information ...
Contact registerName(const std::string &name)
Register a port with a given name.
void setSave(bool allow=true)
Control whether the name client can save the address of the name server in a cache file.
Small helper class to help deal with legacy YARP configuration files.
std::string getNamespace(bool refresh=false)
#define yCDebug(component,...)
#define YARP_OS_LOG_COMPONENT(name, name_string)
The components from which ports and connections are built.
An interface to the operating system, including Port based communication.