43 if (!writer.
writeString(
"getRemoteProtocolVersion")) {
57 if (!helper_proto.read(connection)) {
67 if(!
yarp().canWrite()) {
68 yError(
" Missing server method yarprobotinterfaceRpc::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();
158 static constexpr const char*
s_tag{
"get_phase"};
162 static constexpr const char*
s_prototype{
"std::string yarprobotinterfaceRpc::get_phase()"};
164 "Returns current phase."
218 static constexpr const char*
s_tag{
"get_level"};
222 static constexpr const char*
s_prototype{
"std::int32_t yarprobotinterfaceRpc::get_level()"};
224 "Returns current level."
278 static constexpr const char*
s_tag{
"get_robot"};
282 static constexpr const char*
s_prototype{
"std::string yarprobotinterfaceRpc::get_robot()"};
284 "Returns robot name."
338 static constexpr const char*
s_tag{
"is_ready"};
342 static constexpr const char*
s_prototype{
"bool yarprobotinterfaceRpc::is_ready()"};
344 "Returns true if yarprobotinterface is ready (all startup actions\n"
345 "performed and no interrupt called)."
399 static constexpr const char*
s_tag{
"quit"};
403 static constexpr const char*
s_prototype{
"std::string yarprobotinterfaceRpc::quit()"};
405 "Closes yarprobotinterface."
459 static constexpr const char*
s_tag{
"bye"};
463 static constexpr const char*
s_prototype{
"std::string yarprobotinterfaceRpc::bye()"};
465 "Closes yarprobotinterface."
519 static constexpr const char*
s_tag{
"exit"};
523 static constexpr const char*
s_prototype{
"std::string yarprobotinterfaceRpc::exit()"};
525 "Closes yarprobotinterface."
546 return write(writer);
561 if (!writeTag(writer)) {
564 if (!writeArgs(writer)) {
585 if (!readTag(reader)) {
588 if (!readArgs(reader)) {
619 return write(writer);
679 return write(writer);
694 if (!writeTag(writer)) {
697 if (!writeArgs(writer)) {
718 if (!readTag(reader)) {
721 if (!readArgs(reader)) {
752 return write(writer);
767 if (!writer.
writeI32(return_helper)) {
783 if (!reader.
readI32(return_helper)) {
812 return write(writer);
827 if (!writeTag(writer)) {
830 if (!writeArgs(writer)) {
851 if (!readTag(reader)) {
854 if (!readArgs(reader)) {
885 return write(writer);
945 return write(writer);
960 if (!writeTag(writer)) {
963 if (!writeArgs(writer)) {
984 if (!readTag(reader)) {
987 if (!readArgs(reader)) {
1018 return write(writer);
1024 return read(reader);
1049 if (!reader.
readBool(return_helper)) {
1078 return write(writer);
1088 return read(reader);
1093 if (!writeTag(writer)) {
1096 if (!writeArgs(writer)) {
1117 if (!readTag(reader)) {
1120 if (!readArgs(reader)) {
1151 return write(writer);
1157 return read(reader);
1211 return write(writer);
1221 return read(reader);
1226 if (!writeTag(writer)) {
1229 if (!writeArgs(writer)) {
1250 if (!readTag(reader)) {
1253 if (!readArgs(reader)) {
1284 return write(writer);
1290 return read(reader);
1344 return write(writer);
1354 return read(reader);
1359 if (!writeTag(writer)) {
1362 if (!writeArgs(writer)) {
1383 if (!readTag(reader)) {
1386 if (!readArgs(reader)) {
1417 return write(writer);
1423 return read(reader);
1463 yarp().setOwner(*
this);
1468 if (!
yarp().canWrite()) {
1472 bool ok =
yarp().write(helper, helper);
1473 return ok ? helper.reply.return_helper : std::string{};
1478 if (!
yarp().canWrite()) {
1482 bool ok =
yarp().write(helper, helper);
1483 return ok ? helper.reply.return_helper : std::int32_t{};
1488 if (!
yarp().canWrite()) {
1492 bool ok =
yarp().write(helper, helper);
1493 return ok ? helper.reply.return_helper : std::string{};
1498 if (!
yarp().canWrite()) {
1502 bool ok =
yarp().write(helper, helper);
1503 return ok ? helper.reply.return_helper :
bool{};
1508 if (!
yarp().canWrite()) {
1512 bool ok =
yarp().write(helper, helper);
1513 return ok ? helper.reply.return_helper : std::string{};
1518 if (!
yarp().canWrite()) {
1522 bool ok =
yarp().write(helper, helper);
1523 return ok ? helper.reply.return_helper : std::string{};
1528 if (!
yarp().canWrite()) {
1532 bool ok =
yarp().write(helper, helper);
1533 return ok ? helper.reply.return_helper : std::string{};
1539 bool showAll = (functionName ==
"--all");
1540 std::vector<std::string> helpString;
1542 helpString.emplace_back(
"*** Available commands:");
1550 helpString.emplace_back(
"help");
1580 if (functionName ==
"help") {
1581 helpString.emplace_back(
"std::vector<std::string> help(const std::string& functionName = \"--all\")");
1582 helpString.emplace_back(
"Return list of available commands, or help message for a specific function");
1583 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");
1584 helpString.emplace_back(
"@return list of strings (one string per line)");
1587 if (helpString.empty()) {
1588 helpString.emplace_back(
"Command not found");
1596 constexpr size_t max_tag_len = 2;
1606 std::string tag = reader.
readTag(1);
1607 bool direct = (tag ==
"__direct__");
1611 while (tag_len <= max_tag_len && !reader.
isError()) {
1612 if(tag ==
"getRemoteProtocolVersion") {
1619 auto proto = getLocalProtocolVersion();
1625 if (!writer.
write(proto)) {
1737 if (tag ==
"help") {
1738 std::string functionName;
1740 functionName =
"--all";
1742 auto help_strings = help(functionName);
1748 if (!writer.
writeTag(
"many", 1, 0)) {
1754 for (
const auto& help_string : help_strings) {
1770 std::string next_tag = reader.
readTag(1);
1771 if (next_tag.empty()) {
1774 tag.append(
"_").append(next_tag);
1775 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