|
YARP
Yet Another Robot Platform
|
|
Go to the documentation of this file.
39 this->sender = sender;
54 this->receiver = receiver;
57 receiverMutex.unlock();
63 if (sender == carrier) {
72 this->sender = sender;
133 if (owner !=
nullptr) {
148 peerMutex(), sent(0), received(0)
179 if (peer !=
nullptr) {
180 peer->accept(
nullptr);
221 if (header.
length() == 8) {
222 std::string target = getSpecifierName();
223 for (
int i = 0; i < 8; i++) {
224 if (!(target[i] == header.
get()[i])) {
235 if (header.
length() == 8) {
236 std::string target = getSpecifierName();
237 for (
int i = 0; i < 8; i++) {
238 header.
get()[i] = target[i];
252 manager.setSender(
this);
254 defaultSendHeader(proto);
257 peer = manager.getReceiver();
259 "sender %p sees receiver %p",
272 peer = manager.getSender(
this);
274 "receiver %p (%s) sees sender %p (%s)",
278 peer->portName.c_str());
290 if (stream !=
nullptr) {
291 stream->attach(
this, sender);
301 if (ref !=
nullptr) {
303 if (peer !=
nullptr) {
306 yCError(LOCALCARRIER,
"local send failed - write without peer");
310 yCError(LOCALCARRIER,
"local send failed - no object");
319 return becomeLocal(proto,
false);
326 return becomeLocal(proto,
true);
332 yCDebug(LOCALCARRIER,
"local recv: wait send");
334 yCDebug(LOCALCARRIER,
"local recv: got send");
337 if (ref !=
nullptr) {
338 yCDebug(LOCALCARRIER,
"local recv: received");
340 yCDebug(LOCALCARRIER,
"local recv: shutdown");
351 yCDebug(LOCALCARRIER,
"local send: send ref");
353 if (ref !=
nullptr && !doomed) {
354 yCDebug(LOCALCARRIER,
"local send: wait receipt");
356 yCDebug(LOCALCARRIER,
"local send: received");
This is a base class for objects that can be both read from and be written to the YARP network.
LocalCarrier * getSender(LocalCarrier *receiver)
virtual std::string getSpecifierName() const
virtual void setReference(yarp::os::Portable *ref)=0
Give a direct pointer to an object being sent on the connection.
LocalCarrier * getReceiver()
A base class for connection types (tcp, mcast, shmem, ...) which are called carriers in YARP.
bool respondToHeader(ConnectionState &proto) override
Respond to the header.
Carrier * create() const override
Factory method.
void accept(yarp::os::Portable *ref)
Simple specification of the minimum functions needed from output streams.
void attach(LocalCarrier *owner, bool sender)
Coordinate ports communicating locally within a process.
bool expectExtraHeader(ConnectionState &proto) override
Receive any carrier-specific header.
bool setTypeOfService(int tos) override
Information about a connection between two ports.
void write(const yarp::os::Bytes &b) override
Write a block of bytes to the stream.
void revoke(LocalCarrier *carrier)
A carrier for communicating locally within a process.
bool isConnectionless() const override
Check if this carrier is connectionless (like udp, mcast) or connection based (like tcp).
virtual Portable * getReference()=0
virtual void takeStreams(TwoWayStream *streams)=0
Provide streams to be used with the connection.
virtual const Route & getRoute() const =0
Get the route associated with this connection.
void interrupt() override
Interrupt the stream.
bool expectReplyToHeader(ConnectionState &proto) override
Process reply to header, if one is expected for this carrier.
void beginPacket() override
Mark the beginning of a logical packet.
const Contact & getLocalAddress() const override
Get the address of the local side of the stream.
OutputStream & getOutputStream() override
Get an OutputStream to write to.
virtual void setRoute(const Route &route)=0
Set the route associated with this connection.
void setParameters(const Bytes &header) override
Configure this carrier based on the first 8 bytes of the connection.
const Contact & getRemoteAddress() const override
Get the address of the remote side of the stream.
bool write(ConnectionState &proto, SizedWriter &writer) override
Write a message.
void endPacket() override
Mark the end of a logical packet (see beginPacket).
A stream for communicating locally within a process.
bool sendHeader(ConnectionState &proto) override
Write a header appropriate to the carrier to the connection, followed by any carrier-specific data.
static LocalCarrierManager manager
void setSender(LocalCarrier *sender)
bool canEscape() const override
Check if carrier can encode administrative messages, as opposed to just user data.
A simple abstraction for a block of bytes.
void reset() override
Reset the stream.
#define yCAssert(component, x)
The basic state of a connection - route, streams in use, etc.
#define yCError(component,...)
bool isOk() const override
Check if the stream is ok or in an error state.
void close() override
Terminate the stream.
An interface to the operating system, including Port based communication.
#define yCDebug(component,...)
void getHeader(Bytes &header) const override
Provide 8 bytes describing this connection sufficiently to allow the other side of a connection to se...
void setFromName(const std::string &fromName)
Set the source of the route.
InputStream & is()
Shorthand for getInputStream()
const std::string & getToName() const
Get the destination of the route.
bool isLocal() const override
Check if carrier operates within a single process.
InputStream & getInputStream() override
Get an InputStream to read from.
bool requireAck() const override
Check if carrier has flow control, requiring sent messages to be acknowledged by recipient.
std::string getName() const override
Get the name of this connection type ("tcp", "mcast", "shmem", ...)
const std::string & getFromName() const
Get the source of the route.
#define YARP_OS_LOG_COMPONENT(name, name_string)
virtual bool becomeLocal(ConnectionState &proto, bool sender)
bool checkHeader(const Bytes &header) override
Given the first 8 bytes received on a connection, decide if this is the right carrier type to use for...
bool expectIndex(ConnectionState &proto) override
Expect a message header, if there is one for this carrier.
Minimal requirements for an efficient Writer.