46 if (!writer.
writeString(
"getRemoteProtocolVersion")) {
60 if (!helper_proto.read(connection)) {
70 if(!
yarp().canWrite()) {
71 yError(
" Missing server method ILLMMsgs::getRemoteProtocolVersion");
76 return helper.helper_proto;}
87 if (remproto.protocol_version != locproto.protocol_version)
89 yCError(SERVICE_LOG_COMPONENT) <<
"Invalid communication protocol.";
90 yCError(SERVICE_LOG_COMPONENT) <<
"Local Protocol Version: " << locproto.toString();
91 yCError(SERVICE_LOG_COMPONENT) <<
"Remote Protocol Version: " << remproto.toString();
166 static constexpr const char*
s_tag{
"setPrompt"};
170 static constexpr const char*
s_prototype{
"yarp::dev::ReturnValue ILLMMsgs::setPrompt(const std::string& prompt)"};
224 static constexpr const char*
s_tag{
"readPrompt"};
228 static constexpr const char*
s_prototype{
"return_readPrompt ILLMMsgs::readPrompt()"};
287 static constexpr const char*
s_tag{
"ask"};
291 static constexpr const char*
s_prototype{
"return_ask ILLMMsgs::ask(const std::string& question)"};
345 static constexpr const char*
s_tag{
"getConversation"};
349 static constexpr const char*
s_prototype{
"return_getConversation ILLMMsgs::getConversation()"};
403 static constexpr const char*
s_tag{
"deleteConversation"};
407 static constexpr const char*
s_prototype{
"yarp::dev::ReturnValue ILLMMsgs::deleteConversation()"};
461 static constexpr const char*
s_tag{
"refreshConversation"};
465 static constexpr const char*
s_prototype{
"yarp::dev::ReturnValue ILLMMsgs::refreshConversation()"};
496 return write(writer);
511 if (!writeTag(writer)) {
514 if (!writeArgs(writer)) {
538 if (!readTag(reader)) {
541 if (!readArgs(reader)) {
580 return write(writer);
592 if (!writer.
write(return_helper)) {
605 if (!reader.
read(return_helper)) {
634 return write(writer);
649 if (!writeTag(writer)) {
652 if (!writeArgs(writer)) {
673 if (!readTag(reader)) {
676 if (!readArgs(reader)) {
707 return write(writer);
722 if (!writer.
write(return_helper)) {
738 if (!reader.
read(return_helper)) {
777 return write(writer);
792 if (!writeTag(writer)) {
795 if (!writeArgs(writer)) {
819 if (!readTag(reader)) {
822 if (!readArgs(reader)) {
861 return write(writer);
876 if (!writer.
write(return_helper)) {
892 if (!reader.
read(return_helper)) {
921 return write(writer);
936 if (!writeTag(writer)) {
939 if (!writeArgs(writer)) {
960 if (!readTag(reader)) {
963 if (!readArgs(reader)) {
994 return write(writer);
1000 return read(reader);
1009 if (!writer.
write(return_helper)) {
1025 if (!reader.
read(return_helper)) {
1054 return write(writer);
1064 return read(reader);
1069 if (!writeTag(writer)) {
1072 if (!writeArgs(writer)) {
1093 if (!readTag(reader)) {
1096 if (!readArgs(reader)) {
1127 return write(writer);
1133 return read(reader);
1139 if (!writer.
write(return_helper)) {
1152 if (!reader.
read(return_helper)) {
1181 return write(writer);
1191 return read(reader);
1196 if (!writeTag(writer)) {
1199 if (!writeArgs(writer)) {
1220 if (!readTag(reader)) {
1223 if (!readArgs(reader)) {
1254 return write(writer);
1260 return read(reader);
1266 if (!writer.
write(return_helper)) {
1279 if (!reader.
read(return_helper)) {
1294 yarp().setOwner(*
this);
1299 if (!
yarp().canWrite()) {
1303 bool ok =
yarp().write(helper, helper);
1309 if (!
yarp().canWrite()) {
1313 bool ok =
yarp().write(helper, helper);
1317 return failed_reply;
1319 return helper.reply.return_helper;
1324 if (!
yarp().canWrite()) {
1328 bool ok =
yarp().write(helper, helper);
1332 return failed_reply;
1334 return helper.reply.return_helper;
1339 if (!
yarp().canWrite()) {
1343 bool ok =
yarp().write(helper, helper);
1347 return failed_reply;
1349 return helper.reply.return_helper;
1354 if (!
yarp().canWrite()) {
1358 bool ok =
yarp().write(helper, helper);
1364 if (!
yarp().canWrite()) {
1368 bool ok =
yarp().write(helper, helper);
1375 bool showAll = (functionName ==
"--all");
1376 std::vector<std::string> helpString;
1378 helpString.emplace_back(
"*** Available commands:");
1385 helpString.emplace_back(
"help");
1405 if (functionName ==
"help") {
1406 helpString.emplace_back(
"std::vector<std::string> help(const std::string& functionName = \"--all\")");
1407 helpString.emplace_back(
"Return list of available commands, or help message for a specific function");
1408 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");
1409 helpString.emplace_back(
"@return list of strings (one string per line)");
1412 if (helpString.empty()) {
1413 helpString.emplace_back(
"Command not found");
1421 constexpr size_t max_tag_len = 1;
1431 std::string tag = reader.
readTag(1);
1432 bool direct = (tag ==
"__direct__");
1436 while (tag_len <= max_tag_len && !reader.
isError()) {
1437 if(tag ==
"getRemoteProtocolVersion") {
1444 auto proto = getLocalProtocolVersion();
1450 if (!writer.
write(proto)) {
1547 if (tag ==
"help") {
1548 std::string functionName;
1550 functionName =
"--all";
1552 auto help_strings = help(functionName);
1558 if (!writer.
writeTag(
"many", 1, 0)) {
1564 for (
const auto& help_string : help_strings) {
1580 std::string next_tag = reader.
readTag(1);
1581 if (next_tag.empty()) {
1584 tag.append(
"_").append(next_tag);
1585 tag_len = std::count(tag.begin(), tag.end(),
'_') + 1;
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)
~Command() override=default
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 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.
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
static constexpr size_t s_tag_len
static constexpr const char * s_tag
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
ILLMMsgs_ask_helper()=default
static constexpr const char * s_prototype
static constexpr size_t s_cmd_len
return_ask(*)(const std::string &) funcptr_t
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool readArgs(yarp::os::idl::WireReader &reader)
bool readTag(yarp::os::idl::WireReader &reader)
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
~Command() override=default
bool writeTag(const yarp::os::idl::WireWriter &writer) const
bool writeArgs(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
yarp::dev::ReturnValue return_helper
static constexpr const char * s_prototype
ILLMMsgs_deleteConversation_helper()=default
yarp::dev::ReturnValue(*)() funcptr_t
static constexpr size_t s_reply_len
static constexpr const char * s_tag
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 size_t s_tag_len
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool readTag(yarp::os::idl::WireReader &reader)
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool writeTag(const yarp::os::idl::WireWriter &writer) const
bool writeArgs(const yarp::os::idl::WireWriter &writer) const
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool readArgs(yarp::os::idl::WireReader &reader)
~Command() override=default
~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.
return_getConversation return_helper
static constexpr const char * s_tag
static constexpr size_t s_tag_len
static constexpr const char * s_prototype
return_getConversation(*)() funcptr_t
static constexpr size_t s_reply_len
static constexpr size_t s_cmd_len
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
static constexpr const char * s_help
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
ILLMMsgs_getConversation_helper()=default
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
ILLMMsgs_getRemoteProtocolVersion_helper()=default
yarp::os::ApplicationNetworkProtocolVersion helper_proto
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 writeArgs(const yarp::os::idl::WireWriter &writer) const
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
~Command() override=default
bool writeTag(const yarp::os::idl::WireWriter &writer) const
bool readTag(yarp::os::idl::WireReader &reader)
bool readArgs(yarp::os::idl::WireReader &reader)
return_readPrompt return_helper
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 read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
ILLMMsgs_readPrompt_helper()=default
static constexpr const char * s_prototype
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
return_readPrompt(*)() funcptr_t
static constexpr size_t s_cmd_len
static constexpr const char * s_tag
static constexpr size_t s_reply_len
static constexpr size_t s_tag_len
static constexpr const char * s_help
bool writeArgs(const yarp::os::idl::WireWriter &writer) const
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool readArgs(yarp::os::idl::WireReader &reader)
~Command() override=default
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)
~Reply() override=default
yarp::dev::ReturnValue 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.
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_reply_len
static constexpr const char * s_prototype
static constexpr size_t s_cmd_len
yarp::dev::ReturnValue(*)() funcptr_t
static constexpr const char * s_help
static constexpr const char * s_tag
ILLMMsgs_refreshConversation_helper()=default
static constexpr size_t s_tag_len
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool writeArgs(const yarp::os::idl::WireWriter &writer) const
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 readArgs(yarp::os::idl::WireReader &reader)
~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.
~Reply() override=default
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
yarp::dev::ReturnValue return_helper
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_reply_len
ILLMMsgs_setPrompt_helper()=default
static constexpr const char * s_tag
static constexpr size_t s_cmd_len
static constexpr size_t s_tag_len
static constexpr const char * s_prototype
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
yarp::dev::ReturnValue(*)(const std::string &) funcptr_t
virtual yarp::dev::ReturnValue deleteConversation()
virtual yarp::dev::ReturnValue refreshConversation()
virtual bool checkProtocolVersion()
virtual return_ask ask(const std::string &question)
virtual yarp::dev::ReturnValue setPrompt(const std::string &prompt)
virtual std::vector< std::string > help(const std::string &functionName="--all")
virtual return_readPrompt readPrompt()
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
virtual yarp::os::ApplicationNetworkProtocolVersion getLocalProtocolVersion()
virtual return_getConversation getConversation()
virtual yarp::os::ApplicationNetworkProtocolVersion getRemoteProtocolVersion()
@ return_value_error_nws_nwc_communication_error
Method is not (yet) implemented.
yarp::dev::ReturnValue ret
yarp::dev::ReturnValue ret
yarp::dev::ReturnValue ret
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
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)
For streams capable of holding different kinds of content, check what they actually have.
The main, catch-all namespace for YARP.
#define YARP_VERSION_PATCH
#define YARP_VERSION_MAJOR
#define YARP_VERSION_MINOR