YARP
Yet Another Robot Platform
Node.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
9 #include <yarp/os/Node.h>
10 
11 #include <yarp/conf/compiler.h>
12 #include <yarp/conf/environment.h>
13 
14 #include <yarp/os/NestedContact.h>
15 #include <yarp/os/Network.h>
16 #include <yarp/os/Os.h>
17 #include <yarp/os/Port.h>
18 #include <yarp/os/PortInfo.h>
19 #include <yarp/os/PortReport.h>
20 #include <yarp/os/RosNameSpace.h>
21 #include <yarp/os/Type.h>
24 
25 #include <algorithm>
26 #include <cstdlib>
27 #include <list>
28 #include <map>
29 #include <vector>
30 #include <mutex>
31 
32 using namespace yarp::os;
33 using namespace yarp::os::impl;
34 
35 namespace {
36 YARP_OS_LOG_COMPONENT(NODE, "yarp.os.Node")
37 }
38 
39 
40 class ROSReport : public PortReport
41 {
42 public:
43  std::multimap<std::string, std::string> outgoingURIs;
44  std::multimap<std::string, std::string> incomingURIs;
45 
46  ROSReport() = default;
47 
48  void report(const PortInfo& info) override
49  {
50  if (info.tag == PortInfo::PORTINFO_CONNECTION) {
52  Contact c;
53  if (info.incoming) {
55  incomingURIs.insert(std::make_pair(info.portName, c.toURI()));
56  } else {
58  outgoingURIs.insert(std::make_pair(info.portName, c.toURI()));
59  }
60  }
61  }
62 };
63 
64 static std::string toRosName(const std::string& str)
65 {
66  return RosNameSpace::toRosName(str);
67 }
68 
69 static std::string fromRosName(const std::string& str)
70 {
71  return RosNameSpace::fromRosName(str);
72 }
73 
74 class NodeItem
75 {
76 public:
79 
80  void update()
81  {
82  if (nc.getTypeName().empty()) {
83  if (contactable == nullptr) {
84  return;
85  }
86  Type typ = contactable->getType();
87  if (typ.isValid()) {
88  nc.setTypeName(typ.getName());
89  }
90  }
91  }
92 
93  bool isSubscriber()
94  {
95  std::string cat = nc.getCategory();
96  return (cat.empty() || cat == "-");
97  }
98 
99  bool isPublisher()
100  {
101  std::string cat = nc.getCategory();
102  return (cat.empty() || cat == "+");
103  }
104 
105  bool isTopic()
106  {
107  std::string cat = nc.getCategory();
108  return (cat.empty() || cat == "+" || cat == "-");
109  }
110 
112  {
113  std::string cat = nc.getCategory();
114  return (cat.empty() || cat == "-1");
115  }
116 
118  {
119  std::string cat = nc.getCategory();
120  return (cat.empty() || cat == "+1");
121  }
122 
123  bool isService()
124  {
125  std::string cat = nc.getCategory();
126  return (cat.empty() || cat == "+1" || cat == "-1");
127  }
128 };
129 
130 class NodeArgs
131 {
132 public:
136  int code;
137  std::string msg;
139 
141  {
142  code = -1;
143  should_drop = true;
144  }
145 
146  void error(const char* txt)
147  {
148  msg = txt;
149  code = -1;
150  }
151 
152  void fail(const char* txt)
153  {
154  msg = txt;
155  code = 0;
156  }
157 
158  void success()
159  {
160  msg = "";
161  code = 1;
162  }
163 
164  void drop()
165  {
166  should_drop = true;
167  }
168 
169  void persist()
170  {
171  should_drop = false;
172  }
173 
174  void fromExternal(const Bottle& alt)
175  {
176  code = alt.get(0).asInt32();
177  msg = alt.get(1).asString();
178  reply = alt.get(2);
179  }
180 };
181 
183 {
184 public:
185  std::multimap<std::string, NodeItem> by_part_name;
186  std::multimap<std::string, NodeItem> by_category;
187  std::map<Contactable*, NodeItem> name_cache;
189  Node* owner{nullptr};
190 
191  std::mutex mutex;
192  std::string name;
193  std::string prev_name;
194  bool has_prev_name{false};
195 
197  {
198  clear();
199  port.includeNodeInName(false);
200  }
201 
202  ~Helper() override
203  {
204  clear();
205  port.close();
206  }
207 
208  void clear()
209  {
210  if (!mutex.try_lock()) {
211  return;
212  }
213  while (name_cache.begin() != name_cache.end()) {
214  Contactable* c = name_cache.begin()->first;
215  if (c != nullptr) {
216  mutex.unlock();
217  c->interrupt();
218  c->close();
219  mutex.lock();
220  // Close will remove the Contactable from the map only the first
221  // time that a node is found (for example if "/foo+@/node" and
222  // "/foo-@node" are registered, only the first time that "/node"
223  // is found it is removed automatically. The second time it must
224  // be removed manually.
225  if (!name_cache.empty() && name_cache.begin()->first == c) {
226  name_cache.erase(name_cache.begin());
227  }
228  }
229  }
230  mutex.unlock();
231  port.interrupt();
232  }
233 
234  void add(Contactable& contactable);
235  void update(Contactable& contactable);
236  void remove(Contactable& contactable);
237  std::vector<Contact> query(const std::string& name, const std::string& category = std::string());
238 
239  void prepare(const std::string& name);
240 
241  void interrupt()
242  {
243  port.interrupt();
244  }
245 
246  bool read(ConnectionReader& reader) override;
247 
249  {
250  na.reply = Value();
251  na.success();
252  }
253 
255  {
256  unsigned int opaque_id = 1;
257  ROSReport report;
258  Value v;
259  Bottle* connections = v.asList();
260 
261  mutex.lock();
262  for (auto& it : by_part_name) {
263  NodeItem& item = it.second;
264  if (!(item.isSubscriber() || item.isPublisher())) {
265  continue;
266  }
267  item.update();
268  item.contactable->getReport(report);
269  }
270  mutex.unlock();
271 
272  for (std::multimap<std::string, std::string>::const_iterator it = report.outgoingURIs.begin(); it != report.outgoingURIs.end(); ++it) {
273  Bottle& lst = connections->addList();
274  lst.addInt32(opaque_id); // connectionId
275  lst.addString(it->second);
276  lst.addString("o");
277  lst.addString("TCPROS");
278  NestedContact nc(it->first);
279  lst.addString(toRosName(nc.getNestedName()));
280  opaque_id++;
281  }
282 
283  for (std::multimap<std::string, std::string>::const_iterator it = report.incomingURIs.begin(); it != report.incomingURIs.end(); ++it) {
284  Bottle& lst = connections->addList();
285  lst.addInt32(opaque_id); // connectionId
286  lst.addString(it->second);
287  lst.addString("i");
288  lst.addString("TCPROS");
289  NestedContact nc(it->first);
290  lst.addString(toRosName(nc.getNestedName()));
291  opaque_id++;
292  }
293 
294  if (connections->size() == 0) {
295  connections->addList(); // add empty list
296  }
297 
298  na.reply = v;
299  na.success();
300  }
301 
303  {
304  na.reply = Value(yarp::conf::environment::getEnvironment("ROS_MASTER_URI"));
305  na.success();
306  }
307 
308  void shutdown(NodeArgs& na)
309  {
310  na.reply = Value(std::string("hmm"));
311  }
312 
313  void getPid(NodeArgs& na)
314  {
315  na.reply = Value(static_cast<int>(yarp::os::getpid()));
316  na.success();
317  }
318 
320  {
321  Value v;
322  Bottle* subscriptions = v.asList();
323  mutex.lock();
324  for (auto& it : by_part_name) {
325  NodeItem& item = it.second;
326  if (!item.isSubscriber()) {
327  continue;
328  }
329  item.update();
330  Bottle& lst = subscriptions->addList();
331  lst.addString(toRosName(item.nc.getNestedName()));
332  lst.addString(item.nc.getTypeName());
333  }
334  mutex.unlock();
335  na.reply = v;
336  na.success();
337  }
338 
340  {
341  Value v;
342  Bottle* publications = v.asList();
343  mutex.lock();
344  for (auto& it : by_part_name) {
345  NodeItem& item = it.second;
346  if (!item.isPublisher()) {
347  continue;
348  }
349  item.update();
350  Bottle& lst = publications->addList();
351  lst.addString(toRosName(item.nc.getNestedName()));
352  lst.addString(item.nc.getTypeName());
353  }
354  mutex.unlock();
355  na.reply = v;
356  na.success();
357  }
358 
360  {
361  na.reply = Value(std::string("hmm"));
362  }
363 
365  {
366  std::string topic = fromRosName(na.args.get(0).asString());
367  std::vector<Contact> contacts = query(topic, "-");
368  if (contacts.empty()) {
369  na.fail("Cannot find topic");
370  return;
371  }
372 
373  for (auto& c : contacts) {
374  if (!c.isValid()) {
375  continue;
376  }
377  c.setName("");
378  // just pass the message along, YARP ports know what to do with it
379  ContactStyle style;
380  style.admin = true;
381  style.carrier = "tcp";
382  Bottle reply;
383  if (!NetworkBase::write(c, na.request, reply, style)) {
384  continue;
385  }
386  na.fromExternal(reply);
387  }
388  }
389 
391  {
392  std::string topic = na.args.get(0).asString();
393  topic = fromRosName(topic);
394  std::vector<Contact> contacts = query(topic, "+");
395  if (contacts.empty()) {
396  na.fail("Cannot find topic");
397  return;
398  }
399  for (auto& c : contacts) {
400  if (!c.isValid()) {
401  continue;
402  }
403  Value v;
404  Bottle* lst = v.asList();
405  lst->addString("TCPROS");
406  lst->addString(c.getHost());
407  lst->addInt32(c.getPort());
408  na.reply = v;
409  na.success();
410  return;
411  }
412  na.fail("Cannot find topic");
413  }
414 };
415 
416 void yarp::os::Node::Helper::prepare(const std::string& name)
417 {
418  mutex.lock();
419  if (port.getName().empty()) {
420  port.setReader(*this);
421  Property* prop = port.acquireProperties(false);
422  if (prop != nullptr) {
423  prop->put("node_like", 1);
424  }
425  port.releaseProperties(prop);
426  port.open(name);
427  this->name = port.getName();
428  }
429  mutex.unlock();
430 }
431 
433 {
434  NodeItem item;
435  item.nc.fromString(contactable.getName());
436  if (name.empty()) {
437  name = item.nc.getNodeName();
438  }
439  if (name != item.nc.getNodeName()) {
440  yCError(NODE, "Node name mismatch, expected [%s] but got [%s]\n", name.c_str(), item.nc.getNodeName().c_str());
441  return;
442  }
443  prepare(name);
444  item.contactable = &contactable;
445 
446  mutex.lock();
447  name_cache[&contactable] = item;
448  by_part_name.insert(std::pair<std::string, NodeItem>(item.nc.getNestedName(), item));
449  by_category.insert(std::pair<std::string, NodeItem>(item.nc.getCategory(), item));
450  mutex.unlock();
451 }
452 
454 {
455  mutex.lock();
456  NodeItem item = name_cache[&contactable];
457  mutex.unlock();
458 }
459 
461 {
462  mutex.lock();
463  NodeItem item = name_cache[&contactable];
464  name_cache.erase(&contactable);
465  std::string nestedName = item.nc.getNestedName();
466  for (auto it = by_part_name.begin(); it != by_part_name.end(); ++it) {
467  if (it->first == nestedName && it->second.contactable->where().toString() == contactable.where().toString()) {
468  by_part_name.erase(it);
469  break;
470  }
471  }
472  std::string category = item.nc.getCategory();
473  for (auto it = by_category.begin(); it != by_category.end(); ++it) {
474  if (it->first == category && it->second.contactable->where().toString() == contactable.where().toString()) {
475  by_category.erase(it);
476  break;
477  }
478  }
479  mutex.unlock();
480 }
481 
482 std::vector<Contact> yarp::os::Node::Helper::query(const std::string& name, const std::string& category)
483 {
484  std::vector<Contact> contacts;
485  mutex.lock();
486  for (std::multimap<std::string, NodeItem>::const_iterator it = by_part_name.begin(); it != by_part_name.end(); ++it) {
487  if (it->first == name && (category.empty() || category == it->second.nc.getCategory())) {
488  contacts.emplace_back(it->second.contactable->where());
489  }
490  }
491  mutex.unlock();
492 
493  return contacts;
494 }
495 
497 {
498  if (!reader.isValid()) {
499  return false;
500  }
501  NodeArgs na;
502  na.request.read(reader);
503  yCDebug(NODE, "NODE API for %s received %s\n", name.c_str(), na.request.toString().c_str());
504  std::string key = na.request.get(0).asString();
505  na.args = na.request.tail().tail();
506  if (key == "getBusStats") {
507  getBusStats(na);
508  } else if (key == "getBusInfo") {
509  getBusInfo(na);
510  } else if (key == "getMasterUri") {
511  getMasterUri(na);
512  } else if (key == "shutdown") {
513  shutdown(na);
514  } else if (key == "getPid") {
515  getPid(na);
516  } else if (key == "getSubscriptions") {
517  getSubscriptions(na);
518  } else if (key == "getPublications") {
519  getPublications(na);
520  } else if (key == "paramUpdate") {
521  paramUpdate(na);
522  } else if (key == "publisherUpdate") {
523  publisherUpdate(na);
524  } else if (key == "requestTopic") {
525  requestTopic(na);
526  } else {
527  na.error("I have no idea what you are talking about");
528  }
529  if (na.should_drop) {
530  reader.requestDrop(); // ROS likes to close down.
531  }
532  if (reader.getWriter() != nullptr) {
533  Bottle full;
534  full.addInt32(na.code);
535  full.addString(na.msg);
536  full.add(na.reply);
537  yCDebug(NODE, "NODE %s <<< %s\n", name.c_str(), full.toString().c_str());
538  full.write(*reader.getWriter());
539  }
540  return true;
541 }
542 
543 
545  mPriv(new Helper)
546 {
547  yCAssert(NODE, mPriv != nullptr);
548  mPriv->owner = this;
549 }
550 
551 Node::Node(const std::string& name) :
552  mPriv(new Helper)
553 {
554  yCAssert(NODE, mPriv != nullptr);
555  mPriv->owner = this;
556  Nodes& nodes = NameClient::getNameClient().getNodes();
557  mPriv->prev_name = nodes.getActiveName();
558  mPriv->has_prev_name = true;
559  mPriv->name = name;
560  prepare(name);
561  std::string rname = mPriv->port.getName();
562  nodes.addExternalNode(rname, *this);
563  nodes.setActiveName(rname);
564 }
565 
567 {
568  if (mPriv->has_prev_name) {
569  Nodes& nodes = NameClient::getNameClient().getNodes();
570  nodes.setActiveName(mPriv->prev_name);
571  nodes.removeExternalNode(mPriv->name);
572  }
573  delete mPriv;
574 }
575 
576 void Node::add(Contactable& contactable)
577 {
578  mPriv->add(contactable);
579 }
580 
581 void Node::update(Contactable& contactable)
582 {
583  mPriv->update(contactable);
584 }
585 
586 void Node::remove(Contactable& contactable)
587 {
588  mPriv->remove(contactable);
589 }
590 
591 Contact Node::query(const std::string& name, const std::string& category)
592 {
593  std::vector<Contact> contacts = mPriv->query(name, category);
594  if (!contacts.empty()) {
595  return contacts.at(0);
596  }
597  return Contact();
598 }
599 
601 {
602  mPriv->interrupt();
603 }
604 
606 {
607  return mPriv->port.where();
608 }
609 
610 void Node::prepare(const std::string& name)
611 {
612  mPriv->prepare(name);
613 }
yarp::os::Port::close
void close() override
Stop port activity.
Definition: Port.cpp:357
yarp::os::Bottle
A simple collection of objects that can be described and transmitted in a portable way.
Definition: Bottle.h:73
yarp::os::ContactStyle::admin
bool admin
Ask recipient to treat message as administrative.
Definition: ContactStyle.h:34
yarp::os::Node::prepare
void prepare(const std::string &name)
prepare if it is not already been done, opens the port of the Node.
Definition: Node.cpp:610
NodeItem::isTopic
bool isTopic()
Definition: Node.cpp:105
yarp::os::Bottle::toString
std::string toString() const override
Gives a human-readable textual representation of the bottle.
Definition: Bottle.cpp:214
RosNameSpace.h
yarp::os::Property::put
void put(const std::string &key, const std::string &value)
Associate the given key with the given string.
Definition: Property.cpp:998
yarp::os::Node::Helper::mutex
std::mutex mutex
Definition: Node.cpp:191
Network.h
yarp::os::ContactStyle
Preferences for how to communicate with a contact.
Definition: ContactStyle.h:27
yarp::os::Port::includeNodeInName
void includeNodeInName(bool flag) override
Choose whether to prepend a node name (if one is available) to the port's name.
Definition: Port.cpp:666
yarp::os::NestedContact
A placeholder for rich contact information.
Definition: NestedContact.h:27
yarp::os::Node::Helper::prepare
void prepare(const std::string &name)
Definition: Node.cpp:416
yarp::sig::file::read
bool read(ImageOf< PixelRgb > &dest, const std::string &src, image_fileformat format=FORMAT_ANY)
Definition: ImageFile.cpp:827
yarp::os::PortInfo::PORTINFO_CONNECTION
@ PORTINFO_CONNECTION
Information about an incoming or outgoing connection.
Definition: PortInfo.h:43
yarp::os::NestedContact::setTypeName
void setTypeName(const std::string &nWireType)
Definition: NestedContact.cpp:164
yarp::os::Bottle::size
size_type size() const
Gets the number of elements in the bottle.
Definition: Bottle.cpp:254
yarp::os::Node::Helper::add
void add(Contactable &contactable)
Definition: Node.cpp:432
yarp::os::Port::releaseProperties
void releaseProperties(Property *prop) override
End access unstructured port properties.
Definition: Port.cpp:661
yarp::os::Node::Helper
Definition: Node.cpp:183
yarp::os::Type
Definition: Type.h:24
yarp::os::impl::NameClient::getNameClient
static NameClient & getNameClient()
Get an instance of the name client.
Definition: NameClient.cpp:128
yarp::os::Contactable::getReport
virtual void getReport(PortReport &reporter)=0
Get information on the state of the port - connections etc.
yarp::os::Node::Helper::getPid
void getPid(NodeArgs &na)
Definition: Node.cpp:313
Port.h
yarp::os::impl::NameClient::queryName
Contact queryName(const std::string &name)
Look up the address of a named port.
Definition: NameClient.cpp:146
yarp::conf::environment::getEnvironment
std::string getEnvironment(const char *key, bool *found=nullptr)
Read a variable from the environment.
Definition: environment.h:31
yarp::os::NetworkBase::write
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.
Definition: Network.cpp:1229
yarp::os::NestedContact::getTypeName
std::string getTypeName() const
Definition: NestedContact.cpp:199
NodeItem::nc
NestedContact nc
Definition: Node.cpp:77
NodeArgs::NodeArgs
NodeArgs()
Definition: Node.cpp:140
yarp::os::Node::add
void add(Contactable &contactable) override
add a contactable to this node.
Definition: Node.cpp:576
yarp::os::Node::Helper::getBusInfo
void getBusInfo(NodeArgs &na)
Definition: Node.cpp:254
NodeItem::isServiceClient
bool isServiceClient()
Definition: Node.cpp:117
yarp::os::NestedContact::getNodeName
std::string getNodeName() const
Definition: NestedContact.cpp:184
yarp::os::Type::getName
std::string getName() const
Definition: Type.cpp:142
yarp::os::ConnectionReader::isValid
virtual bool isValid() const =0
yarp::os::getpid
int getpid()
Portable wrapper for the getppid() function.
Definition: Os.cpp:94
yarp::os::Port::open
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
Definition: Port.cpp:82
yarp::os::PortReport
A base class for objects that want information about port status changes.
Definition: PortReport.h:31
LogComponent.h
yarp::os::Contactable::interrupt
virtual void interrupt()=0
Interrupt any current reads or writes attached to the port.
yarp::os::Node::query
virtual Contact query(const std::string &name, const std::string &category="") override
query the Node to obtain Contact information about a nested port associated with this Node.
Definition: Node.cpp:591
yarp::os::Node::Helper::~Helper
~Helper() override
Definition: Node.cpp:202
yarp::os::PortInfo
Information about a port connection or event.
Definition: PortInfo.h:29
yarp::os::Contact::toString
std::string toString() const
Get a textual representation of the Contact.
Definition: Contact.cpp:306
yarp::os::Contactable::where
virtual Contact where() const =0
Returns information about how this port can be reached.
NestedContact.h
yarp::os::NestedContact::getCategory
std::string getCategory() const
Definition: NestedContact.cpp:194
ROSReport::incomingURIs
std::multimap< std::string, std::string > incomingURIs
Definition: Node.cpp:44
yarp::os::Contact::toURI
std::string toURI(bool includeCarrier=true) const
Get a representation of the Contact as a URI.
Definition: Contact.cpp:316
yarp::os::Node::Helper::Helper
Helper()
Definition: Node.cpp:196
yarp::os::Port
A mini-server for network communication.
Definition: Port.h:50
yarp::os::Node::Helper::getMasterUri
void getMasterUri(NodeArgs &na)
Definition: Node.cpp:302
yarp::os::Node::Helper::update
void update(Contactable &contactable)
Definition: Node.cpp:453
NodeArgs::reply
Value reply
Definition: Node.cpp:135
NodeArgs::code
int code
Definition: Node.cpp:136
yarp::os::PortInfo::targetName
std::string targetName
Name of connection target, if any.
Definition: PortInfo.h:66
yarp::os::RosNameSpace::toRosName
static std::string toRosName(const std::string &name)
Possible ROS names are a subset of YARP names.
Definition: RosNameSpace.cpp:662
NodeItem::isService
bool isService()
Definition: Node.cpp:123
Type.h
yarp::os::Type::isValid
bool isValid() const
Definition: Type.cpp:157
yarp::os::PortReader
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition: PortReader.h:28
yarp::os::Bottle::get
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
Definition: Bottle.cpp:249
yarp::os::Bottle::addList
Bottle & addList()
Places an empty nested list in the bottle, at the end of the list.
Definition: Bottle.cpp:185
yarp::os::Bottle::write
bool write(ConnectionWriter &writer) const override
Output a representation of the bottle to a network connection.
Definition: Bottle.cpp:233
NodeArgs::msg
std::string msg
Definition: Node.cpp:137
yarp::os::Node::Helper::prev_name
std::string prev_name
Definition: Node.cpp:193
yarp::os::Node::Helper::name
std::string name
Definition: Node.cpp:192
NodeItem
Definition: Node.cpp:75
yarp::os::PortInfo::tag
int tag
Type of information.
Definition: PortInfo.h:51
yarp::os::Nodes::addExternalNode
void addExternalNode(const std::string &name, Node &node)
addExternalNode adds a Node to this container.
Definition: Nodes.cpp:338
NodeArgs::request
Bottle request
Definition: Node.cpp:133
ROSReport::report
void report(const PortInfo &info) override
Callback for port event/state information.
Definition: Node.cpp:48
yarp::os::Value::asString
virtual std::string asString() const
Get string value.
Definition: Value.cpp:237
NodeItem::contactable
Contactable * contactable
Definition: Node.cpp:78
ROSReport
Definition: Node.cpp:41
yarp::os::RosNameSpace::rosify
static Contact rosify(const Contact &contact)
Definition: RosNameSpace.cpp:717
Os.h
yarp::os::PortInfo::incoming
bool incoming
True if a connection is incoming, false if outgoing.
Definition: PortInfo.h:54
Node.h
yarp::os::Node::Helper::read
bool read(ConnectionReader &reader) override
Read this object from a network connection.
Definition: Node.cpp:496
yarp::os::PortInfo::portName
std::string portName
Name of port.
Definition: PortInfo.h:60
NodeArgs::success
void success()
Definition: Node.cpp:158
yarp::os::Bottle::addInt32
void addInt32(std::int32_t x)
Places a 32-bit integer in the bottle, at the end of the list.
Definition: Bottle.cpp:143
compiler.h
yarp::os::Node
The Node class.
Definition: Node.h:27
NameClient.h
yarp::os::ConnectionReader::getWriter
virtual ConnectionWriter * getWriter()=0
Gets a way to reply to the message, if possible.
yarp::os::Contactable::getName
virtual std::string getName() const
Get name of port.
Definition: Contactable.cpp:17
yarp::os::Bottle::addString
void addString(const char *str)
Places a string in the bottle, at the end of the list.
Definition: Bottle.cpp:173
yarp::os::Node::Helper::shutdown
void shutdown(NodeArgs &na)
Definition: Node.cpp:308
NodeArgs::args
Bottle args
Definition: Node.cpp:134
yarp::os::Port::setReader
void setReader(PortReader &reader) override
Set an external reader for port data.
Definition: Port.cpp:505
yarp::os::Node::where
Contact where()
where getter fot information about the port of the Node.
Definition: Node.cpp:605
yCAssert
#define yCAssert(component, x)
Definition: LogComponent.h:172
yarp::os::ConnectionReader
An interface for reading from a network connection.
Definition: ConnectionReader.h:40
yarp::os::Bottle::tail
Bottle tail() const
Get all but the first element of a bottle.
Definition: Bottle.cpp:391
yarp::os::Node::Node
Node()
Definition: Node.cpp:544
yarp::os::Node::Helper::query
std::vector< Contact > query(const std::string &name, const std::string &category=std::string())
Definition: Node.cpp:482
yarp::os::Node::Helper::clear
void clear()
Definition: Node.cpp:208
NodeArgs::fail
void fail(const char *txt)
Definition: Node.cpp:152
yarp::os::Nodes
The Nodes class.
Definition: Nodes.h:35
yCError
#define yCError(component,...)
Definition: LogComponent.h:157
yarp::os::Value::asInt32
virtual std::int32_t asInt32() const
Get 32-bit integer value.
Definition: Value.cpp:207
yarp::os::Node::Helper::owner
Node * owner
Definition: Node.cpp:189
yarp::os::Node::Helper::has_prev_name
bool has_prev_name
Definition: Node.cpp:194
yarp::os::impl::NameClient
Client for YARP name server.
Definition: NameClient.h:35
yarp::os::Node::Helper::getPublications
void getPublications(NodeArgs &na)
Definition: Node.cpp:339
yarp::os::Nodes::setActiveName
void setActiveName(const std::string &name)
setActiveName setter for the currently active node
Definition: Nodes.cpp:323
yarp::os::ContactStyle::carrier
std::string carrier
Request that communication be made using a particular carrier.
Definition: ContactStyle.h:56
yarp::os::Node::Helper::requestTopic
void requestTopic(NodeArgs &na)
Definition: Node.cpp:390
yarp::os::NestedContact::fromString
bool fromString(const std::string &nFullName)
Definition: NestedContact.cpp:156
yarp::os
An interface to the operating system, including Port based communication.
Definition: AbstractCarrier.h:17
yCDebug
#define yCDebug(component,...)
Definition: LogComponent.h:112
NodeArgs::drop
void drop()
Definition: Node.cpp:164
ROSReport::outgoingURIs
std::multimap< std::string, std::string > outgoingURIs
Definition: Node.cpp:43
yarp::os::Node::update
void update(Contactable &contactable)
update should update the contactable with new information.
Definition: Node.cpp:581
yarp::os::Node::Helper::name_cache
std::map< Contactable *, NodeItem > name_cache
Definition: Node.cpp:187
NodeItem::isPublisher
bool isPublisher()
Definition: Node.cpp:99
yarp::os::Port::acquireProperties
Property * acquireProperties(bool readOnly) override
Access unstructured port properties.
Definition: Port.cpp:656
yarp::os::Node::Helper::port
Port port
Definition: Node.cpp:188
yarp::os::Node::Helper::getSubscriptions
void getSubscriptions(NodeArgs &na)
Definition: Node.cpp:319
ROSReport::ROSReport
ROSReport()=default
yarp::os::Node::Helper::publisherUpdate
void publisherUpdate(NodeArgs &na)
Definition: Node.cpp:364
environment.h
yarp::os::Node::Helper::interrupt
void interrupt()
Definition: Node.cpp:241
NodeArgs::fromExternal
void fromExternal(const Bottle &alt)
Definition: Node.cpp:174
cat
void cat(Vector &a, const Vector &b)
Definition: JoypadControlServer.cpp:29
yarp::os::Node::Helper::paramUpdate
void paramUpdate(NodeArgs &na)
Definition: Node.cpp:359
NodeArgs::error
void error(const char *txt)
Definition: Node.cpp:146
NodeItem::isSubscriber
bool isSubscriber()
Definition: Node.cpp:93
yarp::os::Port::where
Contact where() const override
Returns information about how this port can be reached.
Definition: Port.cpp:399
yarp::os::Bottle::read
bool read(ConnectionReader &reader) override
Set the bottle's value based on input from a network connection.
Definition: Bottle.cpp:243
yarp::os::Node::~Node
virtual ~Node()
Definition: Node.cpp:566
yarp::os::Port::interrupt
void interrupt() override
Interrupt any current reads or writes attached to the port.
Definition: Port.cpp:377
yarp::os::Contact
Represents how to reach a part of a YARP network.
Definition: Contact.h:39
yarp::os::Node::Helper::remove
void remove(Contactable &contactable)
Definition: Node.cpp:460
yarp::os::Value::asList
virtual Bottle * asList() const
Get list value.
Definition: Value.cpp:243
yarp::os::Node::interrupt
void interrupt()
interrupt delegates the call to the Node port interrupt.
Definition: Node.cpp:600
yarp::os::Node::remove
void remove(Contactable &contactable) override
remove specified contactable from the list of contactables associated with this Node.
Definition: Node.cpp:586
yarp::os::Contactable::getType
virtual Type getType()=0
Get the type of data the port has committed to send/receive.
NodeArgs
Definition: Node.cpp:131
yarp::os::Bottle::add
void add(const Value &value)
Add a Value to the bottle, at the end of the list.
Definition: Bottle.cpp:339
yarp::os::Nodes::getActiveName
std::string getActiveName()
getActiveName getter for the currently active node's name
Definition: Nodes.cpp:328
NodeItem::update
void update()
Definition: Node.cpp:80
yarp::os::Node::Helper::getBusStats
void getBusStats(NodeArgs &na)
Definition: Node.cpp:248
yarp::os::Value
A single value (typically within a Bottle).
Definition: Value.h:47
toRosName
static std::string toRosName(const std::string &str)
Definition: Node.cpp:64
PortInfo.h
NodeItem::isServiceServer
bool isServiceServer()
Definition: Node.cpp:111
NodeArgs::persist
void persist()
Definition: Node.cpp:169
yarp::os::Contactable::close
virtual void close()=0
Stop port activity.
NodeArgs::should_drop
bool should_drop
Definition: Node.cpp:138
YARP_OS_LOG_COMPONENT
#define YARP_OS_LOG_COMPONENT(name, name_string)
Definition: LogComponent.h:37
yarp::os::Node::Helper::by_part_name
std::multimap< std::string, NodeItem > by_part_name
Definition: Node.cpp:185
yarp::os::impl
The components from which ports and connections are built.
yarp::os::ConnectionReader::requestDrop
virtual void requestDrop()=0
Tag the connection to be dropped after the current message.
yarp::os::RosNameSpace::fromRosName
static std::string fromRosName(const std::string &name)
Definition: RosNameSpace.cpp:678
yarp::os::NestedContact::getNestedName
std::string getNestedName() const
Definition: NestedContact.cpp:189
yarp::os::Node::Helper::by_category
std::multimap< std::string, NodeItem > by_category
Definition: Node.cpp:186
PortReport.h
yarp::os::Property
A class for storing options and configuration information.
Definition: Property.h:37
yarp::os::Contactable
An abstract port.
Definition: Contactable.h:38
yarp::os::Nodes::removeExternalNode
void removeExternalNode(const std::string &name)
removeExternalNode erase the node from the container.
Definition: Nodes.cpp:343
fromRosName
static std::string fromRosName(const std::string &str)
Definition: Node.cpp:69
yarp::os::PortInfo::sourceName
std::string sourceName
Name of connection source, if any.
Definition: PortInfo.h:63