|
YARP
Yet Another Robot Platform
|
|
Go to the documentation of this file.
62 return "humans are handy";
66 const char *target =
"HUMANITY";
67 for (
size_t i=0; i<8 && i<header.
length(); i++) {
68 header.
get()[i] = target[i];
76 const char *target =
"HUMANITY";
77 for (
size_t i=0; i<8; i++) {
78 if (header.
get()[i] != target[i]) {
115 if (stream==NULL) {
return false; }
123 if (stream==NULL) {
return false; }
137 if (!ok)
return false;
143 std::string prefix =
"human says ";
144 Bytes b2((
char*)prefix.c_str(),prefix.length());
150 std::string prefix =
"human says ";
151 std::string compare = prefix;
152 Bytes b2((
char*)prefix.c_str(),prefix.length());
154 bool ok = proto.
is().
isOk() && (prefix==compare);
155 if (!ok) std::cout <<
"YOU DID NOT SAY 'human says '" << std::endl;
162 std::string prefix =
"computers rule!\r\n";
163 Bytes b2((
char*)prefix.c_str(),prefix.length());
169 std::string prefix =
"computers rule!\r\n";
170 std::string compare = prefix;
171 Bytes b2((
char*)prefix.c_str(),prefix.length());
173 bool ok = proto.
is().
isOk() && (prefix==compare);
174 if (!ok) std::cout <<
"YOU DID NOT SAY 'computers rule!'" << std::endl;
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 sendAck(ConnectionState &proto) override
Send an acknowledgement, if needed for this carrier.
bool canAccept() const override
Check if reading is implemented for this carrier.
bool expectSenderSpecifier(ConnectionState &proto) override
Expect the name of the sending port.
A base class for connection types (tcp, mcast, shmem, ...) which are called carriers in YARP.
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...
virtual void write(OutputStream &os)
Information about a connection between two ports.
virtual bool sendIndex(ConnectionState &proto, SizedWriter &writer)
bool canEscape() const override
Check if carrier can encode administrative messages, as opposed to just user data.
bool write(ConnectionState &proto, SizedWriter &writer) override
Write a message.
bool requireAck() const override
Check if carrier has flow control, requiring sent messages to be acknowledged by recipient.
void setParameters(const Bytes &header) override
Configure this carrier based on the first 8 bytes of the connection.
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.
Carrier * create() const override
Factory method.
bool supportReply() const override
This flag is used by YARP to determine whether the connection can carry RPC traffic,...
virtual void setRoute(const Route &route)=0
Set the route associated with this connection.
std::string getName() const override
Get the name of this connection type ("tcp", "mcast", "shmem", ...)
bool isConnectionless() const override
Check if this carrier is connectionless (like udp, mcast) or connection based (like tcp).
bool expectIndex(ConnectionState &proto) override
Expect a message header, if there is one for this carrier.
A simple abstraction for a block of bytes.
bool expectExtraHeader(ConnectionState &proto) override
Receive any carrier-specific header.
The basic state of a connection - route, streams in use, etc.
virtual bool isOk() const =0
Check if the stream is ok or in an error state.
bool isActive() const override
Check if carrier is alive and error free.
bool respondToHeader(ConnectionState &proto) override
Respond to the header.
void setFromName(const std::string &fromName)
Set the source of the route.
bool sendHeader(ConnectionState &proto) override
Write a header appropriate to the carrier to the connection, followed by any carrier-specific data.
InputStream & is()
Shorthand for getInputStream()
bool isLocal() const override
Check if carrier operates within a single process.
bool canOffer() const override
Check if writing is implemented for this carrier.
std::string toString() const override
Get name of carrier.
bool isTextMode() const override
Check if carrier is textual in nature.
Minimal requirements for an efficient Writer.
bool expectReplyToHeader(ConnectionState &proto) override
Process reply to header, if one is expected for this carrier.
bool expectAck(ConnectionState &proto) override
Receive an acknowledgement, if expected for this carrier.
bool prepareSend(ConnectionState &proto) override
Perform any initialization needed before writing on a connection.