|
| 1 | +/* |
| 2 | + * SPDX-FileCopyrightText: 2023-2023 Istituto Italiano di Tecnologia (IIT) |
| 3 | + * SPDX-License-Identifier: LGPL-2.1-or-later |
| 4 | + */ |
| 5 | + |
| 6 | + |
| 7 | +// Generated by yarpDeviceParamParserGenerator (2.0) |
| 8 | +// This is an automatically generated file. Please do not edit it. |
| 9 | +// It will be re-generated if the cmake flag ALLOW_DEVICE_PARAM_PARSER_GERNERATION is ON. |
| 10 | + |
| 11 | +// Generated on: Mon May 26 10:28:39 2025 |
| 12 | + |
| 13 | + |
| 14 | +#include "FrameTransformGet_nwc_yarp_ParamsParser.h" |
| 15 | +#include <yarp/os/LogStream.h> |
| 16 | +#include <yarp/os/Value.h> |
| 17 | + |
| 18 | +namespace { |
| 19 | + YARP_LOG_COMPONENT(FrameTransformGet_nwc_yarpParamsCOMPONENT, "yarp.device.FrameTransformGet_nwc_yarp") |
| 20 | +} |
| 21 | + |
| 22 | + |
| 23 | +FrameTransformGet_nwc_yarp_ParamsParser::FrameTransformGet_nwc_yarp_ParamsParser() |
| 24 | +{ |
| 25 | +} |
| 26 | + |
| 27 | + |
| 28 | +std::vector<std::string> FrameTransformGet_nwc_yarp_ParamsParser::getListOfParams() const |
| 29 | +{ |
| 30 | + std::vector<std::string> params; |
| 31 | + params.push_back("streaming_enabled"); |
| 32 | + params.push_back("output_streaming_port_prefix"); |
| 33 | + params.push_back("input_streaming_port_prefix"); |
| 34 | + params.push_back("nws_thrift_port_prefix"); |
| 35 | + params.push_back("nwc_thrift_port_prefix"); |
| 36 | + params.push_back("default_server"); |
| 37 | + params.push_back("default_client"); |
| 38 | + return params; |
| 39 | +} |
| 40 | + |
| 41 | + |
| 42 | +bool FrameTransformGet_nwc_yarp_ParamsParser::getParamValue(const std::string& paramName, std::string& paramValue) const |
| 43 | +{ |
| 44 | + if (paramName =="streaming_enabled") |
| 45 | + { |
| 46 | + if (m_streaming_enabled==true) paramValue = "true"; |
| 47 | + else paramValue = "false"; |
| 48 | + return true; |
| 49 | + } |
| 50 | + if (paramName =="output_streaming_port_prefix") |
| 51 | + { |
| 52 | + if (m_output_streaming_port_prefix==true) paramValue = "true"; |
| 53 | + else paramValue = "false"; |
| 54 | + return true; |
| 55 | + } |
| 56 | + if (paramName =="input_streaming_port_prefix") |
| 57 | + { |
| 58 | + paramValue = m_input_streaming_port_prefix; |
| 59 | + return true; |
| 60 | + } |
| 61 | + if (paramName =="nws_thrift_port_prefix") |
| 62 | + { |
| 63 | + paramValue = m_nws_thrift_port_prefix; |
| 64 | + return true; |
| 65 | + } |
| 66 | + if (paramName =="nwc_thrift_port_prefix") |
| 67 | + { |
| 68 | + paramValue = m_nwc_thrift_port_prefix; |
| 69 | + return true; |
| 70 | + } |
| 71 | + if (paramName =="default_server") |
| 72 | + { |
| 73 | + paramValue = m_default_server; |
| 74 | + return true; |
| 75 | + } |
| 76 | + if (paramName =="default_client") |
| 77 | + { |
| 78 | + if (m_default_client==true) paramValue = "true"; |
| 79 | + else paramValue = "false"; |
| 80 | + return true; |
| 81 | + } |
| 82 | + |
| 83 | + yError() <<"parameter '" << paramName << "' was not found"; |
| 84 | + return false; |
| 85 | + |
| 86 | +} |
| 87 | + |
| 88 | + |
| 89 | +std::string FrameTransformGet_nwc_yarp_ParamsParser::getConfiguration() const |
| 90 | +{ |
| 91 | + //This is a sub-optimal solution. |
| 92 | + //Ideally getConfiguration() should return all parameters but it is currently |
| 93 | + //returning only user provided parameters (excluding default values) |
| 94 | + //This behaviour will be fixed in the near future. |
| 95 | + std::string s_cfg = m_provided_configuration; |
| 96 | + return s_cfg; |
| 97 | +} |
| 98 | + |
| 99 | +bool FrameTransformGet_nwc_yarp_ParamsParser::parseParams(const yarp::os::Searchable & config) |
| 100 | +{ |
| 101 | + //Check for --help option |
| 102 | + if (config.check("help")) |
| 103 | + { |
| 104 | + yCInfo(FrameTransformGet_nwc_yarpParamsCOMPONENT) << getDocumentationOfDeviceParams(); |
| 105 | + } |
| 106 | + |
| 107 | + m_provided_configuration = config.toString(); |
| 108 | + yarp::os::Property prop_check(m_provided_configuration.c_str()); |
| 109 | + //Parser of parameter streaming_enabled |
| 110 | + { |
| 111 | + if (config.check("streaming_enabled")) |
| 112 | + { |
| 113 | + m_streaming_enabled = config.find("streaming_enabled").asBool(); |
| 114 | + yCInfo(FrameTransformGet_nwc_yarpParamsCOMPONENT) << "Parameter 'streaming_enabled' using value:" << m_streaming_enabled; |
| 115 | + } |
| 116 | + else |
| 117 | + { |
| 118 | + yCInfo(FrameTransformGet_nwc_yarpParamsCOMPONENT) << "Parameter 'streaming_enabled' using DEFAULT value:" << m_streaming_enabled; |
| 119 | + } |
| 120 | + prop_check.unput("streaming_enabled"); |
| 121 | + } |
| 122 | + |
| 123 | + //Parser of parameter output_streaming_port_prefix |
| 124 | + { |
| 125 | + if (config.check("output_streaming_port_prefix")) |
| 126 | + { |
| 127 | + m_output_streaming_port_prefix = config.find("output_streaming_port_prefix").asBool(); |
| 128 | + yCInfo(FrameTransformGet_nwc_yarpParamsCOMPONENT) << "Parameter 'output_streaming_port_prefix' using value:" << m_output_streaming_port_prefix; |
| 129 | + } |
| 130 | + else |
| 131 | + { |
| 132 | + yCInfo(FrameTransformGet_nwc_yarpParamsCOMPONENT) << "Parameter 'output_streaming_port_prefix' using DEFAULT value:" << m_output_streaming_port_prefix; |
| 133 | + } |
| 134 | + prop_check.unput("output_streaming_port_prefix"); |
| 135 | + } |
| 136 | + |
| 137 | + //Parser of parameter input_streaming_port_prefix |
| 138 | + { |
| 139 | + if (config.check("input_streaming_port_prefix")) |
| 140 | + { |
| 141 | + m_input_streaming_port_prefix = config.find("input_streaming_port_prefix").asString(); |
| 142 | + yCInfo(FrameTransformGet_nwc_yarpParamsCOMPONENT) << "Parameter 'input_streaming_port_prefix' using value:" << m_input_streaming_port_prefix; |
| 143 | + } |
| 144 | + else |
| 145 | + { |
| 146 | + yCInfo(FrameTransformGet_nwc_yarpParamsCOMPONENT) << "Parameter 'input_streaming_port_prefix' using DEFAULT value:" << m_input_streaming_port_prefix; |
| 147 | + } |
| 148 | + prop_check.unput("input_streaming_port_prefix"); |
| 149 | + } |
| 150 | + |
| 151 | + //Parser of parameter nws_thrift_port_prefix |
| 152 | + { |
| 153 | + if (config.check("nws_thrift_port_prefix")) |
| 154 | + { |
| 155 | + m_nws_thrift_port_prefix = config.find("nws_thrift_port_prefix").asString(); |
| 156 | + yCInfo(FrameTransformGet_nwc_yarpParamsCOMPONENT) << "Parameter 'nws_thrift_port_prefix' using value:" << m_nws_thrift_port_prefix; |
| 157 | + } |
| 158 | + else |
| 159 | + { |
| 160 | + yCInfo(FrameTransformGet_nwc_yarpParamsCOMPONENT) << "Parameter 'nws_thrift_port_prefix' using DEFAULT value:" << m_nws_thrift_port_prefix; |
| 161 | + } |
| 162 | + prop_check.unput("nws_thrift_port_prefix"); |
| 163 | + } |
| 164 | + |
| 165 | + //Parser of parameter nwc_thrift_port_prefix |
| 166 | + { |
| 167 | + if (config.check("nwc_thrift_port_prefix")) |
| 168 | + { |
| 169 | + m_nwc_thrift_port_prefix = config.find("nwc_thrift_port_prefix").asString(); |
| 170 | + yCInfo(FrameTransformGet_nwc_yarpParamsCOMPONENT) << "Parameter 'nwc_thrift_port_prefix' using value:" << m_nwc_thrift_port_prefix; |
| 171 | + } |
| 172 | + else |
| 173 | + { |
| 174 | + yCInfo(FrameTransformGet_nwc_yarpParamsCOMPONENT) << "Parameter 'nwc_thrift_port_prefix' using DEFAULT value:" << m_nwc_thrift_port_prefix; |
| 175 | + } |
| 176 | + prop_check.unput("nwc_thrift_port_prefix"); |
| 177 | + } |
| 178 | + |
| 179 | + //Parser of parameter default_server |
| 180 | + { |
| 181 | + if (config.check("default_server")) |
| 182 | + { |
| 183 | + m_default_server = config.find("default_server").asString(); |
| 184 | + yCInfo(FrameTransformGet_nwc_yarpParamsCOMPONENT) << "Parameter 'default_server' using value:" << m_default_server; |
| 185 | + } |
| 186 | + else |
| 187 | + { |
| 188 | + yCInfo(FrameTransformGet_nwc_yarpParamsCOMPONENT) << "Parameter 'default_server' using DEFAULT value:" << m_default_server; |
| 189 | + } |
| 190 | + prop_check.unput("default_server"); |
| 191 | + } |
| 192 | + |
| 193 | + //Parser of parameter default_client |
| 194 | + { |
| 195 | + if (config.check("default_client")) |
| 196 | + { |
| 197 | + m_default_client = config.find("default_client").asBool(); |
| 198 | + yCInfo(FrameTransformGet_nwc_yarpParamsCOMPONENT) << "Parameter 'default_client' using value:" << m_default_client; |
| 199 | + } |
| 200 | + else |
| 201 | + { |
| 202 | + yCInfo(FrameTransformGet_nwc_yarpParamsCOMPONENT) << "Parameter 'default_client' using DEFAULT value:" << m_default_client; |
| 203 | + } |
| 204 | + prop_check.unput("default_client"); |
| 205 | + } |
| 206 | + |
| 207 | + /* |
| 208 | + //This code check if the user set some parameter which are not check by the parser |
| 209 | + //If the parser is set in strict mode, this will generate an error |
| 210 | + if (prop_check.size() > 0) |
| 211 | + { |
| 212 | + bool extra_params_found = false; |
| 213 | + for (auto it=prop_check.begin(); it!=prop_check.end(); it++) |
| 214 | + { |
| 215 | + if (m_parser_is_strict) |
| 216 | + { |
| 217 | + yCError(FrameTransformGet_nwc_yarpParamsCOMPONENT) << "User asking for parameter: "<<it->name <<" which is unknown to this parser!"; |
| 218 | + extra_params_found = true; |
| 219 | + } |
| 220 | + else |
| 221 | + { |
| 222 | + yCWarning(FrameTransformGet_nwc_yarpParamsCOMPONENT) << "User asking for parameter: "<< it->name <<" which is unknown to this parser!"; |
| 223 | + } |
| 224 | + } |
| 225 | +
|
| 226 | + if (m_parser_is_strict && extra_params_found) |
| 227 | + { |
| 228 | + return false; |
| 229 | + } |
| 230 | + } |
| 231 | + */ |
| 232 | + return true; |
| 233 | +} |
| 234 | + |
| 235 | + |
| 236 | +std::string FrameTransformGet_nwc_yarp_ParamsParser::getDocumentationOfDeviceParams() const |
| 237 | +{ |
| 238 | + std::string doc; |
| 239 | + doc = doc + std::string("\n=============================================\n"); |
| 240 | + doc = doc + std::string("This is the help for device: FrameTransformGet_nwc_yarp\n"); |
| 241 | + doc = doc + std::string("\n"); |
| 242 | + doc = doc + std::string("This is the list of the parameters accepted by the device:\n"); |
| 243 | + doc = doc + std::string("'streaming_enabled': tells whether or not the nwc is instantiated by the frameTransformClient device. If true, \"/frameTransformClient\" will appended to the port name prefix\n"); |
| 244 | + doc = doc + std::string("'output_streaming_port_prefix': tells whether or not the nws is instantiated by the frameTransformServer device. If true, \"/frameTransformServer/frameTransformGet_nws_yarp\" will appended to the port name prefix\n"); |
| 245 | + doc = doc + std::string("'input_streaming_port_prefix': a prefix for the nwc thrift rpc port name\n"); |
| 246 | + doc = doc + std::string("'nws_thrift_port_prefix': a prefix for the nws thrift rpc port name\n"); |
| 247 | + doc = doc + std::string("'nwc_thrift_port_prefix': a prefix for the input streaming port name (if the port is enabled)\n"); |
| 248 | + doc = doc + std::string("'default_server': a prefix for the output streaming port name (if the port is enabled)\n"); |
| 249 | + doc = doc + std::string("'default_client': if enabled, tfs are received from the streaming port instead of using RPCs\n"); |
| 250 | + doc = doc + std::string("\n"); |
| 251 | + doc = doc + std::string("Here are some examples of invocation command with yarpdev, with all params:\n"); |
| 252 | + doc = doc + " yarpdev --device frameTransformGet_nwc_yarp --streaming_enabled true --output_streaming_port_prefix true --input_streaming_port_prefix <optional_value> --nws_thrift_port_prefix <optional_value> --nwc_thrift_port_prefix <optional_value> --default_server <optional_value> --default_client false\n"; |
| 253 | + doc = doc + std::string("Using only mandatory params:\n"); |
| 254 | + doc = doc + " yarpdev --device frameTransformGet_nwc_yarp\n"; |
| 255 | + doc = doc + std::string("=============================================\n\n"); return doc; |
| 256 | +} |
0 commit comments