|
YARP
Yet Another Robot Platform
|
|
Go to the documentation of this file.
30 if (delegate !=
nullptr) {
43 return delegate->getOutputStream();
48 return delegate->getLocalAddress();
53 return delegate->getRemoteAddress();
58 return delegate->isOk();
73 delegate->beginPacket();
78 delegate->endPacket();
89 while (swallowRead.length() > 0) {
94 swallowRead = swallowRead.substr(1, swallowRead.length() - 1);
96 if (pendingRead.length() > 0) {
97 b.
get()[0] = pendingRead[0];
98 pendingRead = pendingRead.substr(1, pendingRead.length() - 1);
105 if (tmp.
get()[0] ==
'\n') {
107 swallowRead =
"NAME_SERVER ";
135 if (header.
length() == 8) {
136 std::string target = getSpecifierName();
137 for (
int i = 0; i < 8; i++) {
138 if (!(target[i] == header.
get()[i])) {
149 if (header.
length() == 8) {
150 std::string target = getSpecifierName();
151 for (
int i = 0; i < 8; i++) {
152 header.
get()[i] = target[i];
180 std::string target = getSpecifierName();
230 std::string target = firstSend ?
"VER " :
"NAME_SERVER ";
231 Bytes b((
char*)target.c_str(), target.length());
236 for (
size_t i = 0; i < writer.
length(); i++) {
237 for (
size_t j = 0; j < writer.
length(i); j++) {
238 char ch = writer.
data(i)[j];
244 Bytes b2((
char*)txt.c_str(), txt.length());
A stream which can be asked to perform bidirectional communication.
virtual size_t length() const =0
A base class for connection types (tcp, mcast, shmem, ...) which are called carriers in YARP.
bool isTextMode() const override
Check if carrier is textual in nature.
bool sendHeader(ConnectionState &proto) override
Write a header appropriate to the carrier to the connection, followed by any carrier-specific data.
virtual TwoWayStream * giveStreams()=0
Take ownership of the streams associated with the connection.
virtual void write(char ch)
Write a single byte to the stream.
void getHeader(Bytes &header) const override
Provide 8 bytes describing this connection sufficiently to allow the other side of a connection to se...
void endPacket() override
Mark the end of a logical packet (see beginPacket).
Simple specification of the minimum functions needed from output streams.
Carrier * create() const override
Factory method.
const Contact & getRemoteAddress() const override
Get the address of the remote side of the stream.
bool canEscape() const override
Check if carrier can encode administrative messages, as opposed to just user data.
Information about a connection between two ports.
bool expectReplyToHeader(ConnectionState &proto) override
Process reply to header, if one is expected for this carrier.
Communicating between two ports via a variant plain-text protocol originally designed for the yarp na...
virtual ~NameserTwoWayStream()
virtual void takeStreams(TwoWayStream *streams)=0
Provide streams to be used with the connection.
OutputStream & os()
Shorthand for getOutputStream()
virtual const Route & getRoute() const =0
Get the route associated with this connection.
bool supportReply() const override
This flag is used by YARP to determine whether the connection can carry RPC traffic,...
bool expectSenderSpecifier(ConnectionState &proto) override
Expect the name of the sending port.
std::string getSpecifierName() const
const Contact & getLocalAddress() const override
Get the address of the local side of the stream.
std::string getName() const override
Get the name of this connection type ("tcp", "mcast", "shmem", ...)
virtual void setRoute(const Route &route)=0
Set the route associated with this connection.
bool sendAck(ConnectionState &proto) override
Send an acknowledgement, if needed for this carrier.
OutputStream & getOutputStream() override
Get an OutputStream to write to.
void close() override
Terminate the stream.
virtual void flush()
Make sure all pending write operations are finished.
bool write(ConnectionState &proto, SizedWriter &writer) override
Write a message.
A simple abstraction for a block of bytes.
bool respondToHeader(ConnectionState &proto) override
Respond to the header.
bool expectAck(ConnectionState &proto) override
Receive an acknowledgement, if expected for this carrier.
The basic state of a connection - route, streams in use, etc.
bool isOk() const override
Check if the stream is ok or in an error state.
virtual bool isOk() const =0
Check if the stream is ok or in an error state.
An interface to the operating system, including Port based communication.
void setFromName(const std::string &fromName)
Set the source of the route.
Communicating between two ports via a variant plain-text protocol originally designed for the yarp na...
bool expectIndex(ConnectionState &proto) override
Expect a message header, if there is one for this carrier.
virtual const char * data(size_t index) const =0
InputStream & getInputStream() override
Get an InputStream to read from.
void reset() override
Reset the stream.
The components from which ports and connections are built.
void beginPacket() override
Mark the beginning of a logical packet.
NameserTwoWayStream(TwoWayStream *delegate)
Minimal requirements for an efficient Writer.
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 requireAck() const override
Check if carrier has flow control, requiring sent messages to be acknowledged by recipient.