44 if (!writer.
writeString(
"getRemoteProtocolVersion")) {
58 if (!helper_proto.read(connection)) {
68 if(!
yarp().canWrite()) {
69 yError(
" Missing server method yarprobotinterfaceRpc::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();
159 static constexpr const char*
s_tag{
"get_phase"};
163 static constexpr const char*
s_prototype{
"std::string yarprobotinterfaceRpc::get_phase()"};
165 "Returns current phase."
219 static constexpr const char*
s_tag{
"get_level"};
223 static constexpr const char*
s_prototype{
"std::int32_t yarprobotinterfaceRpc::get_level()"};
225 "Returns current level."
279 static constexpr const char*
s_tag{
"get_robot"};
283 static constexpr const char*
s_prototype{
"std::string yarprobotinterfaceRpc::get_robot()"};
285 "Returns robot name."
339 static constexpr const char*
s_tag{
"is_ready"};
343 static constexpr const char*
s_prototype{
"bool yarprobotinterfaceRpc::is_ready()"};
345 "Returns true if yarprobotinterface is ready (all startup actions\n"
346 "performed and no interrupt called)."
400 static constexpr const char*
s_tag{
"quit"};
404 static constexpr const char*
s_prototype{
"std::string yarprobotinterfaceRpc::quit()"};
406 "Closes yarprobotinterface."
460 static constexpr const char*
s_tag{
"bye"};
464 static constexpr const char*
s_prototype{
"std::string yarprobotinterfaceRpc::bye()"};
466 "Closes yarprobotinterface."
520 static constexpr const char*
s_tag{
"exit"};
524 static constexpr const char*
s_prototype{
"std::string yarprobotinterfaceRpc::exit()"};
526 "Closes yarprobotinterface."
547 return write(writer);
562 if (!writeTag(writer)) {
565 if (!writeArgs(writer)) {
586 if (!readTag(reader)) {
589 if (!readArgs(reader)) {
620 return write(writer);
680 return write(writer);
695 if (!writeTag(writer)) {
698 if (!writeArgs(writer)) {
719 if (!readTag(reader)) {
722 if (!readArgs(reader)) {
753 return write(writer);
768 if (!writer.
writeI32(return_helper)) {
784 if (!reader.
readI32(return_helper)) {
813 return write(writer);
828 if (!writeTag(writer)) {
831 if (!writeArgs(writer)) {
852 if (!readTag(reader)) {
855 if (!readArgs(reader)) {
886 return write(writer);
946 return write(writer);
961 if (!writeTag(writer)) {
964 if (!writeArgs(writer)) {
985 if (!readTag(reader)) {
988 if (!readArgs(reader)) {
1019 return write(writer);
1025 return read(reader);
1050 if (!reader.
readBool(return_helper)) {
1079 return write(writer);
1089 return read(reader);
1094 if (!writeTag(writer)) {
1097 if (!writeArgs(writer)) {
1118 if (!readTag(reader)) {
1121 if (!readArgs(reader)) {
1152 return write(writer);
1158 return read(reader);
1212 return write(writer);
1222 return read(reader);
1227 if (!writeTag(writer)) {
1230 if (!writeArgs(writer)) {
1251 if (!readTag(reader)) {
1254 if (!readArgs(reader)) {
1285 return write(writer);
1291 return read(reader);
1345 return write(writer);
1355 return read(reader);
1360 if (!writeTag(writer)) {
1363 if (!writeArgs(writer)) {
1384 if (!readTag(reader)) {
1387 if (!readArgs(reader)) {
1418 return write(writer);
1424 return read(reader);
1464 yarp().setOwner(*
this);
1469 if (!
yarp().canWrite()) {
1473 bool ok =
yarp().write(helper, helper);
1474 return ok ? helper.reply.return_helper : std::string{};
1479 if (!
yarp().canWrite()) {
1483 bool ok =
yarp().write(helper, helper);
1484 return ok ? helper.reply.return_helper : std::int32_t{};
1489 if (!
yarp().canWrite()) {
1493 bool ok =
yarp().write(helper, helper);
1494 return ok ? helper.reply.return_helper : std::string{};
1499 if (!
yarp().canWrite()) {
1503 bool ok =
yarp().write(helper, helper);
1504 return ok ? helper.reply.return_helper :
bool{};
1509 if (!
yarp().canWrite()) {
1513 bool ok =
yarp().write(helper, helper);
1514 return ok ? helper.reply.return_helper : std::string{};
1519 if (!
yarp().canWrite()) {
1523 bool ok =
yarp().write(helper, helper);
1524 return ok ? helper.reply.return_helper : std::string{};
1529 if (!
yarp().canWrite()) {
1533 bool ok =
yarp().write(helper, helper);
1534 return ok ? helper.reply.return_helper : std::string{};
1540 bool showAll = (functionName ==
"--all");
1541 std::vector<std::string> helpString;
1543 helpString.emplace_back(
"*** Available commands:");
1551 helpString.emplace_back(
"help");
1581 if (functionName ==
"help") {
1582 helpString.emplace_back(
"std::vector<std::string> help(const std::string& functionName = \"--all\")");
1583 helpString.emplace_back(
"Return list of available commands, or help message for a specific function");
1584 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");
1585 helpString.emplace_back(
"@return list of strings (one string per line)");
1588 if (helpString.empty()) {
1589 helpString.emplace_back(
"Command not found");
1597 constexpr size_t max_tag_len = 2;
1607 std::string tag = reader.
readTag(1);
1608 bool direct = (tag ==
"__direct__");
1612 while (tag_len <= max_tag_len && !reader.
isError()) {
1613 if(tag ==
"getRemoteProtocolVersion") {
1620 auto proto = getLocalProtocolVersion();
1626 if (!writer.
write(proto)) {
1738 if (tag ==
"help") {
1739 std::string functionName;
1741 functionName =
"--all";
1743 auto help_strings = help(functionName);
1749 if (!writer.
writeTag(
"many", 1, 0)) {
1755 for (
const auto& help_string : help_strings) {
1771 std::string next_tag = reader.
readTag(1);
1772 if (next_tag.empty()) {
1775 tag.append(
"_").append(next_tag);
1776 tag_len = std::count(tag.begin(), tag.end(),
'_') + 1;
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)
bool readI32(std::int32_t &x)
std::string readTag(size_t len=static_cast< size_t >(-1))
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 writeString(const std::string &str, bool skip_tag=false) const
bool writeListEnd() const
bool writeListBegin(int tag, size_t len) const
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool writeTag(const yarp::os::idl::WireWriter &writer) const
bool readArgs(yarp::os::idl::WireReader &reader)
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 write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
~Reply() override=default
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
std::string return_helper
static constexpr const char * s_tag
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
static constexpr const char * s_prototype
static constexpr const char * s_help
static constexpr size_t s_cmd_len
static constexpr size_t s_tag_len
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
std::string(*)() funcptr_t
static constexpr size_t s_reply_len
yarprobotinterfaceRpc_bye_helper()=default
void call(yarprobotinterfaceRpc *ptr)
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
~Command() override=default
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool readTag(yarp::os::idl::WireReader &reader)
bool readArgs(yarp::os::idl::WireReader &reader)
bool writeArgs(const yarp::os::idl::WireWriter &writer) const
bool writeTag(const yarp::os::idl::WireWriter &writer) const
std::string return_helper
~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.
std::string(*)() funcptr_t
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
static constexpr size_t s_tag_len
static constexpr const char * s_prototype
static constexpr size_t s_cmd_len
void call(yarprobotinterfaceRpc *ptr)
static constexpr const char * s_tag
yarprobotinterfaceRpc_exit_helper()=default
static constexpr size_t s_reply_len
static constexpr const char * s_help
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
yarp::os::ApplicationNetworkProtocolVersion helper_proto
yarprobotinterfaceRpc_getRemoteProtocolVersion_helper()=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.
~Command() override=default
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool writeArgs(const yarp::os::idl::WireWriter &writer) const
bool writeTag(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)
bool readArgs(yarp::os::idl::WireReader &reader)
std::int32_t return_helper
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
yarprobotinterfaceRpc_get_level_helper()=default
void call(yarprobotinterfaceRpc *ptr)
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
static constexpr size_t s_tag_len
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
static constexpr const char * s_prototype
std::int32_t(*)() funcptr_t
static constexpr const char * s_help
static constexpr size_t s_cmd_len
static constexpr const char * s_tag
static constexpr size_t s_reply_len
bool writeArgs(const yarp::os::idl::WireWriter &writer) const
bool writeTag(const yarp::os::idl::WireWriter &writer) const
~Command() override=default
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool readTag(yarp::os::idl::WireReader &reader)
bool readArgs(yarp::os::idl::WireReader &reader)
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.
std::string return_helper
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
void call(yarprobotinterfaceRpc *ptr)
std::string(*)() funcptr_t
static constexpr const char * s_help
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
static constexpr size_t s_cmd_len
static constexpr const char * s_prototype
static constexpr size_t s_tag_len
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
static constexpr const char * s_tag
static constexpr size_t s_reply_len
yarprobotinterfaceRpc_get_phase_helper()=default
~Command() override=default
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to 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
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool readTag(yarp::os::idl::WireReader &reader)
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
std::string return_helper
~Reply() override=default
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
static constexpr const char * s_tag
void call(yarprobotinterfaceRpc *ptr)
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
static constexpr const char * s_help
yarprobotinterfaceRpc_get_robot_helper()=default
static constexpr size_t s_tag_len
static constexpr const char * s_prototype
static constexpr size_t s_reply_len
static constexpr size_t s_cmd_len
std::string(*)() funcptr_t
~Command() override=default
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool writeTag(const yarp::os::idl::WireWriter &writer) const
bool readTag(yarp::os::idl::WireReader &reader)
bool readArgs(yarp::os::idl::WireReader &reader)
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.
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
~Reply() override=default
static constexpr size_t s_tag_len
static constexpr size_t s_reply_len
static constexpr const char * s_tag
static constexpr const char * s_prototype
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
static constexpr const char * s_help
static constexpr size_t s_cmd_len
void call(yarprobotinterfaceRpc *ptr)
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
yarprobotinterfaceRpc_is_ready_helper()=default
bool writeTag(const yarp::os::idl::WireWriter &writer) const
~Command() override=default
bool readTag(yarp::os::idl::WireReader &reader)
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool writeArgs(const yarp::os::idl::WireWriter &writer) const
bool readArgs(yarp::os::idl::WireReader &reader)
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
std::string return_helper
~Reply() override=default
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.
static constexpr const char * s_prototype
static constexpr const char * s_tag
static constexpr const char * s_help
yarprobotinterfaceRpc_quit_helper()=default
static constexpr size_t s_tag_len
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
static constexpr size_t s_cmd_len
std::string(*)() funcptr_t
static constexpr size_t s_reply_len
void call(yarprobotinterfaceRpc *ptr)
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
virtual std::string quit()
Closes yarprobotinterface.
virtual bool checkProtocolVersion()
virtual std::string get_phase()
Returns current phase.
virtual std::string get_robot()
Returns robot name.
virtual std::string bye()
Closes yarprobotinterface.
virtual std::string exit()
Closes yarprobotinterface.
virtual std::int32_t get_level()
Returns current level.
virtual yarp::os::ApplicationNetworkProtocolVersion getLocalProtocolVersion()
virtual std::vector< std::string > help(const std::string &functionName="--all")
virtual yarp::os::ApplicationNetworkProtocolVersion getRemoteProtocolVersion()
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
virtual bool is_ready()
Returns true if yarprobotinterface is ready (all startup actions performed and no interrupt called).
#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