|
YARP
Yet Another Robot Platform
|
|
Go to the documentation of this file.
34 convertedTextMode(false),
37 parentConnectionReader(nullptr)
43 if (writer !=
nullptr) {
59 this->messageLen = len;
60 this->textMode = textMode;
61 this->bareMode = bareMode;
65 convertedTextMode =
false;
66 pushedIntFlag =
false;
71 this->protocol = protocol;
106 #ifndef YARP_NO_DEPRECATED // Since YARP 3.2
112 char* buf =
new char[len];
116 if (r < 0 ||
static_cast<size_t>(r) < b.
length()) {
126 #endif // YARP_NO_DEPRECATED
134 bool success =
false;
135 std::string result = in->
readLine(
'\n', &success);
140 messageLen -= result.length() + 1;
146 if (writer !=
nullptr) {
148 if (str !=
nullptr) {
149 if (protocol !=
nullptr) {
150 protocol->
reply(*writer);
158 writePending =
false;
168 reset(*in, str, route, len, textMode, bareMode);
182 pushedIntFlag =
true;
187 template <
typename T,
typename NetT>
188 inline T StreamConnectionReader::expectType()
195 if (r < 0 ||
static_cast<size_t>(r) < b.length()) {
199 messageLen -= b.length();
201 return static_cast<T
>(x);
209 return expectType<std::int8_t, NetInt8>();
217 return expectType<std::int16_t, NetInt16>();
223 pushedIntFlag =
false;
229 return expectType<std::int32_t, NetInt32>();
237 return expectType<std::int64_t, NetInt64>();
245 return expectType<yarp::conf::float32_t, NetFloat32>();
253 return expectType<yarp::conf::float64_t, NetFloat64>();
268 bool lsuccess =
false;
269 std::string result = in->
readLine(terminatingChar, &lsuccess);
271 messageLen -= result.length() + 1;
289 if (!convertedTextMode) {
297 convertedTextMode =
true;
306 if (str ==
nullptr) {
309 if (writer ==
nullptr) {
315 if (protocol !=
nullptr) {
323 if (str !=
nullptr) {
334 if (str !=
nullptr) {
378 if (protocol !=
nullptr) {
380 return {
const_cast<char*
>(env.c_str()), env.length()};
382 if (parentConnectionReader !=
nullptr) {
395 if (config.
size() == 0) {
396 if (protocol !=
nullptr) {
405 this->parentConnectionReader = parentConnectionReader;
408 bool StreamConnectionReader::isGood()
virtual const Contact & getLocalAddress() const =0
Get the address of the local side of the stream.
virtual std::string expectString()
Read a string from the network connection.
A stream which can be asked to perform bidirectional communication.
bool isTextMode() const override
Check if the connection is text mode.
A simple collection of objects that can be described and transmitted in a portable way.
std::string getSenderSpecifier() const override
Extract a name for the sender, if the connection type supports that.
virtual Bytes readEnvelope()
Read a message envelope, if available.
This is a base class for objects that can be both read from and be written to the YARP network.
void reset(yarp::os::InputStream &in, TwoWayStream *str, const Route &route, size_t len, bool textMode, bool bareMode=false)
yarp::os::Contact getRemoteContact() const override
Gets information about who is supplying the data being read, if that information is available.
const std::string & getCarrierName() const
Get the carrier type of the route.
A base class for nested structures that can be searched.
size_type size() const
Gets the number of elements in the bottle.
bool write(ConnectionWriter &connection) const override
Write this object to a network connection.
std::int32_t expectInt32() override
Read a 32-bit integer from the network connection.
bool pushInt(int x) override
Store an integer to return on the next call to expectInt()
yarp::conf::float64_t expectFloat64() override
Read a 64-bit floating point number from the network connection.
size_t getSize() const override
Checks how much data is available.
void reply(SizedWriter &writer) override
Reply to a message we have just read.
A helper for creating cached object descriptions.
bool isError() const override
std::string expectText(const char terminatingChar) override
Read some text from the network connection.
Information about a connection between two ports.
void clear() override
Clear all cached data.
virtual OutputStream & getOutputStream()=0
Get an OutputStream to write to.
void willReply()
Promise that we'll be making a reply.
yarp::os::ConnectionWriter * getWriter() override
Gets a way to reply to the message, if possible.
Connection choreographer.
bool write(ConnectionWriter &writer) const override
Output a representation of the bottle to a network connection.
An interface for writing to a network connection.
virtual std::string expectLine()
const yarp::os::Searchable & getConnectionModifiers() const override
Access modifiers associated with the connection, if any.
virtual bool expectBlock(yarp::os::Bytes &b)
yarp::os::Contact getLocalContact() const override
Gets information about who is receiving the data, if that information is available.
virtual const Contact & getRemoteAddress() const =0
Get the address of the remote side of the stream.
std::string toString() const
bool isBareMode() const override
Check if the connection is bare mode.
yarp::conf::float32_t expectFloat32() override
Read a 32-bit floating point number from the network connection.
A simple abstraction for a block of bytes.
void setParentConnectionReader(ConnectionReader *parentConnectionReader) override
Set ConnectionReader to be used for reading the envelope.
virtual void setReference(yarp::os::Portable *obj)
bool convertTextMode() override
Reads in a standard description in text mode, and converts it to a standard description in binary.
virtual void flushWriter()
An interface for reading from a network connection.
void requestDrop() override
Tag the connection to be dropped after the current message.
bool isValid() const override
An interface to the operating system, including Port based communication.
bool setSize(size_t len) override
yarp::os::Portable * getReference() const override
Get a direct pointer to the object being sent, if possible.
const std::string & getEnvelope() const override
Read the envelope associated with the current message.
bool isActive() const override
void setProtocol(Protocol *protocol)
bool read(ConnectionReader &reader) override
Set the bottle's value based on input from a network connection.
const std::string & getToName() const
Get the destination of the route.
yarp::os::Bytes readEnvelope() override
Read a message envelope, if available.
std::int16_t expectInt16() override
Read a 16-bit integer from the network connection.
virtual ~StreamConnectionReader()
const std::string & getFromName() const
Get the source of the route.
The components from which ports and connections are built.
std::int64_t expectInt64() override
Read a 64-bit integer from the network connection.
std::int8_t expectInt8() override
Read a 8-bit integer from the network connection.
std::int32_t NetInt32
Definition of the NetInt32 type.