@@ -46,6 +46,7 @@ class CLIParser
46
46
struct publisher_config
47
47
{
48
48
uint16_t samples = 0 ;
49
+ uint16_t matched = 1 ;
49
50
};
50
51
51
52
// ! Subscriber application configuration structure
@@ -83,6 +84,9 @@ class CLIParser
83
84
std::cout << " -s <num>, --samples <num> Number of samples to send or receive" << std::endl;
84
85
std::cout << " [0 <= <num> <= 65535]" << std::endl;
85
86
std::cout << " (Default: 0 [unlimited])" << std::endl;
87
+ std::cout << " Publisher options:" << std::endl;
88
+ std::cout << " -m, --matched Number of participants to discover" << std::endl;
89
+ std::cout << " before start publishing (Default: 1)" << std::endl;
86
90
std::cout << " Subscriber options:" << std::endl;
87
91
std::cout << " -w, --waitset Use waitset & read condition" << std::endl;
88
92
std::exit (return_code);
@@ -194,6 +198,40 @@ class CLIParser
194
198
print_help (EXIT_FAILURE);
195
199
}
196
200
}
201
+ else if (arg == " -m" || arg == " --matched" )
202
+ {
203
+ try
204
+ {
205
+ int input = std::stoi (argv[++i]);
206
+ if (input < std::numeric_limits<std::uint16_t >::min () ||
207
+ input > std::numeric_limits<std::uint16_t >::max ())
208
+ {
209
+ throw std::out_of_range (" matched argument out of range" );
210
+ }
211
+ else
212
+ {
213
+ if (config.entity == CLIParser::EntityKind::PUBLISHER)
214
+ {
215
+ config.pub_config .matched = static_cast <uint16_t >(input);
216
+ }
217
+ else
218
+ {
219
+ EPROSIMA_LOG_ERROR (CLI_PARSER, " matched can only be used with the publisher entity" );
220
+ print_help (EXIT_FAILURE);
221
+ }
222
+ }
223
+ }
224
+ catch (const std::invalid_argument& e)
225
+ {
226
+ EPROSIMA_LOG_ERROR (CLI_PARSER, " invalid sample argument for " + arg + " : " + e.what ());
227
+ print_help (EXIT_FAILURE);
228
+ }
229
+ catch (const std::out_of_range& e)
230
+ {
231
+ EPROSIMA_LOG_ERROR (CLI_PARSER, " sample argument out of range for " + arg + " : " + e.what ());
232
+ print_help (EXIT_FAILURE);
233
+ }
234
+ }
197
235
else
198
236
{
199
237
EPROSIMA_LOG_ERROR (CLI_PARSER, " unknown option " + arg);
0 commit comments