segmentation
All Data Structures Namespaces Files Functions Variables Modules Pages
SegmentationModule.cpp
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
9 // Autogenerated by Thrift Compiler (0.12.0-yarped)
10 //
11 // This is an automatically generated file.
12 // It could get re-generated if the ALLOW_IDL_GENERATION flag is on.
13 
14 #include <SegmentationModule.h>
15 
16 #include <yarp/os/idl/WireTypes.h>
17 
18 class SegmentationModule_set_sigmaS_helper :
19  public yarp::os::Portable
20 {
21 public:
22  explicit SegmentationModule_set_sigmaS_helper(const double newValue);
23  bool write(yarp::os::ConnectionWriter& connection) const override;
24  bool read(yarp::os::ConnectionReader& connection) override;
25 
26  double m_newValue;
27 };
28 
29 SegmentationModule_set_sigmaS_helper::SegmentationModule_set_sigmaS_helper(const double newValue) :
30  m_newValue{newValue}
31 {
32 }
33 
34 bool SegmentationModule_set_sigmaS_helper::write(yarp::os::ConnectionWriter& connection) const
35 {
36  yarp::os::idl::WireWriter writer(connection);
37  if (!writer.writeListHeader(3)) {
38  return false;
39  }
40  if (!writer.writeTag("set_sigmaS", 1, 2)) {
41  return false;
42  }
43  if (!writer.writeFloat64(m_newValue)) {
44  return false;
45  }
46  return true;
47 }
48 
49 bool SegmentationModule_set_sigmaS_helper::read(yarp::os::ConnectionReader& connection)
50 {
51  yarp::os::idl::WireReader reader(connection);
52  if (!reader.readListReturn()) {
53  return false;
54  }
55  return true;
56 }
57 
58 class SegmentationModule_set_sigmaR_helper :
59  public yarp::os::Portable
60 {
61 public:
62  explicit SegmentationModule_set_sigmaR_helper(const double newValue);
63  bool write(yarp::os::ConnectionWriter& connection) const override;
64  bool read(yarp::os::ConnectionReader& connection) override;
65 
66  double m_newValue;
67 };
68 
69 SegmentationModule_set_sigmaR_helper::SegmentationModule_set_sigmaR_helper(const double newValue) :
70  m_newValue{newValue}
71 {
72 }
73 
74 bool SegmentationModule_set_sigmaR_helper::write(yarp::os::ConnectionWriter& connection) const
75 {
76  yarp::os::idl::WireWriter writer(connection);
77  if (!writer.writeListHeader(3)) {
78  return false;
79  }
80  if (!writer.writeTag("set_sigmaR", 1, 2)) {
81  return false;
82  }
83  if (!writer.writeFloat64(m_newValue)) {
84  return false;
85  }
86  return true;
87 }
88 
89 bool SegmentationModule_set_sigmaR_helper::read(yarp::os::ConnectionReader& connection)
90 {
91  yarp::os::idl::WireReader reader(connection);
92  if (!reader.readListReturn()) {
93  return false;
94  }
95  return true;
96 }
97 
98 class SegmentationModule_set_minRegion_helper :
99  public yarp::os::Portable
100 {
101 public:
102  explicit SegmentationModule_set_minRegion_helper(const double newValue);
103  bool write(yarp::os::ConnectionWriter& connection) const override;
104  bool read(yarp::os::ConnectionReader& connection) override;
105 
106  double m_newValue;
107 };
108 
109 SegmentationModule_set_minRegion_helper::SegmentationModule_set_minRegion_helper(const double newValue) :
110  m_newValue{newValue}
111 {
112 }
113 
114 bool SegmentationModule_set_minRegion_helper::write(yarp::os::ConnectionWriter& connection) const
115 {
116  yarp::os::idl::WireWriter writer(connection);
117  if (!writer.writeListHeader(3)) {
118  return false;
119  }
120  if (!writer.writeTag("set_minRegion", 1, 2)) {
121  return false;
122  }
123  if (!writer.writeFloat64(m_newValue)) {
124  return false;
125  }
126  return true;
127 }
128 
129 bool SegmentationModule_set_minRegion_helper::read(yarp::os::ConnectionReader& connection)
130 {
131  yarp::os::idl::WireReader reader(connection);
132  if (!reader.readListReturn()) {
133  return false;
134  }
135  return true;
136 }
137 
138 class SegmentationModule_set_gradWindRad_helper :
139  public yarp::os::Portable
140 {
141 public:
142  explicit SegmentationModule_set_gradWindRad_helper(const double newValue);
143  bool write(yarp::os::ConnectionWriter& connection) const override;
144  bool read(yarp::os::ConnectionReader& connection) override;
145 
146  double m_newValue;
147 };
148 
149 SegmentationModule_set_gradWindRad_helper::SegmentationModule_set_gradWindRad_helper(const double newValue) :
150  m_newValue{newValue}
151 {
152 }
153 
154 bool SegmentationModule_set_gradWindRad_helper::write(yarp::os::ConnectionWriter& connection) const
155 {
156  yarp::os::idl::WireWriter writer(connection);
157  if (!writer.writeListHeader(3)) {
158  return false;
159  }
160  if (!writer.writeTag("set_gradWindRad", 1, 2)) {
161  return false;
162  }
163  if (!writer.writeFloat64(m_newValue)) {
164  return false;
165  }
166  return true;
167 }
168 
169 bool SegmentationModule_set_gradWindRad_helper::read(yarp::os::ConnectionReader& connection)
170 {
171  yarp::os::idl::WireReader reader(connection);
172  if (!reader.readListReturn()) {
173  return false;
174  }
175  return true;
176 }
177 
178 class SegmentationModule_set_threshold_helper :
179  public yarp::os::Portable
180 {
181 public:
182  explicit SegmentationModule_set_threshold_helper(const double newValue);
183  bool write(yarp::os::ConnectionWriter& connection) const override;
184  bool read(yarp::os::ConnectionReader& connection) override;
185 
186  double m_newValue;
187 };
188 
189 SegmentationModule_set_threshold_helper::SegmentationModule_set_threshold_helper(const double newValue) :
190  m_newValue{newValue}
191 {
192 }
193 
194 bool SegmentationModule_set_threshold_helper::write(yarp::os::ConnectionWriter& connection) const
195 {
196  yarp::os::idl::WireWriter writer(connection);
197  if (!writer.writeListHeader(3)) {
198  return false;
199  }
200  if (!writer.writeTag("set_threshold", 1, 2)) {
201  return false;
202  }
203  if (!writer.writeFloat64(m_newValue)) {
204  return false;
205  }
206  return true;
207 }
208 
209 bool SegmentationModule_set_threshold_helper::read(yarp::os::ConnectionReader& connection)
210 {
211  yarp::os::idl::WireReader reader(connection);
212  if (!reader.readListReturn()) {
213  return false;
214  }
215  return true;
216 }
217 
218 class SegmentationModule_set_mixture_helper :
219  public yarp::os::Portable
220 {
221 public:
222  explicit SegmentationModule_set_mixture_helper(const double newValue);
223  bool write(yarp::os::ConnectionWriter& connection) const override;
224  bool read(yarp::os::ConnectionReader& connection) override;
225 
226  double m_newValue;
227 };
228 
229 SegmentationModule_set_mixture_helper::SegmentationModule_set_mixture_helper(const double newValue) :
230  m_newValue{newValue}
231 {
232 }
233 
234 bool SegmentationModule_set_mixture_helper::write(yarp::os::ConnectionWriter& connection) const
235 {
236  yarp::os::idl::WireWriter writer(connection);
237  if (!writer.writeListHeader(3)) {
238  return false;
239  }
240  if (!writer.writeTag("set_mixture", 1, 2)) {
241  return false;
242  }
243  if (!writer.writeFloat64(m_newValue)) {
244  return false;
245  }
246  return true;
247 }
248 
249 bool SegmentationModule_set_mixture_helper::read(yarp::os::ConnectionReader& connection)
250 {
251  yarp::os::idl::WireReader reader(connection);
252  if (!reader.readListReturn()) {
253  return false;
254  }
255  return true;
256 }
257 
258 class SegmentationModule_set_speedup_helper :
259  public yarp::os::Portable
260 {
261 public:
262  explicit SegmentationModule_set_speedup_helper(const SpeedUpLevelComm newSpeedLevel);
263  bool write(yarp::os::ConnectionWriter& connection) const override;
264  bool read(yarp::os::ConnectionReader& connection) override;
265 
266  SpeedUpLevelComm m_newSpeedLevel;
267 };
268 
269 SegmentationModule_set_speedup_helper::SegmentationModule_set_speedup_helper(const SpeedUpLevelComm newSpeedLevel) :
270  m_newSpeedLevel{newSpeedLevel}
271 {
272 }
273 
274 bool SegmentationModule_set_speedup_helper::write(yarp::os::ConnectionWriter& connection) const
275 {
276  yarp::os::idl::WireWriter writer(connection);
277  if (!writer.writeListHeader(3)) {
278  return false;
279  }
280  if (!writer.writeTag("set_speedup", 1, 2)) {
281  return false;
282  }
283  if (!writer.writeI32(static_cast<int32_t>(m_newSpeedLevel))) {
284  return false;
285  }
286  return true;
287 }
288 
289 bool SegmentationModule_set_speedup_helper::read(yarp::os::ConnectionReader& connection)
290 {
291  yarp::os::idl::WireReader reader(connection);
292  if (!reader.readListReturn()) {
293  return false;
294  }
295  return true;
296 }
297 
298 class SegmentationModule_get_sigmaS_helper :
299  public yarp::os::Portable
300 {
301 public:
302  explicit SegmentationModule_get_sigmaS_helper();
303  bool write(yarp::os::ConnectionWriter& connection) const override;
304  bool read(yarp::os::ConnectionReader& connection) override;
305 
306  thread_local static double s_return_helper;
307 };
308 
309 thread_local double SegmentationModule_get_sigmaS_helper::s_return_helper = {};
310 
311 SegmentationModule_get_sigmaS_helper::SegmentationModule_get_sigmaS_helper()
312 {
313  s_return_helper = {};
314 }
315 
316 bool SegmentationModule_get_sigmaS_helper::write(yarp::os::ConnectionWriter& connection) const
317 {
318  yarp::os::idl::WireWriter writer(connection);
319  if (!writer.writeListHeader(2)) {
320  return false;
321  }
322  if (!writer.writeTag("get_sigmaS", 1, 2)) {
323  return false;
324  }
325  return true;
326 }
327 
328 bool SegmentationModule_get_sigmaS_helper::read(yarp::os::ConnectionReader& connection)
329 {
330  yarp::os::idl::WireReader reader(connection);
331  if (!reader.readListReturn()) {
332  return false;
333  }
334  if (!reader.readFloat64(s_return_helper)) {
335  reader.fail();
336  return false;
337  }
338  return true;
339 }
340 
341 class SegmentationModule_get_sigmaR_helper :
342  public yarp::os::Portable
343 {
344 public:
345  explicit SegmentationModule_get_sigmaR_helper();
346  bool write(yarp::os::ConnectionWriter& connection) const override;
347  bool read(yarp::os::ConnectionReader& connection) override;
348 
349  thread_local static double s_return_helper;
350 };
351 
352 thread_local double SegmentationModule_get_sigmaR_helper::s_return_helper = {};
353 
354 SegmentationModule_get_sigmaR_helper::SegmentationModule_get_sigmaR_helper()
355 {
356  s_return_helper = {};
357 }
358 
359 bool SegmentationModule_get_sigmaR_helper::write(yarp::os::ConnectionWriter& connection) const
360 {
361  yarp::os::idl::WireWriter writer(connection);
362  if (!writer.writeListHeader(2)) {
363  return false;
364  }
365  if (!writer.writeTag("get_sigmaR", 1, 2)) {
366  return false;
367  }
368  return true;
369 }
370 
371 bool SegmentationModule_get_sigmaR_helper::read(yarp::os::ConnectionReader& connection)
372 {
373  yarp::os::idl::WireReader reader(connection);
374  if (!reader.readListReturn()) {
375  return false;
376  }
377  if (!reader.readFloat64(s_return_helper)) {
378  reader.fail();
379  return false;
380  }
381  return true;
382 }
383 
384 class SegmentationModule_get_minRegion_helper :
385  public yarp::os::Portable
386 {
387 public:
388  explicit SegmentationModule_get_minRegion_helper();
389  bool write(yarp::os::ConnectionWriter& connection) const override;
390  bool read(yarp::os::ConnectionReader& connection) override;
391 
392  thread_local static double s_return_helper;
393 };
394 
395 thread_local double SegmentationModule_get_minRegion_helper::s_return_helper = {};
396 
397 SegmentationModule_get_minRegion_helper::SegmentationModule_get_minRegion_helper()
398 {
399  s_return_helper = {};
400 }
401 
402 bool SegmentationModule_get_minRegion_helper::write(yarp::os::ConnectionWriter& connection) const
403 {
404  yarp::os::idl::WireWriter writer(connection);
405  if (!writer.writeListHeader(2)) {
406  return false;
407  }
408  if (!writer.writeTag("get_minRegion", 1, 2)) {
409  return false;
410  }
411  return true;
412 }
413 
414 bool SegmentationModule_get_minRegion_helper::read(yarp::os::ConnectionReader& connection)
415 {
416  yarp::os::idl::WireReader reader(connection);
417  if (!reader.readListReturn()) {
418  return false;
419  }
420  if (!reader.readFloat64(s_return_helper)) {
421  reader.fail();
422  return false;
423  }
424  return true;
425 }
426 
427 class SegmentationModule_get_gradWindRad_helper :
428  public yarp::os::Portable
429 {
430 public:
431  explicit SegmentationModule_get_gradWindRad_helper();
432  bool write(yarp::os::ConnectionWriter& connection) const override;
433  bool read(yarp::os::ConnectionReader& connection) override;
434 
435  thread_local static double s_return_helper;
436 };
437 
438 thread_local double SegmentationModule_get_gradWindRad_helper::s_return_helper = {};
439 
440 SegmentationModule_get_gradWindRad_helper::SegmentationModule_get_gradWindRad_helper()
441 {
442  s_return_helper = {};
443 }
444 
445 bool SegmentationModule_get_gradWindRad_helper::write(yarp::os::ConnectionWriter& connection) const
446 {
447  yarp::os::idl::WireWriter writer(connection);
448  if (!writer.writeListHeader(2)) {
449  return false;
450  }
451  if (!writer.writeTag("get_gradWindRad", 1, 2)) {
452  return false;
453  }
454  return true;
455 }
456 
457 bool SegmentationModule_get_gradWindRad_helper::read(yarp::os::ConnectionReader& connection)
458 {
459  yarp::os::idl::WireReader reader(connection);
460  if (!reader.readListReturn()) {
461  return false;
462  }
463  if (!reader.readFloat64(s_return_helper)) {
464  reader.fail();
465  return false;
466  }
467  return true;
468 }
469 
470 class SegmentationModule_get_threshold_helper :
471  public yarp::os::Portable
472 {
473 public:
474  explicit SegmentationModule_get_threshold_helper();
475  bool write(yarp::os::ConnectionWriter& connection) const override;
476  bool read(yarp::os::ConnectionReader& connection) override;
477 
478  thread_local static double s_return_helper;
479 };
480 
481 thread_local double SegmentationModule_get_threshold_helper::s_return_helper = {};
482 
483 SegmentationModule_get_threshold_helper::SegmentationModule_get_threshold_helper()
484 {
485  s_return_helper = {};
486 }
487 
488 bool SegmentationModule_get_threshold_helper::write(yarp::os::ConnectionWriter& connection) const
489 {
490  yarp::os::idl::WireWriter writer(connection);
491  if (!writer.writeListHeader(2)) {
492  return false;
493  }
494  if (!writer.writeTag("get_threshold", 1, 2)) {
495  return false;
496  }
497  return true;
498 }
499 
500 bool SegmentationModule_get_threshold_helper::read(yarp::os::ConnectionReader& connection)
501 {
502  yarp::os::idl::WireReader reader(connection);
503  if (!reader.readListReturn()) {
504  return false;
505  }
506  if (!reader.readFloat64(s_return_helper)) {
507  reader.fail();
508  return false;
509  }
510  return true;
511 }
512 
513 class SegmentationModule_get_mixture_helper :
514  public yarp::os::Portable
515 {
516 public:
517  explicit SegmentationModule_get_mixture_helper();
518  bool write(yarp::os::ConnectionWriter& connection) const override;
519  bool read(yarp::os::ConnectionReader& connection) override;
520 
521  thread_local static double s_return_helper;
522 };
523 
524 thread_local double SegmentationModule_get_mixture_helper::s_return_helper = {};
525 
526 SegmentationModule_get_mixture_helper::SegmentationModule_get_mixture_helper()
527 {
528  s_return_helper = {};
529 }
530 
531 bool SegmentationModule_get_mixture_helper::write(yarp::os::ConnectionWriter& connection) const
532 {
533  yarp::os::idl::WireWriter writer(connection);
534  if (!writer.writeListHeader(2)) {
535  return false;
536  }
537  if (!writer.writeTag("get_mixture", 1, 2)) {
538  return false;
539  }
540  return true;
541 }
542 
543 bool SegmentationModule_get_mixture_helper::read(yarp::os::ConnectionReader& connection)
544 {
545  yarp::os::idl::WireReader reader(connection);
546  if (!reader.readListReturn()) {
547  return false;
548  }
549  if (!reader.readFloat64(s_return_helper)) {
550  reader.fail();
551  return false;
552  }
553  return true;
554 }
555 
556 class SegmentationModule_get_speedup_helper :
557  public yarp::os::Portable
558 {
559 public:
560  explicit SegmentationModule_get_speedup_helper();
561  bool write(yarp::os::ConnectionWriter& connection) const override;
562  bool read(yarp::os::ConnectionReader& connection) override;
563 
564  thread_local static SpeedUpLevelComm s_return_helper;
565 };
566 
567 thread_local SpeedUpLevelComm SegmentationModule_get_speedup_helper::s_return_helper = {};
568 
569 SegmentationModule_get_speedup_helper::SegmentationModule_get_speedup_helper()
570 {
571  s_return_helper = {};
572 }
573 
574 bool SegmentationModule_get_speedup_helper::write(yarp::os::ConnectionWriter& connection) const
575 {
576  yarp::os::idl::WireWriter writer(connection);
577  if (!writer.writeListHeader(2)) {
578  return false;
579  }
580  if (!writer.writeTag("get_speedup", 1, 2)) {
581  return false;
582  }
583  return true;
584 }
585 
586 bool SegmentationModule_get_speedup_helper::read(yarp::os::ConnectionReader& connection)
587 {
588  yarp::os::idl::WireReader reader(connection);
589  if (!reader.readListReturn()) {
590  return false;
591  }
592  int32_t ecast0;
593  SpeedUpLevelCommVocab cvrt1;
594  if (!reader.readEnum(ecast0, cvrt1)) {
595  reader.fail();
596  return false;
597  } else {
598  s_return_helper = static_cast<SpeedUpLevelComm>(ecast0);
599  }
600  return true;
601 }
602 
603 // Constructor
604 SegmentationModule::SegmentationModule()
605 {
606  yarp().setOwner(*this);
607 }
608 
609 void SegmentationModule::set_sigmaS(const double newValue)
610 {
611  SegmentationModule_set_sigmaS_helper helper{newValue};
612  if (!yarp().canWrite()) {
613  yError("Missing server method '%s'?", "void SegmentationModule::set_sigmaS(const double newValue)");
614  }
615  yarp().write(helper, helper);
616 }
617 
618 void SegmentationModule::set_sigmaR(const double newValue)
619 {
620  SegmentationModule_set_sigmaR_helper helper{newValue};
621  if (!yarp().canWrite()) {
622  yError("Missing server method '%s'?", "void SegmentationModule::set_sigmaR(const double newValue)");
623  }
624  yarp().write(helper, helper);
625 }
626 
627 void SegmentationModule::set_minRegion(const double newValue)
628 {
629  SegmentationModule_set_minRegion_helper helper{newValue};
630  if (!yarp().canWrite()) {
631  yError("Missing server method '%s'?", "void SegmentationModule::set_minRegion(const double newValue)");
632  }
633  yarp().write(helper, helper);
634 }
635 
636 void SegmentationModule::set_gradWindRad(const double newValue)
637 {
638  SegmentationModule_set_gradWindRad_helper helper{newValue};
639  if (!yarp().canWrite()) {
640  yError("Missing server method '%s'?", "void SegmentationModule::set_gradWindRad(const double newValue)");
641  }
642  yarp().write(helper, helper);
643 }
644 
645 void SegmentationModule::set_threshold(const double newValue)
646 {
647  SegmentationModule_set_threshold_helper helper{newValue};
648  if (!yarp().canWrite()) {
649  yError("Missing server method '%s'?", "void SegmentationModule::set_threshold(const double newValue)");
650  }
651  yarp().write(helper, helper);
652 }
653 
654 void SegmentationModule::set_mixture(const double newValue)
655 {
656  SegmentationModule_set_mixture_helper helper{newValue};
657  if (!yarp().canWrite()) {
658  yError("Missing server method '%s'?", "void SegmentationModule::set_mixture(const double newValue)");
659  }
660  yarp().write(helper, helper);
661 }
662 
663 void SegmentationModule::set_speedup(const SpeedUpLevelComm newSpeedLevel)
664 {
665  SegmentationModule_set_speedup_helper helper{newSpeedLevel};
666  if (!yarp().canWrite()) {
667  yError("Missing server method '%s'?", "void SegmentationModule::set_speedup(const SpeedUpLevelComm newSpeedLevel)");
668  }
669  yarp().write(helper, helper);
670 }
671 
672 double SegmentationModule::get_sigmaS()
673 {
674  SegmentationModule_get_sigmaS_helper helper{};
675  if (!yarp().canWrite()) {
676  yError("Missing server method '%s'?", "double SegmentationModule::get_sigmaS()");
677  }
678  bool ok = yarp().write(helper, helper);
679  return ok ? SegmentationModule_get_sigmaS_helper::s_return_helper : double{};
680 }
681 
682 double SegmentationModule::get_sigmaR()
683 {
684  SegmentationModule_get_sigmaR_helper helper{};
685  if (!yarp().canWrite()) {
686  yError("Missing server method '%s'?", "double SegmentationModule::get_sigmaR()");
687  }
688  bool ok = yarp().write(helper, helper);
689  return ok ? SegmentationModule_get_sigmaR_helper::s_return_helper : double{};
690 }
691 
692 double SegmentationModule::get_minRegion()
693 {
694  SegmentationModule_get_minRegion_helper helper{};
695  if (!yarp().canWrite()) {
696  yError("Missing server method '%s'?", "double SegmentationModule::get_minRegion()");
697  }
698  bool ok = yarp().write(helper, helper);
699  return ok ? SegmentationModule_get_minRegion_helper::s_return_helper : double{};
700 }
701 
702 double SegmentationModule::get_gradWindRad()
703 {
704  SegmentationModule_get_gradWindRad_helper helper{};
705  if (!yarp().canWrite()) {
706  yError("Missing server method '%s'?", "double SegmentationModule::get_gradWindRad()");
707  }
708  bool ok = yarp().write(helper, helper);
709  return ok ? SegmentationModule_get_gradWindRad_helper::s_return_helper : double{};
710 }
711 
712 double SegmentationModule::get_threshold()
713 {
714  SegmentationModule_get_threshold_helper helper{};
715  if (!yarp().canWrite()) {
716  yError("Missing server method '%s'?", "double SegmentationModule::get_threshold()");
717  }
718  bool ok = yarp().write(helper, helper);
719  return ok ? SegmentationModule_get_threshold_helper::s_return_helper : double{};
720 }
721 
722 double SegmentationModule::get_mixture()
723 {
724  SegmentationModule_get_mixture_helper helper{};
725  if (!yarp().canWrite()) {
726  yError("Missing server method '%s'?", "double SegmentationModule::get_mixture()");
727  }
728  bool ok = yarp().write(helper, helper);
729  return ok ? SegmentationModule_get_mixture_helper::s_return_helper : double{};
730 }
731 
732 SpeedUpLevelComm SegmentationModule::get_speedup()
733 {
734  SegmentationModule_get_speedup_helper helper{};
735  if (!yarp().canWrite()) {
736  yError("Missing server method '%s'?", "SpeedUpLevelComm SegmentationModule::get_speedup()");
737  }
738  bool ok = yarp().write(helper, helper);
739  return ok ? SegmentationModule_get_speedup_helper::s_return_helper : SpeedUpLevelComm{};
740 }
741 
742 // help method
743 std::vector<std::string> SegmentationModule::help(const std::string& functionName)
744 {
745  bool showAll = (functionName == "--all");
746  std::vector<std::string> helpString;
747  if (showAll) {
748  helpString.emplace_back("*** Available commands:");
749  helpString.emplace_back("set_sigmaS");
750  helpString.emplace_back("set_sigmaR");
751  helpString.emplace_back("set_minRegion");
752  helpString.emplace_back("set_gradWindRad");
753  helpString.emplace_back("set_threshold");
754  helpString.emplace_back("set_mixture");
755  helpString.emplace_back("set_speedup");
756  helpString.emplace_back("get_sigmaS");
757  helpString.emplace_back("get_sigmaR");
758  helpString.emplace_back("get_minRegion");
759  helpString.emplace_back("get_gradWindRad");
760  helpString.emplace_back("get_threshold");
761  helpString.emplace_back("get_mixture");
762  helpString.emplace_back("get_speedup");
763  helpString.emplace_back("help");
764  } else {
765  if (functionName == "set_sigmaS") {
766  helpString.emplace_back("void set_sigmaS(const double newValue) ");
767  }
768  if (functionName == "set_sigmaR") {
769  helpString.emplace_back("void set_sigmaR(const double newValue) ");
770  }
771  if (functionName == "set_minRegion") {
772  helpString.emplace_back("void set_minRegion(const double newValue) ");
773  }
774  if (functionName == "set_gradWindRad") {
775  helpString.emplace_back("void set_gradWindRad(const double newValue) ");
776  }
777  if (functionName == "set_threshold") {
778  helpString.emplace_back("void set_threshold(const double newValue) ");
779  }
780  if (functionName == "set_mixture") {
781  helpString.emplace_back("void set_mixture(const double newValue) ");
782  }
783  if (functionName == "set_speedup") {
784  helpString.emplace_back("void set_speedup(const SpeedUpLevelComm newSpeedLevel) ");
785  }
786  if (functionName == "get_sigmaS") {
787  helpString.emplace_back("double get_sigmaS() ");
788  }
789  if (functionName == "get_sigmaR") {
790  helpString.emplace_back("double get_sigmaR() ");
791  }
792  if (functionName == "get_minRegion") {
793  helpString.emplace_back("double get_minRegion() ");
794  }
795  if (functionName == "get_gradWindRad") {
796  helpString.emplace_back("double get_gradWindRad() ");
797  }
798  if (functionName == "get_threshold") {
799  helpString.emplace_back("double get_threshold() ");
800  }
801  if (functionName == "get_mixture") {
802  helpString.emplace_back("double get_mixture() ");
803  }
804  if (functionName == "get_speedup") {
805  helpString.emplace_back("SpeedUpLevelComm get_speedup() ");
806  }
807  if (functionName == "help") {
808  helpString.emplace_back("std::vector<std::string> help(const std::string& functionName = \"--all\")");
809  helpString.emplace_back("Return list of available commands, or help message for a specific function");
810  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");
811  helpString.emplace_back("@return list of strings (one string per line)");
812  }
813  }
814  if (helpString.empty()) {
815  helpString.emplace_back("Command not found");
816  }
817  return helpString;
818 }
819 
820 // read from ConnectionReader
821 bool SegmentationModule::read(yarp::os::ConnectionReader& connection)
822 {
823  yarp::os::idl::WireReader reader(connection);
824  reader.expectAccept();
825  if (!reader.readListHeader()) {
826  reader.fail();
827  return false;
828  }
829 
830  std::string tag = reader.readTag();
831  bool direct = (tag == "__direct__");
832  if (direct) {
833  tag = reader.readTag();
834  }
835  while (!reader.isError()) {
836  if (tag == "set_sigmaS") {
837  double newValue;
838  if (!reader.readFloat64(newValue)) {
839  reader.fail();
840  return false;
841  }
842  set_sigmaS(newValue);
843  yarp::os::idl::WireWriter writer(reader);
844  if (!writer.isNull()) {
845  if (!writer.writeListHeader(0)) {
846  return false;
847  }
848  }
849  reader.accept();
850  return true;
851  }
852  if (tag == "set_sigmaR") {
853  double newValue;
854  if (!reader.readFloat64(newValue)) {
855  reader.fail();
856  return false;
857  }
858  set_sigmaR(newValue);
859  yarp::os::idl::WireWriter writer(reader);
860  if (!writer.isNull()) {
861  if (!writer.writeListHeader(0)) {
862  return false;
863  }
864  }
865  reader.accept();
866  return true;
867  }
868  if (tag == "set_minRegion") {
869  double newValue;
870  if (!reader.readFloat64(newValue)) {
871  reader.fail();
872  return false;
873  }
874  set_minRegion(newValue);
875  yarp::os::idl::WireWriter writer(reader);
876  if (!writer.isNull()) {
877  if (!writer.writeListHeader(0)) {
878  return false;
879  }
880  }
881  reader.accept();
882  return true;
883  }
884  if (tag == "set_gradWindRad") {
885  double newValue;
886  if (!reader.readFloat64(newValue)) {
887  reader.fail();
888  return false;
889  }
890  set_gradWindRad(newValue);
891  yarp::os::idl::WireWriter writer(reader);
892  if (!writer.isNull()) {
893  if (!writer.writeListHeader(0)) {
894  return false;
895  }
896  }
897  reader.accept();
898  return true;
899  }
900  if (tag == "set_threshold") {
901  double newValue;
902  if (!reader.readFloat64(newValue)) {
903  reader.fail();
904  return false;
905  }
906  set_threshold(newValue);
907  yarp::os::idl::WireWriter writer(reader);
908  if (!writer.isNull()) {
909  if (!writer.writeListHeader(0)) {
910  return false;
911  }
912  }
913  reader.accept();
914  return true;
915  }
916  if (tag == "set_mixture") {
917  double newValue;
918  if (!reader.readFloat64(newValue)) {
919  reader.fail();
920  return false;
921  }
922  set_mixture(newValue);
923  yarp::os::idl::WireWriter writer(reader);
924  if (!writer.isNull()) {
925  if (!writer.writeListHeader(0)) {
926  return false;
927  }
928  }
929  reader.accept();
930  return true;
931  }
932  if (tag == "set_speedup") {
933  SpeedUpLevelComm newSpeedLevel;
934  int32_t ecast2;
935  SpeedUpLevelCommVocab cvrt3;
936  if (!reader.readEnum(ecast2, cvrt3)) {
937  reader.fail();
938  return false;
939  } else {
940  newSpeedLevel = static_cast<SpeedUpLevelComm>(ecast2);
941  }
942  set_speedup(newSpeedLevel);
943  yarp::os::idl::WireWriter writer(reader);
944  if (!writer.isNull()) {
945  if (!writer.writeListHeader(0)) {
946  return false;
947  }
948  }
949  reader.accept();
950  return true;
951  }
952  if (tag == "get_sigmaS") {
953  SegmentationModule_get_sigmaS_helper::s_return_helper = get_sigmaS();
954  yarp::os::idl::WireWriter writer(reader);
955  if (!writer.isNull()) {
956  if (!writer.writeListHeader(1)) {
957  return false;
958  }
959  if (!writer.writeFloat64(SegmentationModule_get_sigmaS_helper::s_return_helper)) {
960  return false;
961  }
962  }
963  reader.accept();
964  return true;
965  }
966  if (tag == "get_sigmaR") {
967  SegmentationModule_get_sigmaR_helper::s_return_helper = get_sigmaR();
968  yarp::os::idl::WireWriter writer(reader);
969  if (!writer.isNull()) {
970  if (!writer.writeListHeader(1)) {
971  return false;
972  }
973  if (!writer.writeFloat64(SegmentationModule_get_sigmaR_helper::s_return_helper)) {
974  return false;
975  }
976  }
977  reader.accept();
978  return true;
979  }
980  if (tag == "get_minRegion") {
981  SegmentationModule_get_minRegion_helper::s_return_helper = get_minRegion();
982  yarp::os::idl::WireWriter writer(reader);
983  if (!writer.isNull()) {
984  if (!writer.writeListHeader(1)) {
985  return false;
986  }
987  if (!writer.writeFloat64(SegmentationModule_get_minRegion_helper::s_return_helper)) {
988  return false;
989  }
990  }
991  reader.accept();
992  return true;
993  }
994  if (tag == "get_gradWindRad") {
995  SegmentationModule_get_gradWindRad_helper::s_return_helper = get_gradWindRad();
996  yarp::os::idl::WireWriter writer(reader);
997  if (!writer.isNull()) {
998  if (!writer.writeListHeader(1)) {
999  return false;
1000  }
1001  if (!writer.writeFloat64(SegmentationModule_get_gradWindRad_helper::s_return_helper)) {
1002  return false;
1003  }
1004  }
1005  reader.accept();
1006  return true;
1007  }
1008  if (tag == "get_threshold") {
1009  SegmentationModule_get_threshold_helper::s_return_helper = get_threshold();
1010  yarp::os::idl::WireWriter writer(reader);
1011  if (!writer.isNull()) {
1012  if (!writer.writeListHeader(1)) {
1013  return false;
1014  }
1015  if (!writer.writeFloat64(SegmentationModule_get_threshold_helper::s_return_helper)) {
1016  return false;
1017  }
1018  }
1019  reader.accept();
1020  return true;
1021  }
1022  if (tag == "get_mixture") {
1023  SegmentationModule_get_mixture_helper::s_return_helper = get_mixture();
1024  yarp::os::idl::WireWriter writer(reader);
1025  if (!writer.isNull()) {
1026  if (!writer.writeListHeader(1)) {
1027  return false;
1028  }
1029  if (!writer.writeFloat64(SegmentationModule_get_mixture_helper::s_return_helper)) {
1030  return false;
1031  }
1032  }
1033  reader.accept();
1034  return true;
1035  }
1036  if (tag == "get_speedup") {
1037  SegmentationModule_get_speedup_helper::s_return_helper = get_speedup();
1038  yarp::os::idl::WireWriter writer(reader);
1039  if (!writer.isNull()) {
1040  if (!writer.writeListHeader(1)) {
1041  return false;
1042  }
1043  if (!writer.writeI32(static_cast<int32_t>(SegmentationModule_get_speedup_helper::s_return_helper))) {
1044  return false;
1045  }
1046  }
1047  reader.accept();
1048  return true;
1049  }
1050  if (tag == "help") {
1051  std::string functionName;
1052  if (!reader.readString(functionName)) {
1053  functionName = "--all";
1054  }
1055  auto help_strings = help(functionName);
1056  yarp::os::idl::WireWriter writer(reader);
1057  if (!writer.isNull()) {
1058  if (!writer.writeListHeader(2)) {
1059  return false;
1060  }
1061  if (!writer.writeTag("many", 1, 0)) {
1062  return false;
1063  }
1064  if (!writer.writeListBegin(BOTTLE_TAG_INT32, static_cast<uint32_t>(help_strings.size()))) {
1065  return false;
1066  }
1067  for (const auto& help_string : help_strings) {
1068  if (!writer.writeString(help_string)) {
1069  return false;
1070  }
1071  }
1072  if (!writer.writeListEnd()) {
1073  return false;
1074  }
1075  }
1076  reader.accept();
1077  return true;
1078  }
1079  if (reader.noMore()) {
1080  reader.fail();
1081  return false;
1082  }
1083  std::string next_tag = reader.readTag();
1084  if (next_tag == "") {
1085  break;
1086  }
1087  tag.append("_").append(next_tag);
1088  }
1089  return false;
1090 }