44 if (!writer.
writeString(
"getRemoteProtocolVersion")) {
58 if (!helper_proto.read(connection)) {
68 if(!
yarp().canWrite()) {
69 yError(
" Missing server method TestMultipleContainers::getRemoteProtocolVersion");
74 return helper.helper_proto;}
85 if (remproto.protocol_version != locproto.protocol_version)
87 yCError(SERVICE_LOG_COMPONENT) <<
"Invalid communication protocol.";
88 yCError(SERVICE_LOG_COMPONENT) <<
"Local Protocol Version: " << locproto.toString();
89 yCError(SERVICE_LOG_COMPONENT) <<
"Remote Protocol Version: " << remproto.toString();
124 explicit Command(
const std::vector<std::int32_t>&
a);
139 std::vector<std::int32_t>
a{};
158 using funcptr_t = bool (*)(
const std::vector<std::int32_t>&);
164 static constexpr const char*
s_tag{
"testList1"};
168 static constexpr const char*
s_prototype{
"bool TestMultipleContainers::testList1(const std::vector<std::int32_t>& a)"};
187 Command(
const std::vector<std::int32_t>&
a,
const std::vector<std::int32_t>&
b);
202 std::vector<std::int32_t>
a{};
203 std::vector<std::int32_t>
b{};
222 using funcptr_t = bool (*)(
const std::vector<std::int32_t>&,
const std::vector<std::int32_t>&);
228 static constexpr const char*
s_tag{
"testList2"};
232 static constexpr const char*
s_prototype{
"bool TestMultipleContainers::testList2(const std::vector<std::int32_t>& a, const std::vector<std::int32_t>& b)"};
251 explicit Command(
const std::map<std::int32_t, std::string>&
a);
266 std::map<std::int32_t, std::string>
a{};
285 using funcptr_t = bool (*)(
const std::map<std::int32_t, std::string>&);
291 static constexpr const char*
s_tag{
"testMap1"};
295 static constexpr const char*
s_prototype{
"bool TestMultipleContainers::testMap1(const std::map<std::int32_t, std::string>& a)"};
314 Command(
const std::map<std::int32_t, std::string>&
a,
const std::map<std::int32_t, std::string>&
b);
329 std::map<std::int32_t, std::string>
a{};
330 std::map<std::int32_t, std::string>
b{};
349 using funcptr_t = bool (*)(
const std::map<std::int32_t, std::string>&,
const std::map<std::int32_t, std::string>&);
355 static constexpr const char*
s_tag{
"testMap2"};
359 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)"};
378 explicit Command(
const std::set<std::int32_t>&
a);
393 std::set<std::int32_t>
a{};
412 using funcptr_t = bool (*)(
const std::set<std::int32_t>&);
418 static constexpr const char*
s_tag{
"testSet1"};
422 static constexpr const char*
s_prototype{
"bool TestMultipleContainers::testSet1(const std::set<std::int32_t>& a)"};
441 Command(
const std::set<std::int32_t>&
a,
const std::set<std::int32_t>&
b);
456 std::set<std::int32_t>
a{};
457 std::set<std::int32_t>
b{};
476 using funcptr_t = bool (*)(
const std::set<std::int32_t>&,
const std::set<std::int32_t>&);
482 static constexpr const char*
s_tag{
"testSet2"};
486 static constexpr const char*
s_prototype{
"bool TestMultipleContainers::testSet2(const std::set<std::int32_t>& a, const std::set<std::int32_t>& b)"};
517 return write(writer);
532 if (!writeTag(writer)) {
535 if (!writeArgs(writer)) {
554 if (!writer.
writeBlock(
reinterpret_cast<const char*
>(a.data()), a.size() *
sizeof(std::int32_t))) {
565 if (!readTag(reader)) {
568 if (!readArgs(reader)) {
599 if constexpr (expected_tag != 0) {
600 if (_csize != 0 && _etype.
code != expected_tag) {
605 if (_csize != 0 && !reader.
readBlock(
reinterpret_cast<char*
>(a.data()), a.size() *
sizeof(std::int32_t))) {
620 return write(writer);
651 if (!reader.
readBool(return_helper)) {
691 return write(writer);
706 if (!writeTag(writer)) {
709 if (!writeArgs(writer)) {
728 if (!writer.
writeBlock(
reinterpret_cast<const char*
>(a.data()), a.size() *
sizeof(std::int32_t))) {
737 if (!writer.
writeBlock(
reinterpret_cast<const char*
>(b.data()), b.size() *
sizeof(std::int32_t))) {
748 if (!readTag(reader)) {
751 if (!readArgs(reader)) {
782 if constexpr (expected_tag != 0) {
783 if (_csize != 0 && _etype.
code != expected_tag) {
788 if (_csize != 0 && !reader.
readBlock(
reinterpret_cast<char*
>(a.data()), a.size() *
sizeof(std::int32_t))) {
803 if constexpr (expected_tag != 0) {
804 if (_csize != 0 && _etype.
code != expected_tag) {
809 if (_csize != 0 && !reader.
readBlock(
reinterpret_cast<char*
>(b.data()), b.size() *
sizeof(std::int32_t))) {
824 return write(writer);
855 if (!reader.
readBool(return_helper)) {
894 return write(writer);
909 if (!writeTag(writer)) {
912 if (!writeArgs(writer)) {
931 for (
const auto& _item : a) {
935 if (!writer.
writeI32(_item.first)) {
953 if (!readTag(reader)) {
956 if (!readArgs(reader)) {
986 for (
size_t _i0 = 0; _i0 < _csize; ++_i0) {
999 std::string& _val1 = a[_key];
1022 return write(writer);
1028 return read(reader);
1053 if (!reader.
readBool(return_helper)) {
1093 return write(writer);
1103 return read(reader);
1108 if (!writeTag(writer)) {
1111 if (!writeArgs(writer)) {
1130 for (
const auto& _item : a) {
1134 if (!writer.
writeI32(_item.first)) {
1150 for (
const auto& _item : b) {
1154 if (!writer.
writeI32(_item.first)) {
1172 if (!readTag(reader)) {
1175 if (!readArgs(reader)) {
1205 for (
size_t _i0 = 0; _i0 < _csize; ++_i0) {
1218 std::string& _val1 = a[_key];
1240 for (
size_t _i0 = 0; _i0 < _csize; ++_i0) {
1253 std::string& _val1 = b[_key];
1276 return write(writer);
1282 return read(reader);
1307 if (!reader.
readBool(return_helper)) {
1346 return write(writer);
1356 return read(reader);
1361 if (!writeTag(writer)) {
1364 if (!writeArgs(writer)) {
1383 for (
const auto& _item : a) {
1396 if (!readTag(reader)) {
1399 if (!readArgs(reader)) {
1428 for (
size_t _i0 = 0; _i0 < _csize; ++_i0) {
1452 return write(writer);
1458 return read(reader);
1483 if (!reader.
readBool(return_helper)) {
1523 return write(writer);
1533 return read(reader);
1538 if (!writeTag(writer)) {
1541 if (!writeArgs(writer)) {
1560 for (
const auto& _item : a) {
1571 for (
const auto& _item : b) {
1584 if (!readTag(reader)) {
1587 if (!readArgs(reader)) {
1616 for (
size_t _i0 = 0; _i0 < _csize; ++_i0) {
1638 for (
size_t _i0 = 0; _i0 < _csize; ++_i0) {
1662 return write(writer);
1668 return read(reader);
1693 if (!reader.
readBool(return_helper)) {
1708 yarp().setOwner(*
this);
1713 if (!
yarp().canWrite()) {
1717 bool ok =
yarp().write(helper, helper);
1718 return ok ? helper.reply.return_helper :
bool{};
1723 if (!
yarp().canWrite()) {
1727 bool ok =
yarp().write(helper, helper);
1728 return ok ? helper.reply.return_helper :
bool{};
1733 if (!
yarp().canWrite()) {
1737 bool ok =
yarp().write(helper, helper);
1738 return ok ? helper.reply.return_helper :
bool{};
1743 if (!
yarp().canWrite()) {
1747 bool ok =
yarp().write(helper, helper);
1748 return ok ? helper.reply.return_helper :
bool{};
1753 if (!
yarp().canWrite()) {
1757 bool ok =
yarp().write(helper, helper);
1758 return ok ? helper.reply.return_helper :
bool{};
1763 if (!
yarp().canWrite()) {
1767 bool ok =
yarp().write(helper, helper);
1768 return ok ? helper.reply.return_helper :
bool{};
1774 bool showAll = (functionName ==
"--all");
1775 std::vector<std::string> helpString;
1777 helpString.emplace_back(
"*** Available commands:");
1784 helpString.emplace_back(
"help");
1804 if (functionName ==
"help") {
1805 helpString.emplace_back(
"std::vector<std::string> help(const std::string& functionName = \"--all\")");
1806 helpString.emplace_back(
"Return list of available commands, or help message for a specific function");
1807 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");
1808 helpString.emplace_back(
"@return list of strings (one string per line)");
1811 if (helpString.empty()) {
1812 helpString.emplace_back(
"Command not found");
1820 constexpr size_t max_tag_len = 1;
1830 std::string tag = reader.
readTag(1);
1831 bool direct = (tag ==
"__direct__");
1835 while (tag_len <= max_tag_len && !reader.
isError()) {
1836 if(tag ==
"getRemoteProtocolVersion") {
1843 auto proto = getLocalProtocolVersion();
1849 if (!writer.
write(proto)) {
1946 if (tag ==
"help") {
1947 std::string functionName;
1949 functionName =
"--all";
1951 auto help_strings = help(functionName);
1957 if (!writer.
writeTag(
"many", 1, 0)) {
1963 for (
const auto& help_string : help_strings) {
1979 std::string next_tag = reader.
readTag(1);
1980 if (next_tag.empty()) {
1983 tag.append(
"_").append(next_tag);
1984 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