43 if (!writer.
writeString(
"getRemoteProtocolVersion")) {
57 if (!helper_proto.read(connection)) {
67 if(!
yarp().canWrite()) {
68 yError(
" Missing server method FakeTestMsgs::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();
155 static constexpr const char*
s_tag{
"doSomethingRPC"};
159 static constexpr const char*
s_prototype{
"yarp::dev::ReturnValue FakeTestMsgs::doSomethingRPC()"};
213 static constexpr const char*
s_tag{
"doSomethingUnimplementedRPC"};
217 static constexpr const char*
s_prototype{
"yarp::dev::ReturnValue FakeTestMsgs::doSomethingUnimplementedRPC()"};
238 return write(writer);
253 if (!writeTag(writer)) {
256 if (!writeArgs(writer)) {
277 if (!readTag(reader)) {
280 if (!readArgs(reader)) {
311 return write(writer);
323 if (!writer.
write(return_helper)) {
336 if (!reader.
read(return_helper)) {
365 return write(writer);
380 if (!writeTag(writer)) {
383 if (!writeArgs(writer)) {
404 if (!readTag(reader)) {
407 if (!readArgs(reader)) {
438 return write(writer);
450 if (!writer.
write(return_helper)) {
463 if (!reader.
read(return_helper)) {
478 yarp().setOwner(*
this);
483 if (!
yarp().canWrite()) {
487 bool ok =
yarp().write(helper, helper);
493 if (!
yarp().canWrite()) {
497 bool ok =
yarp().write(helper, helper);
504 bool showAll = (functionName ==
"--all");
505 std::vector<std::string> helpString;
507 helpString.emplace_back(
"*** Available commands:");
510 helpString.emplace_back(
"help");
518 if (functionName ==
"help") {
519 helpString.emplace_back(
"std::vector<std::string> help(const std::string& functionName = \"--all\")");
520 helpString.emplace_back(
"Return list of available commands, or help message for a specific function");
521 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");
522 helpString.emplace_back(
"@return list of strings (one string per line)");
525 if (helpString.empty()) {
526 helpString.emplace_back(
"Command not found");
534 constexpr size_t max_tag_len = 1;
544 std::string tag = reader.
readTag(1);
545 bool direct = (tag ==
"__direct__");
549 while (tag_len <= max_tag_len && !reader.
isError()) {
550 if(tag ==
"getRemoteProtocolVersion") {
557 auto proto = getLocalProtocolVersion();
563 if (!writer.
write(proto)) {
601 std::string functionName;
603 functionName =
"--all";
605 auto help_strings = help(functionName);
611 if (!writer.
writeTag(
"many", 1, 0)) {
617 for (
const auto& help_string : help_strings) {
633 std::string next_tag = reader.
readTag(1);
634 if (next_tag.empty()) {
637 tag.append(
"_").append(next_tag);
638 tag_len = std::count(tag.begin(), tag.end(),
'_') + 1;
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool readArgs(yarp::os::idl::WireReader &reader)
bool writeTag(const yarp::os::idl::WireWriter &writer) const
bool writeArgs(const yarp::os::idl::WireWriter &writer) const
bool readTag(yarp::os::idl::WireReader &reader)
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
~Command() override=default
yarp::dev::ReturnValue return_helper
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.
static constexpr const char * s_help
yarp::dev::ReturnValue(*)() funcptr_t
static constexpr size_t s_tag_len
FakeTestMsgs_doSomethingRPC_helper()=default
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
static constexpr size_t s_cmd_len
void call(FakeTestMsgs *ptr)
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 size_t s_reply_len
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 writeTag(const yarp::os::idl::WireWriter &writer) const
~Command() override=default
yarp::dev::ReturnValue return_helper
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
yarp::dev::ReturnValue(*)() funcptr_t
static constexpr size_t s_cmd_len
static constexpr size_t s_reply_len
static constexpr const char * s_tag
void call(FakeTestMsgs *ptr)
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
FakeTestMsgs_doSomethingUnimplementedRPC_helper()=default
static constexpr const char * s_prototype
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_help
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
yarp::os::ApplicationNetworkProtocolVersion helper_proto
FakeTestMsgs_getRemoteProtocolVersion_helper()=default
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
virtual yarp::dev::ReturnValue doSomethingUnimplementedRPC()
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
virtual std::vector< std::string > help(const std::string &functionName="--all")
virtual yarp::os::ApplicationNetworkProtocolVersion getRemoteProtocolVersion()
virtual yarp::dev::ReturnValue doSomethingRPC()
virtual yarp::os::ApplicationNetworkProtocolVersion getLocalProtocolVersion()
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)
std::string readTag(size_t len=static_cast< size_t >(-1))
bool read(WirePortable &obj)
IDL-friendly connection writer.
bool write(const WirePortable &obj) 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
constexpr std::int16_t protocol_version
#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