YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
ConnectionRecorder.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef YARP_OS_IMPL_CONNECTIONRECORDER_H
8#define YARP_OS_IMPL_CONNECTIONRECORDER_H
9
10#include <yarp/os/Bottle.h>
13#include <yarp/os/PortWriter.h>
15
16namespace yarp::os::impl {
17
18
26{
27private:
32 bool writing;
33 bool wrote;
34 bool skipNextInt;
35 yarp::os::Bottle blank;
36
37public:
39
44
48 void fini();
49
52 bool hasReply() const;
53
54 bool expectBlock(char* data, size_t len) override;
55 std::string expectText(const char terminatingChar) override;
56 std::int8_t expectInt8() override;
57 std::int16_t expectInt16() override;
58 std::int32_t expectInt32() override;
59 std::int64_t expectInt64() override;
62 bool pushInt(int x) override;
63 bool isTextMode() const override;
64 bool isBareMode() const override;
65 bool convertTextMode() override;
66 size_t getSize() const override;
68 yarp::os::Portable* getReference() const override;
69 yarp::os::Contact getRemoteContact() const override;
70 yarp::os::Contact getLocalContact() const override;
71 bool isValid() const override;
72 bool isActive() const override;
73 bool isError() const override;
74 void appendBlock(const char* data, size_t len) override;
75 void appendInt8(std::int8_t data) override;
76 void appendInt16(std::int16_t data) override;
77 void appendInt32(std::int32_t data) override;
78 void appendInt64(std::int64_t data) override;
79 void appendFloat32(yarp::conf::float32_t data) override;
80 void appendFloat64(yarp::conf::float64_t data) override;
81 void appendText(const std::string& str, const char terminate) override;
82 void appendExternalBlock(const char* data, size_t len) override;
83 void declareSizes(int argc, int* argv) override;
84 void setReplyHandler(yarp::os::PortReader& reader) override;
85 void setReference(yarp::os::Portable* obj) override;
86 bool write(yarp::os::ConnectionWriter& connection) const override;
87 void requestDrop() override;
88 const yarp::os::Searchable& getConnectionModifiers() const override;
90 const yarp::os::SizedWriter* getBuffer() const override;
91 bool setSize(size_t len) override;
92 void flushWriter() override;
93};
94
95} // namespace yarp::os::impl
96
97#endif // YARP_OS_IMPL_CONNECTIONRECORDER_H
A simple collection of objects that can be described and transmitted in a portable way.
Definition Bottle.h:64
A mini-server for performing network communication in the background.
An interface for reading from a network connection.
An interface for writing to a network connection.
Represents how to reach a part of a YARP network.
Definition Contact.h:33
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition PortReader.h:24
Interface implemented by all objects that can write themselves to the network, such as Bottle objects...
Definition PortWriter.h:23
This is a base class for objects that can be both read from and be written to the YARP network.
Definition Portable.h:25
A base class for nested structures that can be searched.
Definition Searchable.h:31
Minimal requirements for an efficient Writer.
Definition SizedWriter.h:32
A helper for creating cached object descriptions.
A helper for recording entire message/reply transactions.
bool expectBlock(char *data, size_t len) override
Read a block of data from the network connection.
std::string expectText(const char terminatingChar) override
Read some text from the network connection.
void declareSizes(int argc, int *argv) override
If you can easily determine how many blocks there are in a message, call this first,...
yarp::conf::float64_t expectFloat64() override
Read a 64-bit floating point number from the network connection.
yarp::os::ConnectionWriter * getWriter() override
Gets a way to reply to the message, if possible.
void setReference(yarp::os::Portable *obj) override
Stores a direct pointer to the object being sent.
bool convertTextMode() override
Reads in a standard description in text mode, and converts it to a standard description in binary.
const yarp::os::Searchable & getConnectionModifiers() const override
Access modifiers associated with the connection, if any.
std::int32_t expectInt32() override
Read a 32-bit integer from the network connection.
void setReplyHandler(yarp::os::PortReader &reader) override
This sets a handler to deal with replies to the message.
std::int64_t expectInt64() override
Read a 64-bit integer from the network connection.
void appendText(const std::string &str, const char terminate) override
Send a terminated string to the network connection.
void requestDrop() override
Tag the connection to be dropped after the current message.
void init(yarp::os::ConnectionReader *wrappedReader)
Call this to wrap a specific ConnectionReader.
void fini()
Call this when all reading/writing has been done.
void appendFloat64(yarp::conf::float64_t data) override
Send a representation of a 64-bit floating point number to the network connection.
yarp::os::Contact getLocalContact() const override
Gets information about who is receiving the data, if that information is available.
size_t getSize() const override
Checks how much data is available.
void appendInt8(std::int8_t data) override
Send a representation of a 8-bit integer to the network connection.
const yarp::os::impl::BufferedConnectionWriter & getMessage() const
bool isTextMode() const override
Check if the connection is text mode.
void appendFloat32(yarp::conf::float32_t data) override
Send a representation of a 32-bit floating point number to the network connection.
void appendBlock(const char *data, size_t len) override
Send a block of data to the network connection.
yarp::conf::float32_t expectFloat32() override
Read a 32-bit floating point number from the network connection.
std::int8_t expectInt8() override
Read a 8-bit integer from the network connection.
bool isBareMode() const override
Check if the connection is bare mode.
void appendInt64(std::int64_t data) override
Send a representation of a 64-bit integer to the network connection.
void appendInt32(std::int32_t data) override
Send a representation of a 32-bit integer to the network connection.
yarp::os::Portable * getReference() const override
Get a direct pointer to the object being sent, if possible.
bool pushInt(int x) override
Store an integer to return on the next call to expectInt()
void appendExternalBlock(const char *data, size_t len) override
Send a block of data to the network connection, without making a copy.
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
yarp::os::SizedWriter * getBuffer() override
yarp::os::Contact getRemoteContact() const override
Gets information about who is supplying the data being read, if that information is available.
std::int16_t expectInt16() override
Read a 16-bit integer from the network connection.
void appendInt16(std::int16_t data) override
Send a representation of a 16-bit integer to the network connection.
const yarp::os::impl::BufferedConnectionWriter & getReply() const
The components from which ports and connections are built.