@@ -40,64 +40,77 @@ Controller::Controller(
40
40
: backend_(configuration)
41
41
, model_(backend_.model())
42
42
{
43
- view_. print_initial ();
43
+ // Do nothing
44
44
}
45
45
46
46
void Controller::run ()
47
47
{
48
+ view_.print_initial ();
48
49
utils::Command<CommandValue> command;
49
50
command.command = CommandValue::participant;
50
51
while (command.command != CommandValue::exit )
51
52
{
52
53
command = input_.wait_next_command ();
54
+ run_command_ (command);
55
+ }
56
+ }
53
57
54
- switch (command.command )
55
- {
56
- case CommandValue::participant:
57
- participants_command (command.arguments );
58
- break ;
58
+ void Controller::one_shot_run (
59
+ const std::vector<std::string>& args)
60
+ {
61
+ utils::sleep_for (configuration_.one_shot_wait_time_ms );
62
+ run_command_ (input_.parse_as_command (args));
63
+ }
59
64
60
- case CommandValue::datareader:
61
- readers_command (command.arguments );
62
- break ;
65
+ utils::ReturnCode Controller::reload_allowed_topics (
66
+ const std::shared_ptr<ddspipe::core::AllowedTopicList>& allowed_topics)
67
+ {
68
+ return backend_.reload_allowed_topics (allowed_topics);
69
+ }
63
70
64
- case CommandValue::datawriter:
65
- writers_command (command.arguments );
66
- break ;
71
+ void Controller::run_command_ (
72
+ const utils::Command<CommandValue>& command)
73
+ {
74
+ switch (command.command )
75
+ {
76
+ case CommandValue::participant:
77
+ participants_command_ (command.arguments );
78
+ break ;
67
79
68
- case CommandValue::topic :
69
- topics_command (command.arguments );
70
- break ;
80
+ case CommandValue::datareader :
81
+ readers_command_ (command.arguments );
82
+ break ;
71
83
72
- case CommandValue::print :
73
- print_command (command.arguments );
74
- break ;
84
+ case CommandValue::datawriter :
85
+ writers_command_ (command.arguments );
86
+ break ;
75
87
76
- case CommandValue::version :
77
- version_command (command.arguments );
78
- break ;
88
+ case CommandValue::topic :
89
+ topics_command_ (command.arguments );
90
+ break ;
79
91
80
- case CommandValue::help :
81
- help_command (command.arguments );
82
- break ;
92
+ case CommandValue::print :
93
+ print_command_ (command.arguments );
94
+ break ;
83
95
84
- case CommandValue::error_input :
85
- error_command (command.arguments );
86
- break ;
96
+ case CommandValue::version :
97
+ version_command_ (command.arguments );
98
+ break ;
87
99
88
- default :
89
- break ;
90
- }
91
- }
92
- }
100
+ case CommandValue::help:
101
+ help_command_ (command.arguments );
102
+ break ;
93
103
94
- utils::ReturnCode Controller::reload_allowed_topics (
95
- const std::shared_ptr<ddspipe::core::AllowedTopicList>& allowed_topics)
96
- {
97
- return backend_.reload_allowed_topics (allowed_topics);
104
+ case CommandValue::error_input:
105
+ error_command_ (command.arguments );
106
+ break ;
107
+
108
+ default :
109
+ break ;
110
+ }
98
111
}
99
112
100
- fastrtps::types::DynamicData_ptr Controller::get_dynamic_data (
113
+ fastrtps::types::DynamicData_ptr Controller::get_dynamic_data_ (
101
114
const fastrtps::types::DynamicType_ptr& dyn_type,
102
115
const ddspipe::core::types::RtpsPayloadData& data) noexcept
103
116
{
@@ -119,7 +132,7 @@ void Controller::data_stream_callback_(
119
132
const ddspipe::core::types::RtpsPayloadData& data)
120
133
{
121
134
// Get deserializad data
122
- auto dyn_data = get_dynamic_data (dyn_type, data);
135
+ auto dyn_data = get_dynamic_data_ (dyn_type, data);
123
136
124
137
// TODO this does not make much sense as print does not allow to choose target
125
138
// change in dyn types to be able to print it in view
@@ -146,15 +159,15 @@ void Controller::data_stream_callback_verbose_(
146
159
view_.show (yml);
147
160
148
161
// Get deserializad data
149
- auto dyn_data = get_dynamic_data (dyn_type, data);
162
+ auto dyn_data = get_dynamic_data_ (dyn_type, data);
150
163
151
164
// Print data
152
165
view_.show (" data:\n ---" );
153
166
fastrtps::types::DynamicDataHelper::print (dyn_data.get ());
154
167
view_.show (" ---\n " );
155
168
}
156
169
157
- bool Controller::verbose_argument (
170
+ bool Controller::verbose_argument_ (
158
171
const std::string& argument) const noexcept
159
172
{
160
173
return (
@@ -165,15 +178,15 @@ bool Controller::verbose_argument(
165
178
|| (argument == " V" ));
166
179
}
167
180
168
- bool Controller::all_argument (
181
+ bool Controller::all_argument_ (
169
182
const std::string& argument) const noexcept
170
183
{
171
184
return (
172
185
(argument == " all" )
173
186
|| (argument == " a" ));
174
187
}
175
188
176
- void Controller::participants_command (
189
+ void Controller::participants_command_ (
177
190
const std::vector<std::string>& arguments) noexcept
178
191
{
179
192
dds_entity_command__ (
@@ -194,7 +207,7 @@ void Controller::participants_command(
194
207
);
195
208
}
196
209
197
- void Controller::writers_command (
210
+ void Controller::writers_command_ (
198
211
const std::vector<std::string>& arguments) noexcept
199
212
{
200
213
dds_entity_command__ (
@@ -215,7 +228,7 @@ void Controller::writers_command(
215
228
);
216
229
}
217
230
218
- void Controller::readers_command (
231
+ void Controller::readers_command_ (
219
232
const std::vector<std::string>& arguments) noexcept
220
233
{
221
234
dds_entity_command__ (
@@ -236,7 +249,7 @@ void Controller::readers_command(
236
249
);
237
250
}
238
251
239
- void Controller::topics_command (
252
+ void Controller::topics_command_ (
240
253
const std::vector<std::string>& arguments) noexcept
241
254
{
242
255
Yaml yml;
@@ -246,7 +259,7 @@ void Controller::topics_command(
246
259
// all participants simple
247
260
ddspipe::yaml::set (yml, participants::ModelParser::topics (*model_));
248
261
}
249
- else if (verbose_argument (arguments[1 ]))
262
+ else if (verbose_argument_ (arguments[1 ]))
250
263
{
251
264
// verbose
252
265
ddspipe::yaml::set (yml, participants::ModelParser::topics_verbose (*model_));
@@ -267,7 +280,7 @@ void Controller::topics_command(
267
280
view_.show (yml);
268
281
}
269
282
270
- void Controller::print_command (
283
+ void Controller::print_command_ (
271
284
const std::vector<std::string>& arguments) noexcept
272
285
{
273
286
// Check the number of arguments is correct
@@ -281,7 +294,7 @@ void Controller::print_command(
281
294
}
282
295
283
296
// Print all data
284
- if (all_argument (arguments[1 ]))
297
+ if (all_argument_ (arguments[1 ]))
285
298
{
286
299
bool activated = model_->activate_all (
287
300
std::make_shared<participants::DataStreamer::CallbackType>(
@@ -330,7 +343,7 @@ void Controller::print_command(
330
343
bool verbose = false ;
331
344
if (arguments.size () >= 3 )
332
345
{
333
- verbose = verbose_argument (arguments[2 ]);
346
+ verbose = verbose_argument_ (arguments[2 ]);
334
347
}
335
348
336
349
std::shared_ptr<participants::DataStreamer::CallbackType> callback;
@@ -380,7 +393,7 @@ void Controller::print_command(
380
393
model_->deactivate ();
381
394
}
382
395
383
- void Controller::version_command (
396
+ void Controller::version_command_ (
384
397
const std::vector<std::string>& arguments) noexcept
385
398
{
386
399
view_.show (STR_ENTRY
@@ -390,15 +403,15 @@ void Controller::version_command(
390
403
<< FASTDDSSPY_PARTICIPANTS_COMMIT_HASH);
391
404
}
392
405
393
- void Controller::help_command (
406
+ void Controller::help_command_ (
394
407
const std::vector<std::string>& arguments) noexcept
395
408
{
396
409
// TODO
397
410
view_.show_error (STR_ENTRY
398
411
<< " <" << arguments[0 ] << " > command is not implemented yet. Please be patient." );
399
412
}
400
413
401
- void Controller::error_command (
414
+ void Controller::error_command_ (
402
415
const std::vector<std::string>& arguments) noexcept
403
416
{
404
417
view_.show_error (STR_ENTRY
0 commit comments