33 name(owner.getName()),
37 cachedWriter(nullptr),
38 cachedReader(nullptr),
39 cachedCallback(nullptr),
40 cachedTracker(nullptr)
94 yCIDebug(PORTCOREOUTPUTUNIT,
getName(),
"write something in background");
96 yCIDebug(PORTCOREOUTPUTUNIT,
getName(),
"wrote something in background");
98 if (cachedTracker !=
nullptr) {
99 void*
t = cachedTracker;
100 cachedTracker =
nullptr;
106 trackerMutex.unlock();
109 yCIDebug(PORTCOREOUTPUTUNIT,
getName(),
"wrote something in background");
148void PortCoreOutputUnit::closeBasic()
150 bool waitForOther =
false;
155 yCIInfo(PORTCOREOUTPUTUNIT,
getName(),
"output for route %s asking other side to close by out-of-band means",
168 waitForOther = op->
write(buf);
172 std::string msg = std::string(
"Removing output from ") + route.
getFromName() +
" to " + route.
getToName();
202 is.
read(dummy.bytes());
211void PortCoreOutputUnit::closeMain()
253bool PortCoreOutputUnit::sendHelper()
255 bool replied =
false;
260 if (cachedReader !=
nullptr) {
261 buf.setReplyHandler(*cachedReader);
268 return (done =
true);
286 bool ok = cachedWriter->
write(buf);
291 bool suppressReply = (buf.getReplyHandler() ==
nullptr);
295 if (!cachedEnvelope.empty()) {
301 if (!cachedEnvelope.empty()) {
302 if (cachedEnvelope ==
"__ADMIN") {
306 PortCommand pc(
'\0', std::string(suppressReply ?
"D " :
"d ") + cachedEnvelope);
319 replied = op->
write(buf);
329 if (buf.dropRequested()) {
348 const std::string& envelopeString,
353 bool replied =
false;
361 if (!waitBefore || !waitAfter) {
365 yCIDebug(PORTCOREOUTPUTUNIT,
getName(),
"starting a thread for output");
367 yCIDebug(PORTCOREOUTPUTUNIT,
getName(),
"started a thread for output");
371 if ((!waitBefore) && waitAfter) {
372 yCIError(PORTCOREOUTPUTUNIT,
getName(),
"chosen port wait combination not yet implemented");
375 cachedWriter = &writer;
376 cachedReader = reader;
377 cachedCallback = callback;
378 cachedEnvelope = envelopeString;
382 replied = sendHelper();
386 void* nextTracker = tracker;
387 tracker = cachedTracker;
388 cachedTracker = nextTracker;
390 trackerMutex.unlock();
393 yCIDebug(PORTCOREOUTPUTUNIT,
getName(),
"skipping connection tagged as sending something");
397 if (gotReply !=
nullptr) {
409 void* tracker =
nullptr;
412 tracker = cachedTracker;
413 cachedTracker =
nullptr;
415 trackerMutex.unlock();
virtual bool isLocal() const =0
Check if carrier operates within a single process.
virtual bool isTextMode() const =0
Check if carrier is textual in nature.
virtual void prepareDisconnect()=0
Do cleanup and preparation for the coming disconnect, if necessary.
virtual bool isConnectionless() const =0
Check if this carrier is connectionless (like udp, mcast) or connection based (like tcp).
virtual void getCarrierParams(yarp::os::Property ¶ms) const =0
Get carrier configuration and deliver it by port administrative commands.
virtual PortReader & modifyReply(PortReader &reader)=0
Modify reply payload data, if appropriate.
virtual void handleEnvelope(const std::string &envelope)=0
Carriers that do not distinguish data from administrative headers (i.e.
virtual bool acceptOutgoingData(const PortWriter &writer)=0
Determine whether outgoing data should be accepted.
virtual bool modifiesReply() const =0
Check if this carrier modifies outgoing data through the Carrier::modifyReply method.
virtual bool isActive() const =0
Check if carrier is alive and error free.
virtual bool isBareMode() const
Check if carrier excludes type information from payload.
virtual bool canEscape() const =0
Check if carrier can encode administrative messages, as opposed to just user data.
virtual const PortWriter & modifyOutgoingData(const PortWriter &writer)=0
Modify outgoing payload data, if appropriate.
virtual bool supportReply() const =0
This flag is used by YARP to determine whether the connection can carry RPC traffic,...
virtual bool modifiesOutgoingData() const =0
Check if this carrier modifies outgoing data through the Carrier::modifyOutgoingData method.
virtual bool isBroadcast() const =0
Check if this carrier uses a broadcast mechanism.
virtual void setCarrierParams(const yarp::os::Property ¶ms)=0
Configure carrier from port administrative commands.
An abstraction for a block of bytes, with optional responsibility for allocating/destroying that bloc...
Simple abstraction for a YARP port name.
bool isRooted() const
Check if port name begins with "/".
static int disconnectInput(const std::string &src, const std::string &dest, bool silent=false)
Sends a disconnection command to the specified port.
The output side of an active connection between two ports.
virtual Connection & getConnection()=0
Get the connection whose protocol operations we are managing.
virtual const Route & getRoute() const =0
virtual void close()=0
Negotiate an end to operations.
virtual void interrupt()=0
virtual InputStream & getInputStream()=0
Access the input stream associated with the connection.
virtual Connection & getSender()=0
It is possible to chain a basic connection with a modifier.
virtual void beginWrite()=0
Notify connection that we intend to write to it.
virtual bool isOk() const =0
Check if the connection is valid and can be used.
virtual bool write(SizedWriter &writer)=0
Write a message on the connection.
Information about a port connection or event.
std::string targetName
Name of connection target, if any.
std::string carrierName
Name of protocol type, if releveant.
bool incoming
True if a connection is incoming, false if outgoing.
std::string message
A human-readable description of contents.
bool created
True if a connection is created, false if destroyed.
std::string portName
Name of port.
int tag
Type of information.
std::string sourceName
Name of connection source, if any.
@ PORTINFO_CONNECTION
Information about an incoming or outgoing connection.
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
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.
This is a base class for objects that can be both read from and be written to the YARP network.
A class for storing options and configuration information.
Information about a connection between two ports.
const std::string & getToName() const
Get the destination of the route.
const std::string & getCarrierName() const
Get the carrier type of the route.
std::string toString() const
Render a text form of the route, "source->carrier->dest".
const std::string & getFromName() const
Get the source of the route.
void wait()
Decrement the counter, even if we must wait to do that.
void post()
Increment the counter.
A helper for creating cached object descriptions.
Simple Readable and Writable object representing a command to a YARP port.
OutputProtocol * getOutPutProtocol()
void getCarrierParams(yarp::os::Property ¶ms) override
void * takeTracker() override
Reacquire a tracker previously passed via send().
void setCarrierParams(const yarp::os::Property ¶ms) override
Set arbitrary parameters for this connection.
void * send(const yarp::os::PortWriter &writer, yarp::os::PortReader *reader, const yarp::os::PortWriter *callback, void *tracker, const std::string &envelopeString, bool waitAfter, bool waitBefore, bool *gotReply) override
Send a message on the connection.
~PortCoreOutputUnit() override
Destructor.
const std::string & getName()
bool start() override
Prepare to serve this output.
void run() override
The body of a thread managing background sends.
virtual void runSingleThreaded()
Perform send operations without a separate thread.
Route getRoute() override
This manages a single threaded resource related to a single input or output connection.
void setMode()
Check the carrier used for the connection, and see if it has a "log" modifier.
void setDoomed()
Request that this connection be shut down as soon as possible.
void notifyCompletion(void *tracker)
Call the right onCompletion() after sending message.
void report(const yarp::os::PortInfo &info)
Handle a port event (connection, disconnection, etc) Generate a description of the connections associ...
void reportUnit(PortCoreUnit *unit, bool active)
Called by a connection handler with active=true just after it is fully configured,...
int join(double seconds=-1)
#define yCIAssert(component, id, x)
#define yCIError(component, id,...)
#define yCIInfo(component, id,...)
#define yCIDebug(component, id,...)
#define YARP_OS_LOG_COMPONENT(name, name_string)
The components from which ports and connections are built.
An interface to the operating system, including Port based communication.