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