Geogram Version 1.8.5
A programming library of geometric algorithms
Loading...
Searching...
No Matches
command.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2000-2022 Inria
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * * Neither the name of the ALICE Project-Team nor the names of its
14 * contributors may be used to endorse or promote products derived from this
15 * software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
28 *
29 * Contact: Bruno Levy
30 *
31 * https://www.inria.fr/fr/bruno-levy
32 *
33 * Inria,
34 * Domaine de Voluceau,
35 * 78150 Le Chesnay - Rocquencourt
36 * FRANCE
37 *
38 */
39
40#ifndef GEOGRAM_GFX_GUI_COMMAND
41#define GEOGRAM_GFX_GUI_COMMAND
42
46
53namespace GEO {
54
61 public:
66
70 ~CommandInvoker() override;
71
75 virtual void invoke() = 0;
76
84 virtual void auto_create_args() = 0;
85 };
86
92
93 /*****************************************************************/
94
100 public:
101
145 template<class FPTR> static void set_current(
146 const std::string& prototype, FPTR tfun
147 );
148
199 template<class T, class TFPTR> static void set_current(
200 const std::string& prototype, T* target, TFPTR tfun
201 );
202
213 static void flush_queue();
214
222 Command(const std::string& prototype);
223
224
229 const std::string& name() const {
230 return name_;
231 }
232
242 invoker_ = invoker;
243 if(auto_create_args_) {
244 invoker_->auto_create_args();
245 auto_create_args_ = false;
246 }
247 }
248
252 ~Command() override;
253
259 bool is_visible() const {
260 return visible_;
261 }
262
269 return &visible_;
270 }
271
277 virtual void draw();
278
287
299 virtual void apply() ;
300
306 static Command* current() {
307 return current_;
308 }
309
313 static void reset_current() {
314 current_.reset();
315 }
316
323 static void set_current(Command* command) {
324 current_ = command;
325 command->visible_ = true;
326 }
327
338 const Arg& arg = find_arg_by_index(i);
339 geo_assert(arg.type == Arg::ARG_BOOL);
340 return arg.val.bool_val;
341 }
342
353
365 unsigned int uint_arg_by_index(index_t i) const;
366
377 const Arg& arg = find_arg_by_index(i);
378 geo_assert(arg.type == Arg::ARG_FLOAT);
379 return arg.val.float_val;
380 }
381
392 double double_arg_by_index(index_t i) const {
393 return double(float_arg_by_index(i));
394 }
395
405 std::string string_arg_by_index(index_t i) const {
406 const Arg& arg = find_arg_by_index(i);
407 geo_assert(arg.type == Arg::ARG_STRING);
408 return std::string(arg.val.string_val);
409 }
410
422 template<class T> void get_arg_by_index(index_t i, T& val) {
423 geo_argused(val);
424 Logger::err("Cmd") << "Attempted to read argument #"
425 << i
426 << " to variable of unknown type"
427 << std::endl;
429 }
430
431 /***************************************************************/
432
442 template <class T> void invoke(
443 T* target, void (T::*fptr)(void)
444 ) {
445 this->assert_nb_args_matches(0);
446 if(target != nullptr && fptr != nullptr) {
447 (*target.*fptr)();
448 }
449 }
450
461 template <
462 class T,
463 class ARG0
464 > void invoke(
465 T* target,
466 void (T::*fptr)(ARG0)
467 ) {
468 this->assert_nb_args_matches(1);
469 ARG0 a0;
470 this->get_arg_by_index(0,a0);
471 if(target != nullptr && fptr != nullptr) {
472 (*target.*fptr)(a0);
473 }
474 }
475
486 template <
487 class T,
488 class ARG0, class ARG1
489 > void invoke(
490 T* target,
491 void (T::*fptr)(ARG0,ARG1)
492 ) {
493 this->assert_nb_args_matches(2);
494 ARG0 a0;
495 this->get_arg_by_index(0,a0);
496 ARG1 a1;
497 this->get_arg_by_index(1,a1);
498 if(target != nullptr && fptr != nullptr) {
499 (*target.*fptr)(a0,a1);
500 }
501 }
502
514 template <
515 class T,
516 class ARG0, class ARG1, class ARG2
517 > void invoke(
518 T* target,
519 void (T::*fptr)(ARG0,ARG1,ARG2)
520 ) {
521 this->assert_nb_args_matches(3);
522 ARG0 a0;
523 this->get_arg_by_index(0,a0);
524 ARG1 a1;
525 this->get_arg_by_index(1,a1);
526 ARG2 a2;
527 this->get_arg_by_index(2,a2);
528 if(target != nullptr && fptr != nullptr) {
529 (*target.*fptr)(a0,a1,a2);
530 }
531 }
532
544 template <
545 class T,
546 class ARG0, class ARG1, class ARG2, class ARG3
547 > void invoke(
548 T* target,
549 void (T::*fptr)(ARG0,ARG1,ARG2,ARG3)
550 ) {
551 this->assert_nb_args_matches(4);
552 ARG0 a0;
553 this->get_arg_by_index(0,a0);
554 ARG1 a1;
555 this->get_arg_by_index(1,a1);
556 ARG2 a2;
557 this->get_arg_by_index(2,a2);
558 ARG3 a3;
559 this->get_arg_by_index(3,a3);
560 if(target != nullptr && fptr != nullptr) {
561 (*target.*fptr)(a0,a1,a2,a3);
562 }
563 }
564
576 template <
577 class T,
578 class ARG0, class ARG1, class ARG2, class ARG3,
579 class ARG4
580 > void invoke(
581 T* target,
582 void (T::*fptr)(ARG0,ARG1,ARG2,ARG3,ARG4)
583 ) {
584 this->assert_nb_args_matches(5);
585 ARG0 a0;
586 this->get_arg_by_index(0,a0);
587 ARG1 a1;
588 this->get_arg_by_index(1,a1);
589 ARG2 a2;
590 this->get_arg_by_index(2,a2);
591 ARG3 a3;
592 this->get_arg_by_index(3,a3);
593 ARG4 a4;
594 this->get_arg_by_index(4,a4);
595 if(target != nullptr && fptr != nullptr) {
596 (*target.*fptr)(a0,a1,a2,a3,a4);
597 }
598 }
599
611 template <
612 class T,
613 class ARG0, class ARG1, class ARG2, class ARG3,
614 class ARG4, class ARG5
615 > void invoke(
616 T* target,
617 void (T::*fptr)(ARG0,ARG1,ARG2,ARG3,ARG4,ARG5)
618 ) {
619 this->assert_nb_args_matches(6);
620 ARG0 a0;
621 this->get_arg_by_index(0,a0);
622 ARG1 a1;
623 this->get_arg_by_index(1,a1);
624 ARG2 a2;
625 this->get_arg_by_index(2,a2);
626 ARG3 a3;
627 this->get_arg_by_index(3,a3);
628 ARG4 a4;
629 this->get_arg_by_index(4,a4);
630 ARG5 a5;
631 this->get_arg_by_index(5,a5);
632 if(target != nullptr && fptr != nullptr) {
633 (*target.*fptr)(a0,a1,a2,a3,a4,a5);
634 }
635 }
636
648 template <
649 class T,
650 class ARG0, class ARG1, class ARG2, class ARG3,
651 class ARG4, class ARG5, class ARG6
652 > void invoke(
653 T* target,
654 void (T::*fptr)(ARG0,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6)
655 ) {
656 this->assert_nb_args_matches(7);
657 ARG0 a0;
658 this->get_arg_by_index(0,a0);
659 ARG1 a1;
660 this->get_arg_by_index(1,a1);
661 ARG2 a2;
662 this->get_arg_by_index(2,a2);
663 ARG3 a3;
664 this->get_arg_by_index(3,a3);
665 ARG4 a4;
666 this->get_arg_by_index(4,a4);
667 ARG5 a5;
668 this->get_arg_by_index(5,a5);
669 ARG6 a6;
670 this->get_arg_by_index(6,a6);
671 if(target != nullptr && fptr != nullptr) {
672 (*target.*fptr)(a0,a1,a2,a3,a4,a5,a6);
673 }
674 }
675
687 template <
688 class T,
689 class ARG0, class ARG1, class ARG2, class ARG3,
690 class ARG4, class ARG5, class ARG6, class ARG7
691 > void invoke(
692 T* target,
693 void (T::*fptr)(ARG0,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7)
694 ) {
695 this->assert_nb_args_matches(8);
696 ARG0 a0;
697 this->get_arg_by_index(0,a0);
698 ARG1 a1;
699 this->get_arg_by_index(1,a1);
700 ARG2 a2;
701 this->get_arg_by_index(2,a2);
702 ARG3 a3;
703 this->get_arg_by_index(3,a3);
704 ARG4 a4;
705 this->get_arg_by_index(4,a4);
706 ARG5 a5;
707 this->get_arg_by_index(5,a5);
708 ARG6 a6;
709 this->get_arg_by_index(6,a6);
710 ARG7 a7;
711 this->get_arg_by_index(7,a7);
712 if(target != nullptr && fptr != nullptr) {
713 (*target.*fptr)(a0,a1,a2,a3,a4,a5,a6,a7);
714 }
715 }
716
717 /**************************************************************/
718
727 void invoke(
728 void (*fptr)(void)
729 ) {
730 this->assert_nb_args_matches(0);
731 if(fptr != nullptr) {
732 (*fptr)();
733 }
734 }
735
745 template <
746 class ARG0
747 > void invoke(
748 void (*fptr)(ARG0)
749 ) {
750 this->assert_nb_args_matches(1);
751 ARG0 a0;
752 this->get_arg_by_index(0,a0);
753 if(fptr != nullptr) {
754 (*fptr)(a0);
755 }
756 }
757
767 template <
768 class ARG0, class ARG1
769 > void invoke(
770 void (*fptr)(ARG0,ARG1)
771 ) {
772 this->assert_nb_args_matches(2);
773 ARG0 a0;
774 this->get_arg_by_index(0,a0);
775 ARG1 a1;
776 this->get_arg_by_index(1,a1);
777 if(fptr != nullptr) {
778 (*fptr)(a0,a1);
779 }
780 }
781
791 template <
792 class ARG0, class ARG1, class ARG2
793 > void invoke(
794 void (*fptr)(ARG0,ARG1,ARG2)
795 ) {
796 this->assert_nb_args_matches(3);
797 ARG0 a0;
798 this->get_arg_by_index(0,a0);
799 ARG1 a1;
800 this->get_arg_by_index(1,a1);
801 ARG2 a2;
802 this->get_arg_by_index(2,a2);
803 if(fptr != nullptr) {
804 (*fptr)(a0,a1,a2);
805 }
806 }
807
817 template <
818 class ARG0, class ARG1, class ARG2, class ARG3
819 > void invoke(
820 void (*fptr)(ARG0,ARG1,ARG2,ARG3)
821 ) {
822 this->assert_nb_args_matches(4);
823 ARG0 a0;
824 this->get_arg_by_index(0,a0);
825 ARG1 a1;
826 this->get_arg_by_index(1,a1);
827 ARG2 a2;
828 this->get_arg_by_index(2,a2);
829 ARG3 a3;
830 this->get_arg_by_index(3,a3);
831 if(fptr != nullptr) {
832 (*fptr)(a0,a1,a2,a3);
833 }
834 }
835
845 template <
846 class ARG0, class ARG1, class ARG2, class ARG3,
847 class ARG4
848 > void invoke(
849 void (*fptr)(ARG0,ARG1,ARG2,ARG3,ARG4)
850 ) {
851 this->assert_nb_args_matches(5);
852 ARG0 a0;
853 this->get_arg_by_index(0,a0);
854 ARG1 a1;
855 this->get_arg_by_index(1,a1);
856 ARG2 a2;
857 this->get_arg_by_index(2,a2);
858 ARG3 a3;
859 this->get_arg_by_index(3,a3);
860 ARG4 a4;
861 this->get_arg_by_index(4,a4);
862 if(fptr != nullptr) {
863 (*fptr)(a0,a1,a2,a3,a4);
864 }
865 }
866
876 template <
877 class ARG0, class ARG1, class ARG2, class ARG3,
878 class ARG4, class ARG5
879 > void invoke(
880 void (*fptr)(ARG0,ARG1,ARG2,ARG3,ARG4,ARG5)
881 ) {
882 this->assert_nb_args_matches(6);
883 ARG0 a0;
884 this->get_arg_by_index(0,a0);
885 ARG1 a1;
886 this->get_arg_by_index(1,a1);
887 ARG2 a2;
888 this->get_arg_by_index(2,a2);
889 ARG3 a3;
890 this->get_arg_by_index(3,a3);
891 ARG4 a4;
892 this->get_arg_by_index(4,a4);
893 ARG5 a5;
894 this->get_arg_by_index(5,a5);
895 if(fptr != nullptr) {
896 (*fptr)(a0,a1,a2,a3,a4,a5);
897 }
898 }
899
909 template <
910 class ARG0, class ARG1, class ARG2, class ARG3,
911 class ARG4, class ARG5, class ARG6
912 > void invoke(
913 void (*fptr)(ARG0,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6)
914 ) {
915 this->assert_nb_args_matches(7);
916 ARG0 a0;
917 this->get_arg_by_index(0,a0);
918 ARG1 a1;
919 this->get_arg_by_index(1,a1);
920 ARG2 a2;
921 this->get_arg_by_index(2,a2);
922 ARG3 a3;
923 this->get_arg_by_index(3,a3);
924 ARG4 a4;
925 this->get_arg_by_index(4,a4);
926 ARG5 a5;
927 this->get_arg_by_index(5,a5);
928 ARG6 a6;
929 this->get_arg_by_index(6,a6);
930 if(fptr != nullptr) {
931 (*fptr)(a0,a1,a2,a3,a4,a5,a6);
932 }
933 }
934
944 template <
945 class ARG0, class ARG1, class ARG2, class ARG3,
946 class ARG4, class ARG5, class ARG6, class ARG7
947 > void invoke(
948 void (*fptr)(ARG0,ARG1,ARG2,ARG3,ARG4,ARG5,ARG6,ARG7)
949 ) {
950 this->assert_nb_args_matches(8);
951 ARG0 a0;
952 this->get_arg_by_index(0,a0);
953 ARG1 a1;
954 this->get_arg_by_index(1,a1);
955 ARG2 a2;
956 this->get_arg_by_index(2,a2);
957 ARG3 a3;
958 this->get_arg_by_index(3,a3);
959 ARG4 a4;
960 this->get_arg_by_index(4,a4);
961 ARG5 a5;
962 this->get_arg_by_index(5,a5);
963 ARG6 a6;
964 this->get_arg_by_index(6,a6);
965 ARG7 a7;
966 this->get_arg_by_index(7,a7);
967 if(fptr != nullptr) {
968 (*fptr)(a0,a1,a2,a3,a4,a5,a6,a7);
969 }
970 }
971
972 /**************************************************************/
973
974 protected:
975
987 (auto_create_args_ && args_.size() == 0) ||
988 (args_.size() == nb)
989 );
990 }
991
992
1002 template<class T> void add_arg(
1003 const std::string& name, const T& default_val,
1004 const std::string& help = ""
1005 ) {
1006 args_.push_back(Arg(name, default_val, help));
1007 }
1008
1017 template<class T> void create_arg(
1018 index_t i, const T& default_val
1019 ) {
1020 if(i >= args_.size()) {
1021 args_.resize(i+1);
1022 }
1023 args_[i] = Arg("arg " + String::to_string(i), default_val);
1024 }
1025
1026 static void set_queued(Command* command) {
1027 queued_ = command;
1028 }
1029
1030 private:
1031
1036 struct GEOGRAM_GFX_API ArgVal {
1040 void clear();
1041
1045 ArgVal() {
1046 clear();
1047 }
1048
1054 ArgVal(const ArgVal& rhs);
1055
1062 ArgVal& operator=(const ArgVal& rhs);
1063
1064 bool bool_val;
1065 int int_val;
1066 float float_val;
1067 char string_val[64];
1068 };
1069
1075 struct GEOGRAM_GFX_API Arg {
1076
1080 Arg();
1081
1089 Arg(
1090 const std::string& name_in, bool x,
1091 const std::string& help_in=""
1092 );
1093
1101 Arg(
1102 const std::string& name_in, int x,
1103 const std::string& help_in=""
1104 );
1105
1114 Arg(
1115 const std::string& name_in, unsigned int x,
1116 const std::string& help_in=""
1117 );
1118
1126 Arg(
1127 const std::string& name_in, float x,
1128 const std::string& help_in=""
1129 );
1130
1139 Arg(
1140 const std::string& name_in, double x,
1141 const std::string& help_in=""
1142 );
1143
1152 Arg(
1153 const std::string& name_in, const std::string& x,
1154 const std::string& help_in=""
1155 );
1156
1160 void draw();
1161
1162 enum { ARG_BOOL, ARG_INT, ARG_UINT, ARG_FLOAT, ARG_STRING } type;
1163 std::string name;
1164 std::string help;
1165 ArgVal val;
1166 ArgVal default_val;
1167 };
1168
1176 const Arg& find_arg(const std::string& name) const {
1177 for(index_t i=0; i<args_.size(); ++i) {
1178 if(args_[i].name == name) {
1179 return args_[i];
1180 }
1181 }
1183 }
1184
1190 const Arg& find_arg_by_index(index_t i) const {
1191 geo_assert(i < args_.size());
1192 return args_[i];
1193 }
1194
1195 private:
1196 std::string name_;
1197 std::string help_;
1198 vector<Arg> args_;
1199 CommandInvoker_var invoker_;
1200 bool visible_;
1205 bool auto_create_args_;
1206 static SmartPointer<Command> current_;
1207 static SmartPointer<Command> queued_;
1208 };
1209
1210/***********************************************************************/
1211
1215 template<> inline void Command::get_arg_by_index(
1216 index_t i, bool& val
1217 ) {
1218 if(auto_create_args_) {
1219 val = false;
1220 this->create_arg(i, val);
1221 } else {
1222 val = this->bool_arg_by_index(i);
1223 }
1224 }
1225
1229 template<> inline void Command::get_arg_by_index(
1230 index_t i, int& val
1231 ) {
1232 if(auto_create_args_) {
1233 val = 0;
1234 this->create_arg(i, val);
1235 } else {
1236 val = this->int_arg_by_index(i);
1237 }
1238 }
1239
1243 template<> inline void Command::get_arg_by_index(
1244 index_t i, unsigned int& val
1245 ) {
1246 if(auto_create_args_) {
1247 val = 0;
1248 this->create_arg(i, val);
1249 } else {
1250 val = this->uint_arg_by_index(i);
1251 }
1252 }
1253
1257 template<> inline void Command::get_arg_by_index(
1258 index_t i, float& val
1259 ) {
1260 if(auto_create_args_) {
1261 val = 0.0f;
1262 this->create_arg(i, val);
1263 } else {
1264 val = this->float_arg_by_index(i);
1265 }
1266 }
1267
1271 template<> inline void Command::get_arg_by_index(
1272 index_t i, double& val
1273 ) {
1274 if(auto_create_args_) {
1275 val = 0.0;
1276 this->create_arg(i, val);
1277 } else {
1278 val = this->double_arg_by_index(i);
1279 }
1280 }
1281
1285 template<> inline void Command::get_arg_by_index(
1286 index_t i, std::string& val
1287 ) {
1288 if(auto_create_args_) {
1289 val = "";
1290 this->create_arg(i, val);
1291 } else {
1292 val = this->string_arg_by_index(i);
1293 }
1294 }
1295
1296 /*****************************************************************/
1297
1303 template <class FPTR>
1305 public:
1306
1313 Command* command,
1314 FPTR fun
1315 ) :
1316 command_(command),
1317 fun_(fun) {
1318 }
1319
1323 void invoke() override {
1324 command_->invoke(fun_);
1325 }
1326
1330 void auto_create_args() override {
1331 command_->invoke(FPTR(nullptr));
1332 }
1333
1334 private:
1335 Command* command_;
1336 FPTR fun_;
1337 };
1338
1339 /*****************************************************************/
1340
1348 template <class T, class TFPTR>
1350 public:
1351
1360 Command* command,
1361 T* target,
1362 TFPTR target_fun
1363 ) :
1364 command_(command),
1365 target_(target),
1366 target_fun_(target_fun) {
1367 }
1368
1373 void invoke() override {
1374 command_->invoke(target_, target_fun_);
1375 }
1376
1381 void auto_create_args() override {
1382 command_->invoke((T*)(nullptr), (TFPTR)(nullptr));
1383 }
1384
1385
1386 private:
1387 Command* command_;
1388 T* target_;
1389 TFPTR target_fun_;
1390 };
1391
1392 /*****************************************************************/
1393
1394 template<class FPTR> inline void Command::set_current(
1395 const std::string& prototype,
1396 FPTR fun
1397 ) {
1398 set_current(new Command(prototype));
1401 );
1402 }
1403
1404 /*****************************************************************/
1405
1406 template<class T, class TFPTR> inline void Command::set_current(
1407 const std::string& prototype,
1408 T* target,
1409 TFPTR tfun
1410 ) {
1411 set_current(new Command(prototype));
1414 );
1415 }
1416
1417 /*****************************************************************/
1418
1419}
1420
1421#endif
#define geo_assert_not_reached
Sets a non reachable point in the program.
Definition assert.h:177
#define geo_assert(x)
Verifies that a condition is met.
Definition assert.h:149
Abstract class for calling functions or calling member functions.
Definition command.h:60
CommandInvoker()
CommandInvoker constructor.
virtual void auto_create_args()=0
Creates the arguments in the target command.
~CommandInvoker() override
CommandInvoker destructor.
virtual void invoke()=0
Invokes the target function.
Manages the GUI of a command with ImGUI.
Definition command.h:99
static void flush_queue()
Flushes the potentially queued command invokation.
void invoke(T *target, void(T::*fptr)(ARG0, ARG1, ARG2))
Invokes a member function with the stored arguments.
Definition command.h:517
~Command() override
Command destructor.
void get_arg_by_index(index_t i, T &val)
Gets the value of an argument by index.
Definition command.h:422
bool is_visible() const
Tests whether this Command is visible.
Definition command.h:259
int int_arg_by_index(index_t i) const
Gets the value of an integer argument by index.
void assert_nb_args_matches(index_t nb)
Tests whether the number of declared arguments matches a specified number.
Definition command.h:985
void invoke(T *target, void(T::*fptr)(ARG0, ARG1))
Invokes a member function with the stored arguments.
Definition command.h:489
virtual void reset_factory_settings()
Restores default parameter values for all parameters.
void invoke(T *target, void(T::*fptr)(ARG0, ARG1, ARG2, ARG3, ARG4))
Invokes a member function with the stored arguments.
Definition command.h:580
void invoke(void(*fptr)(ARG0, ARG1, ARG2, ARG3, ARG4))
Invokes a function with the stored arguments.
Definition command.h:848
const std::string & name() const
Gets the name of this command.
Definition command.h:229
void invoke(T *target, void(T::*fptr)(ARG0, ARG1, ARG2, ARG3, ARG4, ARG5))
Invokes a member function with the stored arguments.
Definition command.h:615
virtual void draw()
Displays and manages the GUI of this Command.
void invoke(void(*fptr)(void))
Invokes a function with the stored arguments.
Definition command.h:727
float float_arg_by_index(index_t i) const
Gets the value of a floating-point argument by index.
Definition command.h:376
void invoke(void(*fptr)(ARG0))
Invokes a function with the stored arguments.
Definition command.h:747
static void set_current(Command *command)
Sets the current command.
Definition command.h:323
void set_invoker(CommandInvoker *invoker)
Sets the invoker.
Definition command.h:241
void invoke(void(*fptr)(ARG0, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6))
Invokes a function with the stored arguments.
Definition command.h:912
void invoke(T *target, void(T::*fptr)(ARG0))
Invokes a member function with the stored arguments.
Definition command.h:464
void invoke(void(*fptr)(ARG0, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7))
Invokes a function with the stored arguments.
Definition command.h:947
virtual void apply()
Gets the value of the parameters and does the task.
void add_arg(const std::string &name, const T &default_val, const std::string &help="")
Adds a parameter to this command.
Definition command.h:1002
void invoke(void(*fptr)(ARG0, ARG1, ARG2, ARG3, ARG4, ARG5))
Invokes a function with the stored arguments.
Definition command.h:879
void invoke(T *target, void(T::*fptr)(void))
Invokes a member function with the stored arguments.
Definition command.h:442
bool bool_arg_by_index(index_t i) const
Gets the value of a boolean argument by index.
Definition command.h:337
static void reset_current()
Resets the current command.
Definition command.h:313
void invoke(T *target, void(T::*fptr)(ARG0, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7))
Invokes a member function with the stored arguments.
Definition command.h:691
std::string string_arg_by_index(index_t i) const
Gets the value of a string argument by index.
Definition command.h:405
void invoke(void(*fptr)(ARG0, ARG1))
Invokes a function with the stored arguments.
Definition command.h:769
void create_arg(index_t i, const T &default_val)
Creates an argument at a given index.
Definition command.h:1017
bool * is_visible_ptr()
Gets a pointer to the visibility flag of this command.
Definition command.h:268
Command(const std::string &prototype)
Command constructor.
static void set_current(const std::string &prototype, FPTR tfun)
Binds the current command to a function.
Definition command.h:1394
void invoke(void(*fptr)(ARG0, ARG1, ARG2))
Invokes a function with the stored arguments.
Definition command.h:793
void invoke(T *target, void(T::*fptr)(ARG0, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6))
Invokes a member function with the stored arguments.
Definition command.h:652
static Command * current()
Gets the current command.
Definition command.h:306
double double_arg_by_index(index_t i) const
Gets the value of a floating-point argument by index and converts it to a double.
Definition command.h:392
void invoke(void(*fptr)(ARG0, ARG1, ARG2, ARG3))
Invokes a function with the stored arguments.
Definition command.h:819
unsigned int uint_arg_by_index(index_t i) const
Gets the value of an unsigned integer argument by index.
void invoke(T *target, void(T::*fptr)(ARG0, ARG1, ARG2, ARG3))
Invokes a member function with the stored arguments.
Definition command.h:547
Base class for reference-counted objects.
Definition counted.h:71
An implementation of CommandInvoker that calls a function.
Definition command.h:1304
FunctionCommandInvoker(Command *command, FPTR fun)
FunctionCommandInvoker constructor.
Definition command.h:1312
void invoke() override
Invokes the target function.
Definition command.h:1323
void auto_create_args() override
Creates the arguments in the target command.
Definition command.h:1330
An implementation of CommandInvoker that calls a member function of an object.
Definition command.h:1349
void auto_create_args() override
Creates the arguments in the target command.
Definition command.h:1381
MemberFunctionCommandInvoker(Command *command, T *target, TFPTR target_fun)
MemberFunctionCommandInvoker constructor.
Definition command.h:1359
void invoke() override
Invokes the target function.
Definition command.h:1373
A smart pointer with reference-counted copy semantics.
#define GEOGRAM_GFX_API
Linkage declaration for geogram symbols.
Definition defs.h:55
Common include file, providing basic definitions. Should be included before anything else by all head...
Generic logging mechanism.
Global Vorpaline namespace.
Definition algorithm.h:64
SmartPointer< CommandInvoker > CommandInvoker_var
Automatic reference-counted pointer to a CommandInvoker.
Definition command.h:91
void geo_argused(const T &)
Suppresses compiler warnings about unused parameters.
Definition argused.h:60
geo_index_t index_t
The type for storing and manipulating indices.
Definition numeric.h:287
Functions for string manipulation.