YARP
Yet Another Robot Platform
PortCoreInputUnit.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * Copyright (C) 2006-2010 RobotCub Consortium
4  * All rights reserved.
5  *
6  * This software may be modified and distributed under the terms of the
7  * BSD-3-Clause license. See the accompanying LICENSE file for details.
8  */
9 
11 
12 #include <yarp/os/Name.h>
13 #include <yarp/os/Os.h>
14 #include <yarp/os/PortInfo.h>
15 #include <yarp/os/PortReport.h>
16 #include <yarp/os/Time.h>
21 
22 #include <cstdio>
23 
24 
25 using namespace yarp::os::impl;
26 using namespace yarp::os;
27 
28 namespace {
29 YARP_OS_LOG_COMPONENT(PORTCOREINPUTUNIT, "yarp.os.impl.PortCoreInputUnit")
30 } // namespace
31 
33  int index,
34  InputProtocol* ip,
35  bool reversed) :
36  PortCoreUnit(owner, index),
37  ip(ip),
38  phase(1),
39  access(1),
40  closing(false),
41  finished(false),
42  running(false),
43  name(owner.getName()),
44  localReader(nullptr),
45  reversed(reversed)
46 {
47  yCAssert(PORTCOREINPUTUNIT, ip != nullptr);
48 
50  if (creator != nullptr) {
51  localReader = creator->create();
52  }
53 }
54 
56 {
57  closeMain();
58  if (localReader != nullptr) {
59  delete localReader;
60  localReader = nullptr;
61  }
62 }
63 
64 
66 {
67  yCDebug(PORTCOREINPUTUNIT, "new input connection to %s starting", getOwner().getName().c_str());
68 
69  phase.wait();
70 
71  bool result = PortCoreUnit::start();
72  if (result) {
73  yCDebug(PORTCOREINPUTUNIT, "new input connection to %s started ok", getOwner().getName().c_str());
74  phase.wait();
75  phase.post();
76  } else {
77  yCDebug(PORTCOREINPUTUNIT, "new input connection to %s failed to start", getOwner().getName().c_str());
78  phase.post();
79  }
80 
81  return result;
82 }
83 
84 
86 {
87  running = true;
88  phase.post();
89 
90  Route route;
91  bool wasNoticed = false;
92  bool posted = false;
93 
94  bool done = false;
95 
96  yCAssert(PORTCOREINPUTUNIT, ip != nullptr);
97 
98  PortCommand cmd;
99 
100  bool ok = true;
101  if (!reversed) {
102  ip->open(getName());
103  }
104  if (!ok) {
105  yCDebug(PORTCOREINPUTUNIT, "new input connection to %s is broken", getOwner().getName().c_str());
106  done = true;
107  } else {
108  route = ip->getRoute();
109 
110  // just before going official, tag any lurking inputs from
111  // the same source as undesired
112  if (Name(route.getFromName()).isRooted()) {
113  yCDebug(PORTCOREINPUTUNIT, "Port %s starting up, flushing routes %s->*->%s",
114  getOwner().getName().c_str(),
115  route.getFromName().c_str(),
116  route.getToName().c_str());
118  route.getToName(),
119  "*"),
120  true);
121  }
122  officialRoute = route;
123  setMode();
124  getOwner().reportUnit(this, true);
125 
126  std::string msg = "Receiving input from " + route.getFromName() + " to " + route.getToName() + " using " + route.getCarrierName();
127  if (Name(route.getFromName()).isRooted() && (reversed || ip->getConnection().isPush())) {
128  yCInfo(PORTCOREINPUTUNIT, "%s", msg.c_str());
129  posted = true;
130  } else {
131  yCDebug(PORTCOREINPUTUNIT, "%s", msg.c_str());
132  }
133 
134  // Report the new connection
135  PortInfo info;
136  info.message = msg;
138  info.incoming = true;
139  info.created = true;
140  info.sourceName = route.getFromName();
141  info.targetName = route.getToName();
142  info.portName = info.targetName;
143  info.carrierName = route.getCarrierName();
144 
145  if (info.sourceName != "admin" && info.sourceName != "null") {
146  getOwner().report(info);
147  wasNoticed = true;
148  }
149  }
150 
151  if (!reversed) {
152  if (!ip->getConnection().isPush()) {
153  /* IP=OP */
154  OutputProtocol* op = &(ip->getOutput());
155  Route r = op->getRoute();
156  // reverse route
157  r.swapNames();
158  op->rename(r);
159 
160  getOwner().addOutput(op);
161  ip = nullptr;
162  done = true;
163  }
164  }
165 
166  if (closing) {
167  done = true;
168  }
169 
170  auto* id = reinterpret_cast<void*>(this);
171 
172  if (ip != nullptr && !ip->getConnection().canEscape()) {
173  InputStream* is = &ip->getInputStream();
174  is->setReadEnvelopeCallback(envelopeReadCallback, this);
175  }
176 
177  while (!done) {
178  if (ip == nullptr) {
179  break;
180  }
181  ConnectionReader& br = ip->beginRead();
182 
183  if (br.getReference() != nullptr) {
184  //printf("HAVE A REFERENCE\n");
185  if (localReader != nullptr) {
186  bool ok = localReader->read(br);
187  if (!br.isActive()) {
188  break;
189  }
190  if (!ok) {
191  continue;
192  }
193  } else {
194  PortCore& man = getOwner();
195  bool ok = man.readBlock(br, id, nullptr);
196  if (!br.isActive()) {
197  break;
198  }
199  if (!ok) {
200  continue;
201  }
202  }
203  //printf("DONE WITH A REFERENCE\n");
204  if (ip != nullptr) {
205  ip->endRead();
206  }
207  continue;
208  }
209 
210  if (ip->getConnection().canEscape()) {
211  bool ok = cmd.read(br);
212  if (!br.isActive()) {
213  break;
214  }
215  if (!ok) {
216  continue;
217  }
218  } else {
219  cmd = PortCommand('d', "");
220  if (!ip->isOk()) {
221  break;
222  }
223  }
224 
225  if (closing || isDoomed()) {
226  break;
227  }
228  char key = cmd.getKey();
229  //printf("Port command is [%c:%d/%s]\n",
230  // (key>=32)?key:'?', key, cmd.getText().c_str());
231 
232  PortCore& man = getOwner();
233  OutputStream* os = nullptr;
234  if (br.isTextMode()) {
235  os = &(ip->getOutputStream());
236  }
237 
238  switch (key) {
239  case '/':
240  yCDebug(PORTCOREINPUTUNIT,
241  "Port command (%s): %s should add connection: %s",
242  route.toString().c_str(),
243  getOwner().getName().c_str(),
244  cmd.getText().c_str());
245  man.addOutput(cmd.getText(), id, os);
246  break;
247  case '!':
248  yCDebug(PORTCOREINPUTUNIT,
249  "Port command (%s): %s should remove output: %s",
250  route.toString().c_str(),
251  getOwner().getName().c_str(),
252  cmd.getText().c_str());
253  man.removeOutput(cmd.getText().substr(1, std::string::npos), id, os);
254  break;
255  case '~':
256  yCDebug(PORTCOREINPUTUNIT,
257  "Port command (%s): %s should remove input: %s",
258  route.toString().c_str(),
259  getOwner().getName().c_str(),
260  cmd.getText().c_str());
261  man.removeInput(cmd.getText().substr(1, std::string::npos), id, os);
262  break;
263  case '*':
264  man.describe(id, os);
265  break;
266  case 'D':
267  case 'd': {
268  if (key == 'D') {
269  ip->suppressReply();
270  }
271 
272  std::string env = cmd.getText();
273  if (env.length() > 2) {
274  yCTrace(PORTCOREINPUTUNIT, "***** received an envelope! [%s]", env.c_str());
275  std::string env2 = env.substr(2, env.length());
276  man.setEnvelope(env2);
277  ip->setEnvelope(env2);
278  }
279  if (localReader != nullptr) {
280  localReader->read(br);
281  if (!br.isActive()) {
282  done = true;
283  break;
284  }
285  } else {
286  if (ip->getReceiver().acceptIncomingData(br)) {
289  modifier.inputMutex.lock();
290  if (modifier.inputModifier != nullptr) {
291  if (modifier.inputModifier->acceptIncomingData(*cr)) {
292  cr = &(modifier.inputModifier->modifyIncomingData(*cr));
293  modifier.inputMutex.unlock();
294  man.readBlock(*cr, id, os);
295  } else {
296  modifier.inputMutex.unlock();
297  skipIncomingData(*cr);
298  }
299  } else {
300  modifier.inputMutex.unlock();
301  man.readBlock(*cr, id, os);
302  }
303  } else {
304  skipIncomingData(br);
305  }
306  if (!br.isActive()) {
307  done = true;
308  break;
309  }
310  }
311  } break;
312  case 'a': {
313  man.adminBlock(br, id);
314  } break;
315  case 'r':
316  /*
317  In YARP implementation, OP=IP.
318  (This information is used rarely, and when used
319  is tagged with OP=IP keyword)
320  If it were not true, memory alloc would need to
321  reorganized here
322  */
323  {
324  OutputProtocol* op = &(ip->getOutput());
325  ip->endRead();
326  Route r = op->getRoute();
327  // reverse route
328  r.swapNames();
329  op->rename(r);
330 
331  getOwner().addOutput(op);
332  ip = nullptr;
333  done = true;
334  }
335  break;
336  case 'q':
337  done = true;
338  break;
339 #if !defined(NDEBUG)
340  case 'i':
341  printf("Interrupt requested\n");
342  //yarp::os::impl::kill(0, 2); // SIGINT
343  //yarp::os::impl::kill(yarp::os::getpid(), 2); // SIGINT
344  yarp::os::impl::kill(yarp::os::getpid(), 15); // SIGTERM
345  break;
346 #endif
347  case '?':
348  case 'h':
349  if (os != nullptr) {
350  BufferedConnectionWriter bw(true);
351  bw.appendLine("This is a YARP port. Here are the commands it responds to:");
352  bw.appendLine("* Gives a description of this port");
353  bw.appendLine("d Signals the beginning of input for the port's owner");
354  bw.appendLine(R"(do The same as "d" except replies should be suppressed ("data-only"))");
355  bw.appendLine("q Disconnects");
356 #if !defined(NDEBUG)
357  bw.appendLine("i Interrupt parent process (unix only)");
358 #endif
359  bw.appendLine("r Reverse connection type to be a reader");
360  bw.appendLine("/port Requests to send output to /port");
361  bw.appendLine("!/port Requests to stop sending output to /port");
362  bw.appendLine("~/port Requests to stop receiving input from /port");
363  bw.appendLine("a Signals the beginning of an administrative message");
364  bw.appendLine("? Gives this help");
365  bw.write(*os);
366  }
367  break;
368  default:
369  if (os != nullptr) {
370  BufferedConnectionWriter bw(true);
371  bw.appendLine("Port command not understood.");
372  bw.appendLine("Type d to send data to the port's owner.");
373  bw.appendLine("Type ? for help.");
374  bw.write(*os);
375  }
376  break;
377  }
378  if (ip != nullptr) {
379  ip->endRead();
380  }
381  if (ip == nullptr) {
382  break;
383  }
384  if (closing || isDoomed() || (!ip->isOk())) {
385  break;
386  }
387  }
388 
389  setDoomed();
390 
391  yCDebug(PORTCOREINPUTUNIT, "Closing ip");
392  access.wait();
393  if (ip != nullptr) {
394  ip->close();
395  }
396  access.post();
397  yCDebug(PORTCOREINPUTUNIT, "Closed ip");
398 
399  std::string msg = std::string("Removing input from ") + route.getFromName() + " to " + route.getToName();
400 
401  if (Name(route.getFromName()).isRooted()) {
402  if (posted) {
403  yCInfo(PORTCOREINPUTUNIT, "%s", msg.c_str());
404  }
405  } else {
406  yCDebug(PORTCOREINPUTUNIT, "(unrooted) shutting down");
407  }
408 
409  getOwner().reportUnit(this, false);
410 
411  if (wasNoticed) {
412  // Report the disappearing connection
413  PortInfo info;
414  info.message = msg;
416  info.incoming = true;
417  info.created = false;
418  info.sourceName = route.getFromName();
419  info.targetName = route.getToName();
420  info.portName = info.targetName;
421  info.carrierName = route.getCarrierName();
422 
423  if (info.sourceName != "admin") {
424  getOwner().report(info);
425  }
426  }
427 
428  if (localReader != nullptr) {
429  delete localReader;
430  localReader = nullptr;
431  }
432 
433  running = false;
434  finished = true;
435 
436  // it would be nice to get my entry removed from the port immediately,
437  // but it would be a bit dodgy to delete this object and join this
438  // thread within and from themselves
439 }
440 
442 {
443  return true;
444 }
445 
447 {
448  closeMain();
449 }
450 
452 {
453  return finished;
454 }
455 
456 const std::string& PortCoreInputUnit::getName()
457 {
458  return name;
459 }
460 
462 {
463  // give a kick (unfortunately unavoidable)
464  access.wait();
465  if (!closing) {
466  if (ip != nullptr) {
467  ip->interrupt();
468  }
469  closing = true;
470  }
471  access.post();
472  return true;
473 }
474 
476 {
477  if (ip != nullptr) {
478  ip->getReceiver().setCarrierParams(params);
479  }
480 }
481 
483 {
484  if (ip != nullptr) {
485  ip->getReceiver().getCarrierParams(params);
486  }
487 }
488 
489 // return the protocol object
491 {
492  return ip;
493 }
494 
495 void PortCoreInputUnit::closeMain()
496 {
497  access.wait();
498  Route r = getRoute();
499  access.post();
500 
501  yCDebug(PORTCOREINPUTUNIT, "[%s] closing", r.toString().c_str());
502 
503  if (running) {
504  yCDebug(PORTCOREINPUTUNIT, "[%s] joining", r.toString().c_str());
505  interrupt();
506  join();
507  yCDebug(PORTCOREINPUTUNIT, "[%s] joined", r.toString().c_str());
508  }
509 
510  if (ip != nullptr) {
511  ip->close();
512  delete ip;
513  ip = nullptr;
514  }
515  running = false;
516  closing = false;
517 }
518 
519 
521 {
522  return officialRoute;
523 }
524 
525 
526 bool PortCoreInputUnit::skipIncomingData(yarp::os::ConnectionReader& reader)
527 {
528  size_t pending = reader.getSize();
529  if (pending > 0) {
530  while (pending > 0) {
531  char buf[10000];
532  size_t next = (pending < sizeof(buf)) ? pending : sizeof(buf);
533  reader.expectBlock(&buf[0], next);
534  pending -= next;
535  }
536  return true;
537  }
538  return false;
539 }
540 
541 
543 {
544  bool busy = false;
545  access.wait();
546  if (ip != nullptr) {
547  busy = ip->isReplying();
548  }
549  access.post();
550  return busy;
551 }
552 
553 
554 void PortCoreInputUnit::envelopeReadCallback(void* data, const Bytes& envelope)
555 {
556  auto* p = reinterpret_cast<PortCoreInputUnit*>(data);
557  if (p == nullptr) {
558  return;
559  }
560  p->getOwner().setEnvelope(envelope.get());
561  p->ip->setEnvelope(envelope.get());
562 }
yarp::os::Route::toString
std::string toString() const
Render a text form of the route, "source->carrier->dest".
Definition: Route.cpp:141
yarp::os::impl::PortCoreUnit::setDoomed
void setDoomed()
Request that this connection be shut down as soon as possible.
Definition: PortCoreUnit.h:100
yarp::os::impl::PortCoreInputUnit::setCarrierParams
void setCarrierParams(const yarp::os::Property &params) override
Set arbitrary parameters for this connection.
Definition: PortCoreInputUnit.cpp:475
yarp::os::impl::BufferedConnectionWriter::appendLine
virtual void appendLine(const std::string &data)
Send a string along with a carriage-return-line-feed sequence.
Definition: BufferedConnectionWriter.cpp:304
yarp::os::Route::swapNames
void swapNames()
Swap from and to names.
Definition: Route.cpp:136
yarp::os::impl::PortCoreInputUnit::getCarrierParams
void getCarrierParams(yarp::os::Property &params) override
Definition: PortCoreInputUnit.cpp:482
yarp::os::Connection::acceptIncomingData
virtual bool acceptIncomingData(yarp::os::ConnectionReader &reader)=0
Determine whether incoming data should be accepted.
yarp::os::PortReader::read
virtual bool read(ConnectionReader &reader)=0
Read this object from a network connection.
yarp::os::Route::getCarrierName
const std::string & getCarrierName() const
Get the carrier type of the route.
Definition: Route.cpp:126
yarp::os::PortReaderCreator::create
virtual PortReader * create() const =0
Factory for PortReader objects.
yarp::os::PortInfo::PORTINFO_CONNECTION
@ PORTINFO_CONNECTION
Information about an incoming or outgoing connection.
Definition: PortInfo.h:43
yarp::os::impl::ThreadImpl::start
virtual bool start()
Definition: ThreadImpl.cpp:187
yarp::os::impl::PortCoreInputUnit::interrupt
bool interrupt() override
Interrupt the connection.
Definition: PortCoreInputUnit.cpp:461
yarp::os::impl::BufferedConnectionWriter::write
bool write(ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: BufferedConnectionWriter.cpp:344
yarp::os::impl::PortCoreInputUnit::run
void run() override
The body of the thread associated with this input.
Definition: PortCoreInputUnit.cpp:85
yarp::os::impl::PortCoreUnit
This manages a single threaded resource related to a single input or output connection.
Definition: PortCoreUnit.h:30
yarp::os::OutputProtocol
The output side of an active connection between two ports.
Definition: OutputProtocol.h:33
yarp::os::impl::PortCoreInputUnit::PortCoreInputUnit
PortCoreInputUnit(PortCore &owner, int index, InputProtocol *ip, bool reversed)
Constructor.
Definition: PortCoreInputUnit.cpp:32
yarp::os::impl::PortCoreInputUnit::getName
const std::string & getName()
Definition: PortCoreInputUnit.cpp:456
yarp::os::InputProtocol::close
virtual void close()=0
Negotiate an end to operations.
yarp::os::impl::PortCoreInputUnit::~PortCoreInputUnit
virtual ~PortCoreInputUnit()
Destructor.
Definition: PortCoreInputUnit.cpp:55
yarp::os::impl::PortDataModifier
This is the heart of a yarp port.
Definition: PortCore.h:113
yarp::os::OutputStream
Simple specification of the minimum functions needed from output streams.
Definition: OutputStream.h:25
yarp::os::impl::PortCoreInputUnit::close
void close() override
Definition: PortCoreInputUnit.cpp:446
yarp::os::OutputProtocol::getRoute
virtual const Route & getRoute() const =0
yarp::os::impl::PortCommand
Simple Readable and Writable object representing a command to a YARP port.
Definition: PortCommand.h:29
yarp::os::impl::BufferedConnectionWriter
A helper for creating cached object descriptions.
Definition: BufferedConnectionWriter.h:50
yarp::os::ConnectionReader::getSize
virtual size_t getSize() const =0
Checks how much data is available.
yarp::os::PortInfo::created
bool created
True if a connection is created, false if destroyed.
Definition: PortInfo.h:57
yarp::os::getpid
int getpid()
Portable wrapper for the getppid() function.
Definition: Os.cpp:94
yarp::os::impl::PortCore
Definition: PortCore.h:155
yarp::os::Route
Information about a connection between two ports.
Definition: Route.h:32
LogComponent.h
yarp::os::Semaphore::wait
void wait()
Decrement the counter, even if we must wait to do that.
Definition: Semaphore.cpp:99
yarp::os::InputProtocol::getOutputStream
virtual OutputStream & getOutputStream()=0
Access the output stream associated with the connection.
yarp::os::impl::PortCore::removeIO
bool removeIO(const Route &route, bool synch=false)
Remove any connection matching the supplied route.
Definition: PortCore.cpp:2965
yarp::os::Connection::canEscape
virtual bool canEscape() const =0
Check if carrier can encode administrative messages, as opposed to just user data.
yarp::os::PortInfo
Information about a port connection or event.
Definition: PortInfo.h:29
yarp::os::PortInfo::carrierName
std::string carrierName
Name of protocol type, if releveant.
Definition: PortInfo.h:69
Name.h
yarp::os::InputProtocol::getOutput
virtual OutputProtocol & getOutput()=0
Get an interface for doing write operations on the connection.
yarp::os::InputProtocol::isReplying
virtual bool isReplying() const =0
yarp::os::impl::PortCore::describe
void describe(void *id, yarp::os::OutputStream *os)
Produce a text description of the port and its connections.
Definition: PortCore.cpp:1052
PortCoreInputUnit.h
yarp::os::Semaphore::post
void post()
Increment the counter.
Definition: Semaphore.cpp:114
yarp::os::PortInfo::targetName
std::string targetName
Name of connection target, if any.
Definition: PortInfo.h:66
PortCommand.h
yarp::os::Connection::modifyIncomingData
virtual yarp::os::ConnectionReader & modifyIncomingData(yarp::os::ConnectionReader &reader)=0
Modify incoming payload data, if appropriate.
yarp::os::PortInfo::tag
int tag
Type of information.
Definition: PortInfo.h:51
yarp::os::InputProtocol::suppressReply
virtual void suppressReply()=0
Make sure that any attempt to send a reply to input will be denied.
yarp::os::Bytes::get
const char * get() const
Definition: Bytes.cpp:30
BufferedConnectionWriter.h
yarp::os::impl::PortCoreInputUnit::isBusy
bool isBusy() override
Definition: PortCoreInputUnit.cpp:542
yarp::os::impl::PortCore::readBlock
bool readBlock(ConnectionReader &reader, void *id, yarp::os::OutputStream *os)
Read a block of regular payload data.
Definition: PortCore.cpp:1203
yarp::os::impl::PortCore::reportUnit
void reportUnit(PortCoreUnit *unit, bool active)
Called by a connection handler with active=true just after it is fully configured,...
Definition: PortCore.cpp:2893
yarp::os::PortReaderCreator
A creator for readers.
Definition: PortReaderCreator.h:34
Os.h
yarp::os::Connection::isPush
virtual bool isPush() const =0
Check if carrier is "push" or "pull" style.
yarp::os::impl::ThreadImpl::join
int join(double seconds=-1)
Definition: ThreadImpl.cpp:123
yarp::os::PortInfo::incoming
bool incoming
True if a connection is incoming, false if outgoing.
Definition: PortInfo.h:54
yarp::os::impl::PortCore::removeOutput
void removeOutput(const std::string &dest, void *id, yarp::os::OutputStream *os)
Remove an output connection.
Definition: PortCore.cpp:1016
yarp::os::impl::PortCore::getPortModifier
yarp::os::impl::PortDataModifier & getPortModifier()
Definition: PortCore.cpp:3121
yarp::os::impl::PortCommand::getKey
char getKey()
Definition: PortCommand.h:48
yarp::os::OutputProtocol::rename
virtual void rename(const Route &route)=0
Relabel the route after the fact (e.g.
yarp::os::InputProtocol::getInputStream
virtual InputStream & getInputStream()=0
Access the input stream associated with the connection.
yarp::os::PortInfo::portName
std::string portName
Name of port.
Definition: PortInfo.h:60
yarp::os::impl::PortCoreInputUnit::start
bool start() override
Start a thread running to serve this input.
Definition: PortCoreInputUnit.cpp:65
yarp::os::impl::PortCoreUnit::isDoomed
bool isDoomed()
Definition: PortCoreUnit.h:92
yarp::os::impl::PortDataModifier::inputModifier
yarp::os::Carrier * inputModifier
Definition: PortCore.h:147
yarp::os::impl::PortCommand::read
bool read(yarp::os::ConnectionReader &reader) override
Read this object from a network connection.
Definition: PortCommand.cpp:23
yarp::os::impl::PortCoreInputUnit::getInPutProtocol
InputProtocol * getInPutProtocol()
Definition: PortCoreInputUnit.cpp:490
yarp::os::impl::PortCore::getReadCreator
yarp::os::PortReaderCreator * getReadCreator()
Get the creator of callbacks.
Definition: PortCore.cpp:3000
yarp::os::Carrier::modifyIncomingData
ConnectionReader & modifyIncomingData(ConnectionReader &reader) override
Modify incoming payload data, if appropriate.
Definition: Carrier.cpp:55
yarp::os::Name
Simple abstraction for a YARP port name.
Definition: Name.h:22
yarp::os::PortInfo::message
std::string message
A human-readable description of contents.
Definition: PortInfo.h:72
yarp::os::InputProtocol::getRoute
virtual const Route & getRoute() const =0
Get the route associated with this connection.
yarp::os::impl::PortDataModifier::inputMutex
std::mutex inputMutex
Definition: PortCore.h:149
yarp::os::impl::PortCoreInputUnit::isInput
bool isInput() override
Definition: PortCoreInputUnit.cpp:441
yarp::os::Bytes
A simple abstraction for a block of bytes.
Definition: Bytes.h:28
yarp::os::Carrier::acceptIncomingData
bool acceptIncomingData(ConnectionReader &reader) override
Determine whether incoming data should be accepted.
Definition: Carrier.cpp:60
yarp::os::Connection::getCarrierParams
virtual void getCarrierParams(yarp::os::Property &params) const =0
Get carrier configuration and deliver it by port administrative commands.
yCAssert
#define yCAssert(component, x)
Definition: LogComponent.h:172
yarp::os::InputProtocol::isOk
virtual bool isOk() const =0
Check if the connection is valid and can be used.
yarp::os::ConnectionReader::isActive
virtual bool isActive() const =0
yarp::os::ConnectionReader
An interface for reading from a network connection.
Definition: ConnectionReader.h:40
yarp::os::impl::PortCore::addOutput
bool addOutput(const std::string &dest, void *id, yarp::os::OutputStream *os, bool onlyIfNeeded=false)
Add an output connection to this port.
Definition: PortCore.cpp:846
yarp::os::InputProtocol::open
virtual bool open(const std::string &name)=0
Start negotiating a carrier, using the given name as our own if a name is needed (this should general...
yarp::os::Connection::setCarrierParams
virtual void setCarrierParams(const yarp::os::Property &params)=0
Configure carrier from port administrative commands.
yarp::os::ConnectionReader::getReference
virtual Portable * getReference() const =0
Get a direct pointer to the object being sent, if possible.
yCInfo
#define yCInfo(component,...)
Definition: LogComponent.h:135
PlatformSignal.h
yarp::os::impl::PortCore::removeInput
void removeInput(const std::string &src, void *id, yarp::os::OutputStream *os)
Remove an input connection.
Definition: PortCore.cpp:1034
yarp::os::impl::PortCore::setEnvelope
void setEnvelope(const std::string &envelope)
Set some envelope information to pass along with a message without actually being part of the message...
Definition: PortCore.cpp:1461
yarp::os
An interface to the operating system, including Port based communication.
Definition: AbstractCarrier.h:17
yCDebug
#define yCDebug(component,...)
Definition: LogComponent.h:112
yarp::os::impl::PortCoreInputUnit::isFinished
bool isFinished() override
Definition: PortCoreInputUnit.cpp:451
yarp::os::InputProtocol::beginRead
virtual ConnectionReader & beginRead()=0
Begin a read operation, with bytes read via the returned yarp::os::ConnectionReader object.
yarp::os::impl::PortCoreInputUnit
Manager for a single input to a port.
Definition: PortCoreInputUnit.h:28
yarp::os::impl::PortCore::report
void report(const yarp::os::PortInfo &info)
Handle a port event (connection, disconnection, etc) Generate a description of the connections associ...
Definition: PortCore.cpp:1189
yarp::os::InputProtocol::interrupt
virtual void interrupt()=0
Try to get operations interrupted.
yarp::os::ConnectionReader::isTextMode
virtual bool isTextMode() const =0
Check if the connection is text mode.
yarp::os::Route::getToName
const std::string & getToName() const
Get the destination of the route.
Definition: Route.cpp:106
yarp::os::impl::PortCoreUnit::getOwner
PortCore & getOwner()
Definition: PortCoreUnit.h:279
yarp::os::InputProtocol::endRead
virtual void endRead()=0
End the current read operation, begin by beginRead().
Time.h
yarp::os::InputProtocol
The input side of an active connection between two ports.
Definition: InputProtocol.h:38
yCTrace
#define yCTrace(component,...)
Definition: LogComponent.h:88
yarp::os::ConnectionReader::expectBlock
virtual bool expectBlock(char *data, size_t len)=0
Read a block of data from the network connection.
yarp::os::Route::getFromName
const std::string & getFromName() const
Get the source of the route.
Definition: Route.cpp:96
PortInfo.h
yarp::os::InputProtocol::setEnvelope
virtual void setEnvelope(const std::string &str)=0
Set the envelope that will be attached to the next message.
yarp::os::impl::PortCoreInputUnit::getRoute
Route getRoute() override
Definition: PortCoreInputUnit.cpp:520
yarp::os::InputStream
Simple specification of the minimum functions needed from input streams.
Definition: InputStream.h:29
YARP_OS_LOG_COMPONENT
#define YARP_OS_LOG_COMPONENT(name, name_string)
Definition: LogComponent.h:37
yarp::os::InputStream::setReadEnvelopeCallback
virtual bool setReadEnvelopeCallback(readEnvelopeCallbackType callback, void *data)
Install a callback that the InputStream will have to call when the envelope is read from a message in...
Definition: InputStream.cpp:126
yarp::os::InputProtocol::getConnection
virtual Connection & getConnection()=0
Get the basic connection through which we are communicating.
yarp::os::impl::PortCoreUnit::setMode
void setMode()
Check the carrier used for the connection, and see if it has a "log" modifier.
Definition: PortCoreUnit.h:189
yarp::os::impl
The components from which ports and connections are built.
yarp::os::InputProtocol::getReceiver
virtual Connection & getReceiver()=0
It is possible to chain a basic connection with a modifier.
yarp::os::impl::PortCore::adminBlock
bool adminBlock(ConnectionReader &reader, void *id)
Read a block of administrative data.
Definition: PortCore.cpp:1663
PortReport.h
yarp::os::impl::PortCommand::getText
std::string getText()
Definition: PortCommand.h:53
yarp::os::Property
A class for storing options and configuration information.
Definition: Property.h:37
yarp::os::Name::isRooted
bool isRooted() const
Check if port name begins with "/".
Definition: Name.cpp:19
yarp::os::PortInfo::sourceName
std::string sourceName
Name of connection source, if any.
Definition: PortInfo.h:63