43 if (!writer.
writeString(
"getRemoteProtocolVersion")) {
57 if (!helper_proto.read(connection)) {
67 if(!
yarp().canWrite()) {
68 yError(
" Missing server method TestMultipleContainers::getRemoteProtocolVersion");
73 return helper.helper_proto;}
84 if (remproto.protocol_version != locproto.protocol_version)
86 yCError(SERVICE_LOG_COMPONENT) <<
"Invalid communication protocol.";
87 yCError(SERVICE_LOG_COMPONENT) <<
"Local Protocol Version: " << locproto.toString();
88 yCError(SERVICE_LOG_COMPONENT) <<
"Remote Protocol Version: " << remproto.toString();
123 explicit Command(
const std::vector<std::int32_t>&
a);
138 std::vector<std::int32_t>
a{};
157 using funcptr_t = bool (*)(
const std::vector<std::int32_t>&);
163 static constexpr const char*
s_tag{
"testList1"};
167 static constexpr const char*
s_prototype{
"bool TestMultipleContainers::testList1(const std::vector<std::int32_t>& a)"};
186 Command(
const std::vector<std::int32_t>&
a,
const std::vector<std::int32_t>&
b);
201 std::vector<std::int32_t>
a{};
202 std::vector<std::int32_t>
b{};
221 using funcptr_t = bool (*)(
const std::vector<std::int32_t>&,
const std::vector<std::int32_t>&);
227 static constexpr const char*
s_tag{
"testList2"};
231 static constexpr const char*
s_prototype{
"bool TestMultipleContainers::testList2(const std::vector<std::int32_t>& a, const std::vector<std::int32_t>& b)"};
250 explicit Command(
const std::map<std::int32_t, std::string>&
a);
265 std::map<std::int32_t, std::string>
a{};
284 using funcptr_t = bool (*)(
const std::map<std::int32_t, std::string>&);
290 static constexpr const char*
s_tag{
"testMap1"};
294 static constexpr const char*
s_prototype{
"bool TestMultipleContainers::testMap1(const std::map<std::int32_t, std::string>& a)"};
313 Command(
const std::map<std::int32_t, std::string>&
a,
const std::map<std::int32_t, std::string>&
b);
328 std::map<std::int32_t, std::string>
a{};
329 std::map<std::int32_t, std::string>
b{};
348 using funcptr_t = bool (*)(
const std::map<std::int32_t, std::string>&,
const std::map<std::int32_t, std::string>&);
354 static constexpr const char*
s_tag{
"testMap2"};
358 static constexpr const char*
s_prototype{
"bool TestMultipleContainers::testMap2(const std::map<std::int32_t, std::string>& a, const std::map<std::int32_t, std::string>& b)"};
377 explicit Command(
const std::set<std::int32_t>&
a);
392 std::set<std::int32_t>
a{};
411 using funcptr_t = bool (*)(
const std::set<std::int32_t>&);
417 static constexpr const char*
s_tag{
"testSet1"};
421 static constexpr const char*
s_prototype{
"bool TestMultipleContainers::testSet1(const std::set<std::int32_t>& a)"};
440 Command(
const std::set<std::int32_t>&
a,
const std::set<std::int32_t>&
b);
455 std::set<std::int32_t>
a{};
456 std::set<std::int32_t>
b{};
475 using funcptr_t = bool (*)(
const std::set<std::int32_t>&,
const std::set<std::int32_t>&);
481 static constexpr const char*
s_tag{
"testSet2"};
485 static constexpr const char*
s_prototype{
"bool TestMultipleContainers::testSet2(const std::set<std::int32_t>& a, const std::set<std::int32_t>& b)"};
516 return write(writer);
531 if (!writeTag(writer)) {
534 if (!writeArgs(writer)) {
553 if (!writer.
writeBlock(
reinterpret_cast<const char*
>(a.data()), a.size() *
sizeof(std::int32_t))) {
564 if (!readTag(reader)) {
567 if (!readArgs(reader)) {
598 if constexpr (expected_tag != 0) {
599 if (_csize != 0 && _etype.
code != expected_tag) {
604 if (_csize != 0 && !reader.
readBlock(
reinterpret_cast<char*
>(a.data()), a.size() *
sizeof(std::int32_t))) {
619 return write(writer);
650 if (!reader.
readBool(return_helper)) {
690 return write(writer);
705 if (!writeTag(writer)) {
708 if (!writeArgs(writer)) {
727 if (!writer.
writeBlock(
reinterpret_cast<const char*
>(a.data()), a.size() *
sizeof(std::int32_t))) {
736 if (!writer.
writeBlock(
reinterpret_cast<const char*
>(b.data()), b.size() *
sizeof(std::int32_t))) {
747 if (!readTag(reader)) {
750 if (!readArgs(reader)) {
781 if constexpr (expected_tag != 0) {
782 if (_csize != 0 && _etype.
code != expected_tag) {
787 if (_csize != 0 && !reader.
readBlock(
reinterpret_cast<char*
>(a.data()), a.size() *
sizeof(std::int32_t))) {
802 if constexpr (expected_tag != 0) {
803 if (_csize != 0 && _etype.
code != expected_tag) {
808 if (_csize != 0 && !reader.
readBlock(
reinterpret_cast<char*
>(b.data()), b.size() *
sizeof(std::int32_t))) {
823 return write(writer);
854 if (!reader.
readBool(return_helper)) {
893 return write(writer);
908 if (!writeTag(writer)) {
911 if (!writeArgs(writer)) {
930 for (
const auto& _item : a) {
934 if (!writer.
writeI32(_item.first)) {
952 if (!readTag(reader)) {
955 if (!readArgs(reader)) {
985 for (
size_t _i = 0; _i < _csize; ++_i) {
998 std::string& _val = a[_key];
1021 return write(writer);
1027 return read(reader);
1052 if (!reader.
readBool(return_helper)) {
1092 return write(writer);
1102 return read(reader);
1107 if (!writeTag(writer)) {
1110 if (!writeArgs(writer)) {
1129 for (
const auto& _item : a) {
1133 if (!writer.
writeI32(_item.first)) {
1149 for (
const auto& _item : b) {
1153 if (!writer.
writeI32(_item.first)) {
1171 if (!readTag(reader)) {
1174 if (!readArgs(reader)) {
1204 for (
size_t _i = 0; _i < _csize; ++_i) {
1217 std::string& _val = a[_key];
1239 for (
size_t _i = 0; _i < _csize; ++_i) {
1252 std::string& _val = b[_key];
1275 return write(writer);
1281 return read(reader);
1306 if (!reader.
readBool(return_helper)) {
1345 return write(writer);
1355 return read(reader);
1360 if (!writeTag(writer)) {
1363 if (!writeArgs(writer)) {
1382 for (
const auto& _item : a) {
1395 if (!readTag(reader)) {
1398 if (!readArgs(reader)) {
1427 for (
size_t _i = 0; _i < _csize; ++_i) {
1451 return write(writer);
1457 return read(reader);
1482 if (!reader.
readBool(return_helper)) {
1522 return write(writer);
1532 return read(reader);
1537 if (!writeTag(writer)) {
1540 if (!writeArgs(writer)) {
1559 for (
const auto& _item : a) {
1570 for (
const auto& _item : b) {
1583 if (!readTag(reader)) {
1586 if (!readArgs(reader)) {
1615 for (
size_t _i = 0; _i < _csize; ++_i) {
1637 for (
size_t _i = 0; _i < _csize; ++_i) {
1661 return write(writer);
1667 return read(reader);
1692 if (!reader.
readBool(return_helper)) {
1707 yarp().setOwner(*
this);
1712 if (!
yarp().canWrite()) {
1716 bool ok =
yarp().write(helper, helper);
1717 return ok ? helper.reply.return_helper :
bool{};
1722 if (!
yarp().canWrite()) {
1726 bool ok =
yarp().write(helper, helper);
1727 return ok ? helper.reply.return_helper :
bool{};
1732 if (!
yarp().canWrite()) {
1736 bool ok =
yarp().write(helper, helper);
1737 return ok ? helper.reply.return_helper :
bool{};
1742 if (!
yarp().canWrite()) {
1746 bool ok =
yarp().write(helper, helper);
1747 return ok ? helper.reply.return_helper :
bool{};
1752 if (!
yarp().canWrite()) {
1756 bool ok =
yarp().write(helper, helper);
1757 return ok ? helper.reply.return_helper :
bool{};
1762 if (!
yarp().canWrite()) {
1766 bool ok =
yarp().write(helper, helper);
1767 return ok ? helper.reply.return_helper :
bool{};
1773 bool showAll = (functionName ==
"--all");
1774 std::vector<std::string> helpString;
1776 helpString.emplace_back(
"*** Available commands:");
1783 helpString.emplace_back(
"help");
1803 if (functionName ==
"help") {
1804 helpString.emplace_back(
"std::vector<std::string> help(const std::string& functionName = \"--all\")");
1805 helpString.emplace_back(
"Return list of available commands, or help message for a specific function");
1806 helpString.emplace_back(
"@param functionName name of command for which to get a detailed description. If none or '--all' is provided, print list of available commands");
1807 helpString.emplace_back(
"@return list of strings (one string per line)");
1810 if (helpString.empty()) {
1811 helpString.emplace_back(
"Command not found");
1819 constexpr size_t max_tag_len = 1;
1829 std::string tag = reader.
readTag(1);
1830 bool direct = (tag ==
"__direct__");
1834 while (tag_len <= max_tag_len && !reader.
isError()) {
1835 if(tag ==
"getRemoteProtocolVersion") {
1842 auto proto = getLocalProtocolVersion();
1848 if (!writer.
write(proto)) {
1945 if (tag ==
"help") {
1946 std::string functionName;
1948 functionName =
"--all";
1950 auto help_strings = help(functionName);
1956 if (!writer.
writeTag(
"many", 1, 0)) {
1962 for (
const auto& help_string : help_strings) {
1978 std::string next_tag = reader.
readTag(1);
1979 if (next_tag.empty()) {
1982 tag.append(
"_").append(next_tag);
1983 tag_len = std::count(tag.begin(), tag.end(),
'_') + 1;
#define BOTTLE_TAG_STRING
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
TestMultipleContainers_getRemoteProtocolVersion_helper()=default
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
yarp::os::ApplicationNetworkProtocolVersion helper_proto
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
~Command() override=default
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool writeArgs(const yarp::os::idl::WireWriter &writer) const
bool readArgs(yarp::os::idl::WireReader &reader)
bool writeTag(const yarp::os::idl::WireWriter &writer) const
std::vector< std::int32_t > a
bool readTag(yarp::os::idl::WireReader &reader)
~Reply() override=default
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
static constexpr size_t s_tag_len
static constexpr const char * s_prototype
static constexpr const char * s_tag
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
TestMultipleContainers_testList1_helper()=default
static constexpr size_t s_reply_len
static constexpr size_t s_cmd_len
bool(*)(const std::vector< std::int32_t > &) funcptr_t
static constexpr const char * s_help
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
void call(TestMultipleContainers *ptr)
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
std::vector< std::int32_t > b
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool readArgs(yarp::os::idl::WireReader &reader)
std::vector< std::int32_t > a
bool writeTag(const yarp::os::idl::WireWriter &writer) const
bool readTag(yarp::os::idl::WireReader &reader)
~Command() override=default
bool writeArgs(const yarp::os::idl::WireWriter &writer) const
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
~Reply() override=default
bool(*)(const std::vector< std::int32_t > &, const std::vector< std::int32_t > &) funcptr_t
static constexpr const char * s_prototype
TestMultipleContainers_testList2_helper()=default
static constexpr size_t s_reply_len
static constexpr size_t s_tag_len
static constexpr size_t s_cmd_len
static constexpr const char * s_tag
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
void call(TestMultipleContainers *ptr)
static constexpr const char * s_help
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
~Command() override=default
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool readArgs(yarp::os::idl::WireReader &reader)
std::map< std::int32_t, std::string > a
bool writeTag(const yarp::os::idl::WireWriter &writer) const
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool readTag(yarp::os::idl::WireReader &reader)
bool writeArgs(const yarp::os::idl::WireWriter &writer) const
~Reply() override=default
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
static constexpr size_t s_cmd_len
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
static constexpr const char * s_help
bool(*)(const std::map< std::int32_t, std::string > &) funcptr_t
void call(TestMultipleContainers *ptr)
TestMultipleContainers_testMap1_helper()=default
static constexpr const char * s_prototype
static constexpr size_t s_reply_len
static constexpr size_t s_tag_len
static constexpr const char * s_tag
std::map< std::int32_t, std::string > b
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
~Command() override=default
bool writeArgs(const yarp::os::idl::WireWriter &writer) const
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool readTag(yarp::os::idl::WireReader &reader)
std::map< std::int32_t, std::string > a
bool writeTag(const yarp::os::idl::WireWriter &writer) const
bool readArgs(yarp::os::idl::WireReader &reader)
~Reply() override=default
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
static constexpr size_t s_cmd_len
static constexpr const char * s_help
static constexpr size_t s_tag_len
static constexpr const char * s_tag
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
TestMultipleContainers_testMap2_helper()=default
static constexpr const char * s_prototype
void call(TestMultipleContainers *ptr)
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
static constexpr size_t s_reply_len
bool(*)(const std::map< std::int32_t, std::string > &, const std::map< std::int32_t, std::string > &) funcptr_t
bool readTag(yarp::os::idl::WireReader &reader)
bool writeArgs(const yarp::os::idl::WireWriter &writer) const
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
~Command() override=default
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
std::set< std::int32_t > a
bool readArgs(yarp::os::idl::WireReader &reader)
bool writeTag(const yarp::os::idl::WireWriter &writer) const
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
~Reply() override=default
static constexpr const char * s_help
static constexpr size_t s_tag_len
void call(TestMultipleContainers *ptr)
static constexpr const char * s_tag
bool(*)(const std::set< std::int32_t > &) funcptr_t
TestMultipleContainers_testSet1_helper()=default
static constexpr size_t s_reply_len
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
static constexpr const char * s_prototype
static constexpr size_t s_cmd_len
std::set< std::int32_t > b
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
~Command() override=default
bool writeArgs(const yarp::os::idl::WireWriter &writer) const
bool readTag(yarp::os::idl::WireReader &reader)
bool writeTag(const yarp::os::idl::WireWriter &writer) const
bool readArgs(yarp::os::idl::WireReader &reader)
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
std::set< std::int32_t > a
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
~Reply() override=default
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
static constexpr const char * s_tag
static constexpr const char * s_prototype
void call(TestMultipleContainers *ptr)
static constexpr size_t s_cmd_len
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
static constexpr size_t s_reply_len
static constexpr const char * s_help
TestMultipleContainers_testSet2_helper()=default
bool(*)(const std::set< std::int32_t > &, const std::set< std::int32_t > &) funcptr_t
static constexpr size_t s_tag_len
virtual yarp::os::ApplicationNetworkProtocolVersion getLocalProtocolVersion()
virtual bool testList1(const std::vector< std::int32_t > &a)
virtual bool testSet1(const std::set< std::int32_t > &a)
virtual bool testList2(const std::vector< std::int32_t > &a, const std::vector< std::int32_t > &b)
virtual bool testMap1(const std::map< std::int32_t, std::string > &a)
virtual std::vector< std::string > help(const std::string &functionName="--all")
virtual bool testMap2(const std::map< std::int32_t, std::string > &a, const std::map< std::int32_t, std::string > &b)
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
virtual bool testSet2(const std::set< std::int32_t > &a, const std::set< std::int32_t > &b)
virtual yarp::os::ApplicationNetworkProtocolVersion getRemoteProtocolVersion()
virtual bool checkProtocolVersion()
short int protocol_version
An interface for reading from a network connection.
An interface for writing to a network connection.
This is a base class for objects that can be both read from and be written to the YARP network.
bool write(PortWriter &writer)
Write a message to the associated port or reader.
yarp::os::WireLink & yarp()
Get YARP state associated with this object.
A "tamed" Portable, that promises to serialize itself in an IDL-friendly way.
IDL-friendly connection reader.
bool readString(std::string &str, bool *is_vocab=nullptr)
void readListBegin(yarp::os::idl::WireState &nstate, size_t &len)
bool readI32(std::int32_t &x)
std::string readTag(size_t len=static_cast< size_t >(-1))
void readMapBegin(yarp::os::idl::WireState &nstate, yarp::os::idl::WireState &nstate2, size_t &len)
bool readBlock(char *const data, size_t len)
void readSetBegin(yarp::os::idl::WireState &nstate, size_t &len)
IDL-friendly connection writer.
bool writeBool(bool x, bool skip_tag=false) const
bool write(const WirePortable &obj) const
bool writeI32(std::int32_t x, bool skip_tag=false) const
bool writeListHeader(int len) const
bool writeTag(const char *tag, int split, int len) const
bool writeBlock(const char *data, size_t len) const
bool writeString(const std::string &str, bool skip_tag=false) const
bool writeListEnd() const
bool writeSetBegin(int tag, size_t len) const
bool writeListBegin(int tag, size_t len) const
bool writeMapBegin(int tag, int tag2, size_t len) const
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)
The main, catch-all namespace for YARP.
#define YARP_VERSION_PATCH
#define YARP_VERSION_MAJOR
#define YARP_VERSION_MINOR