72 static constexpr const char*
s_tag{
"setDTR"};
76 static constexpr const char*
s_prototype{
"bool ISerialMsgs::setDTR(const bool enable)"};
77 static constexpr const char*
s_help{
""};
130 static constexpr const char*
s_tag{
"flush"};
134 static constexpr const char*
s_prototype{
"std::int32_t ISerialMsgs::flush()"};
165 return write(writer);
180 if (!writeTag(writer)) {
183 if (!writeArgs(writer)) {
207 if (!readTag(reader)) {
210 if (!readArgs(reader)) {
249 return write(writer);
280 if (!reader.
readBool(return_helper)) {
309 return write(writer);
324 if (!writeTag(writer)) {
327 if (!writeArgs(writer)) {
348 if (!readTag(reader)) {
351 if (!readArgs(reader)) {
382 return write(writer);
397 if (!writer.
writeI32(return_helper)) {
413 if (!reader.
readI32(return_helper)) {
428 yarp().setOwner(*
this);
433 if (!
yarp().canWrite()) {
437 bool ok =
yarp().write(helper, helper);
438 return ok ? helper.reply.return_helper :
bool{};
443 if (!
yarp().canWrite()) {
447 bool ok =
yarp().write(helper, helper);
448 return ok ? helper.reply.return_helper : std::int32_t{};
454 bool showAll = (functionName ==
"--all");
455 std::vector<std::string> helpString;
457 helpString.emplace_back(
"*** Available commands:");
460 helpString.emplace_back(
"help");
468 if (functionName ==
"help") {
469 helpString.emplace_back(
"std::vector<std::string> help(const std::string& functionName = \"--all\")");
470 helpString.emplace_back(
"Return list of available commands, or help message for a specific function");
471 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");
472 helpString.emplace_back(
"@return list of strings (one string per line)");
475 if (helpString.empty()) {
476 helpString.emplace_back(
"Command not found");
484 constexpr size_t max_tag_len = 1;
494 std::string tag = reader.
readTag(1);
495 bool direct = (tag ==
"__direct__");
499 while (tag_len <= max_tag_len && !reader.
isError()) {
531 std::string functionName;
533 functionName =
"--all";
535 auto help_strings = help(functionName);
541 if (!writer.
writeTag(
"many", 1, 0)) {
547 for (
const auto& help_string : help_strings) {
563 std::string next_tag = reader.
readTag(1);
564 if (next_tag.empty()) {
567 tag.append(
"_").append(next_tag);
568 tag_len = std::count(tag.begin(), tag.end(),
'_') + 1;
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool writeArgs(const yarp::os::idl::WireWriter &writer) const
~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 readTag(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.
~Reply() override=default
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
static constexpr size_t s_reply_len
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.
std::int32_t(*)() funcptr_t
static constexpr size_t s_cmd_len
static constexpr const char * s_help
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
ISerialMsgs_flush_helper()=default
void call(ISerialMsgs *ptr)
static constexpr const char * s_prototype
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 readArgs(yarp::os::idl::WireReader &reader)
bool readTag(yarp::os::idl::WireReader &reader)
bool writeArgs(const yarp::os::idl::WireWriter &writer) const
bool writeTag(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 const char * s_help
bool(*)(const bool) funcptr_t
static constexpr size_t s_tag_len
void call(ISerialMsgs *ptr)
static constexpr const char * s_tag
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
static constexpr size_t s_reply_len
ISerialMsgs_setDTR_helper()=default
static constexpr size_t s_cmd_len
static constexpr const char * s_prototype
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
virtual std::vector< std::string > help(const std::string &functionName="--all")
virtual bool setDTR(const bool enable)
virtual std::int32_t flush()
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
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.
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 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
The main, catch-all namespace for YARP.