32 this->contact = contact;
56 if (
cat.find(
"-1") == std::string::npos) {
79 contact.
setCarrier(std::string(
"rossrv+service.") + name);
111 contact.
toURI().c_str());
126 rosrpc.setCarrier(
"rosrpc");
129 if (store !=
nullptr) {
142 }
else if (
cat ==
"+" ||
cat ==
"-") {
146 cmd.
addString((
cat ==
"+") ?
"registerPublisher" :
"registerSubscriber");
150 if (
typ !=
"*" && !
typ.empty()) {
152 if (
typ ==
"yarp/image") {
153 typ =
"sensor_msgs/Image";
155 if (
typ.find(
'/') == std::string::npos) {
156 typ = std::string(
"yarp/") +
typ;
161 if (store !=
nullptr) {
188 if (pending.
size() == 0) {
207 std::string name = contact.
getName();
208 size_t pub_idx = name.find(
"+#");
209 size_t sub_idx = name.find(
"-#");
214 if (
pub_idx != std::string::npos) {
215 node = name.substr(0,
pub_idx);
216 pub = name.substr(
pub_idx + 2, name.length());
219 if (
sub_idx != std::string::npos) {
220 node = name.substr(0,
sub_idx);
221 sub = name.substr(
sub_idx + 2, name.length());
227 yCDebug(
ROSNAMESPACE,
"Name [%s] Node [%s] sub [%s] pub [%s]", name.c_str(), node.c_str(),
sub.c_str(), pub.c_str());
277 c.setCarrier(
"rosrpc");
292 }
else if (
cat ==
"+" ||
cat ==
"-") {
296 cmd.
addString((
cat ==
"+") ?
"unregisterPublisher" :
"unregisterSubscriber");
300 if (store !=
nullptr) {
319 size_t pub_idx = name.find(
"+#");
320 size_t sub_idx = name.find(
"-#");
325 if (
pub_idx != std::string::npos) {
326 node = name.substr(0,
pub_idx);
327 pub = name.substr(
pub_idx + 2, name.length());
329 if (
sub_idx != std::string::npos) {
330 node = name.substr(0,
sub_idx);
331 sub = name.substr(
sub_idx + 2, name.length());
384 const std::string& key,
394 const std::string& key)
412 return connectTopic(cmd,
false, src, dest, style,
false);
438 return connectTopic(cmd,
false, src, dest, style,
false);
450 return connectTopic(cmd,
true, src, dest, style,
false);
494 bool fail = (reply.
check(
"faultCode",
Value(0)).asInt32() != 0) || !ok;
498 if (reply.
check(
"faultString")) {
507 if (lst !=
nullptr) {
508 cmd2.addString(
"publisherUpdate");
509 cmd2.addString(
"/yarp");
511 cmd2.addList() = *lst;
559 c.setCarrier(
"xmlrpc");
585 if (key ==
"query") {
590 reply2.addString(
c.toString());
598 cmd2.addString(
"getSystemState");
599 cmd2.addString(
"dummy_id");
612 if (
parts !=
nullptr) {
613 for (
int i = 0; i < 3; i++) {
615 if (part ==
nullptr) {
618 for (
size_t j = 0;
j < part->
size();
j++) {
620 if (
unit ==
nullptr) {
623 std::string
stem =
unit->get(0).asString();
625 if (
links ==
nullptr) {
633 for (
size_t j = 0;
j <
links->size();
j++) {
639 const char* title[3] = {
"node",
"topic",
"service"};
640 for (
int p = 0; p < 3; p++) {
643 for (
size_t i = 0; i <
blist.size(); i++) {
644 std::string name =
blist.get(i).asList()->get(0).asString();
647 info.addString(name);
661 if (name.find(
':') == std::string::npos) {
665 for (
char i : name) {
677 if (name.find(
"__") == std::string::npos) {
683 for (
char i : name) {
716 std::string carrier = ((contact.
getCarrier() ==
"rosrpc") ?
"rosrpc" :
"http");
717 std::string hostname = contact.
getHost();
732 pct = pending.
size();
752 pending = pending.
tail();
753 pct = pending.
size();
std::string toString(const T &value)
convert an arbitrary type to string.
void cat(Vector &a, const Vector &b)
A simple collection of objects that can be described and transmitted in a portable way.
void addVocab32(yarp::conf::vocab32_t x)
Places a vocabulary item in the bottle, at the end of the list.
Bottle & addList()
Places an empty nested list in 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 check(const std::string &key) const override
Check if there exists a property of the given name.
Bottle tail() const
Get all but the first element of a bottle.
void clear()
Empties the bottle of any objects it contains.
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 mini-server for performing network communication in the background.
std::string getName() const override
Get name of port.
T * read(bool shouldWait=true) override
Read an available object from the port.
void write(bool forceStrict=false)
Write the current object being returned by BufferedPort::prepare.
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(ConnectionWriter *replyWriter=nullptr)
Get the dummy ConnectionReader loaded with whatever was written the ConnectionWriter since it was las...
Abstract interface for a database of port names.
virtual Contact query(const std::string &name)=0
static bool connect(const std::string &src, const std::string &dest, const std::string &carrier="", bool quiet=true)
Request that an output port connect to an input port.
static Contact queryName(const std::string &name)
Find out information about a registered name.
static bool disconnect(const std::string &src, const std::string &dest, bool quiet)
Request that an output port disconnect from an input port.
static bool write(const Contact &contact, PortWriter &cmd, PortReader &reply, bool admin=false, bool quiet=false, double timeout=-1)
Send a single command to a port and await a single response.
Contact getURI(const std::string &name)
getURI queries the Node specified in the name parameter to get Contact information about the specifie...
Contact getParent(const std::string &name)
getParent get info about node associated with the specified port.
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 class for storing options and configuration information.
void put(const std::string &key, const std::string &value)
Associate the given key with the given string.
bool usesCentralServer() const override
Check if a central server is involved in managing the NameSpace.
Contact getNameServerContact() const override
Get an address for a name server that manages the name space, if available.
RosNameSpace(const Contact &contact)
bool localOnly() const override
Check if the NameSpace is only valid for the current process ("local").
virtual bool writeToNameServer(PortWriter &cmd, PortReader &reply, const ContactStyle &style) override
Write a message to a name server for this NameSpace, if applicable.
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).
virtual bool disconnectPortToPortPersistently(const Contact &src, const Contact &dest, const ContactStyle &style) override
Disconnect two ports, removing any persistence.
Contact queryName(const std::string &name) override
Map from port name to contact information.
virtual bool connectTopicToPort(const Contact &src, const Contact &dest, const ContactStyle &style) override
Subscribe a port to a topic.
Contact registerContact(const Contact &contact) override
Record contact information (should include a port name).
virtual bool connectPortToPortPersistently(const Contact &src, const Contact &dest, const ContactStyle &style) override
Connect two ports with persistence.
virtual bool disconnectTopicFromPort(const Contact &src, const Contact &dest, const ContactStyle &style) override
Stop subscribing a port to a topic.
bool serverAllocatesPortNumbers() const override
Check if a central server is responsible for allocating port numbers, or if this should be left up to...
static Contact rosify(const Contact &contact)
virtual Value * getProperty(const std::string &name, const std::string &key) override
Get the value of a named key from a named port.
virtual bool connectTopic(Bottle &cmd, bool srcIsTopic, const Contact &src, const Contact &dest, const ContactStyle &style, bool activeRegistration)
virtual Contact detectNameServer(bool useDetectedServer, bool &scanNeeded, bool &serverUsed) override
Find a name server for this NameSpace, if applicable.
Contact registerName(const std::string &name) override
Record contact information to tie to a port name.
static std::string fromRosName(const std::string &name)
static std::string toRosName(const std::string &name)
Possible ROS names are a subset of YARP names.
virtual bool setProperty(const std::string &name, const std::string &key, const Value &value) override
Associate a key/value pair with a named port.
static std::string fromRosNodeName(const std::string &name)
static std::string toRosNodeName(const std::string &name)
virtual Contact unregisterAdvanced(const std::string &name, NameStore *store) override
Remove contact information, with access to the contact information of other ports for cross-referenci...
bool connectionHasNameOfEndpoints() const override
When connections are made involving ports managed by this NameSpace do the ports involved end up know...
virtual Contact registerAdvanced(const Contact &contact, NameStore *store) override
Record contact information, with access to the contact information of other ports for cross-referenci...
virtual bool connectPortToTopic(const Contact &src, const Contact &dest, const ContactStyle &style) override
Publish a port to a topic.
virtual bool disconnectPortFromTopic(const Contact &src, const Contact &dest, const ContactStyle &style) override
Stop publishing a port to a topic.
void run() override
Main body of the new thread.
bool stop()
Stop the thread.
bool start()
Start the new thread running.
A single value (typically within a Bottle).
virtual std::int32_t asInt32() const
Get 32-bit integer value.
virtual Bottle * asList() const
Get list value.
virtual std::string asString() const
Get string value.
static NameClient & getNameClient()
Get an instance of the name client.
Small helper class to help deal with legacy YARP configuration files.
std::string getNamespace(bool refresh=false)
static bool isLocalName(const std::string &name)
void setMode(const std::string &mode)
bool fromFile(const char *ns=nullptr)
void setAddress(const Contact &address)
bool toFile(bool clean=false)
#define yCInfo(component,...)
#define yCError(component,...)
#define yCDebug(component,...)
#define YARP_OS_LOG_COMPONENT(name, name_string)
std::string get_string(const std::string &key, bool *found=nullptr)
Read a string from an environment variable.
The components from which ports and connections are built.
An interface to the operating system, including Port based communication.
std::string gethostname()
Portable wrapper for the gethostname() function.