cxWidgets 1.0
cxFunction.h
Go to the documentation of this file.
1// Copyright (c) 2026 E. Oulashin
2#ifndef __CXFUNCTION_H__
3#define __CXFUNCTION_H__
4
5/*
6 * cxFunction.h - function
7 *
8 * Copyright (C) 2005-2007 Michael H. Kinney
9 *
10 *
11 */
12
13#include <string>
14#include <memory>
15
16namespace cx {
17
18// Typedefs for various function pointer types
19typedef std::string (*funcPtr0)();
20typedef std::string (*funcPtr2)(void *p1, void *p2);
21typedef std::string (*funcPtr4)(void *p1, void *p2, void *p3, void *p4);
22
30{
31 public:
42 cxFunction(bool pUseReturnVal, bool pExitAfterRun, bool pRunOnLeaveFunction);
43
44 virtual ~cxFunction();
45
50 virtual bool functionIsSet() const = 0;
51
59 virtual std::string runFunction() const = 0;
60
61 virtual void* getFuncPtr() const = 0;
62
70 virtual bool getUseReturnVal() const;
71
78 virtual void setUseReturnVal(bool pUseReturnVal);
79
86 virtual bool getExitAfterRun() const;
87
95 virtual void setExitAfterRun(bool pExitAfterRun);
96
104 virtual bool getRunOnLeaveFunction() const;
105
114 virtual void setRunOnLeaveFunction(bool pRunOnLeaveFunction);
115
122 virtual std::string cxTypeStr() const = 0;
123
124 private:
125 bool mUseReturnVal;
126 bool mExitAfterRun;
127 bool mRunOnLeaveFunction;
128}; // end of class cxFunction
129
138{
139 public:
154 explicit cxFunction0(funcPtr0 pFuncPtr = nullptr, bool pUseReturnVal = false,
155 bool pExitAfterRun = false,
156 bool pRunOnLeaveFunction = true);
157
161 virtual ~cxFunction0();
162
167 virtual bool functionIsSet() const override;
168
173 void setFunction(funcPtr0 pFuncPtr);
174
180 funcPtr0 getFunction() const;
181
188 virtual std::string runFunction() const override;
189
190 virtual void* getFuncPtr() const override;
191
199 virtual std::string cxTypeStr() const override;
200
201 private:
202 funcPtr0 mFunction; // This is the actual function pointer
203}; // end of class cxFunction2
204
230{
231 public:
250 explicit cxFunction2(funcPtr2 pFuncPtr = nullptr, void *pParam1 = nullptr,
251 void *pParam2 = nullptr, bool pUseReturnVal = false,
252 bool pExitAfterRun = false,
253 bool pRunOnLeaveFunction = true);
254
258 virtual ~cxFunction2();
259
264 virtual bool functionIsSet() const override;
265
270 void setFunction(funcPtr2 pFuncPtr);
271
277 funcPtr2 getFunction() const;
278
284 void setParams(void *pParam1, void *pParam2);
285
290 void setParam1(void *pParam);
291
296 void setParam2(void *pParam);
297
302 void* getParam1() const;
303
308 void* getParam2() const;
309
316 virtual std::string runFunction() const override;
317
318 virtual void* getFuncPtr() const override;
319
327 virtual std::string cxTypeStr() const override;
328
329 private:
330 funcPtr2 mFunction; // The actual function pointer
331 void *mParam1; // The first parameter to pass to the function
332 void *mParam2; // The second parameter to pass to the function
333}; // end of class cxFunction2
334
341{
342 public:
365 explicit cxFunction4(funcPtr4 pFuncPtr = nullptr, void *pParam1 = nullptr,
366 void *pParam2 = nullptr, void *pParam3 = nullptr,
367 void *pParam4 = nullptr, bool pUseReturnVal = false,
368 bool pExitAfterRun = false,
369 bool pRunOnLeaveFunction = true);
370
374 virtual ~cxFunction4();
375
380 virtual bool functionIsSet() const override;
381
386 void setFunction(funcPtr4 pFuncPtr);
387
393 funcPtr4 getFunction() const;
394
402 void setParams(void *pParam1, void *pParam2, void *pParam3, void *pParam4);
403
408 void setParam1(void *pParam);
409
414 void setParam2(void *pParam);
415
420 void setParam3(void *pParam);
421
426 void setParam4(void *pParam);
427
432 void* getParam1() const;
433
438 void* getParam2() const;
439
444 void* getParam3() const;
445
450 void* getParam4() const;
451
458 virtual std::string runFunction() const override;
459
460 virtual void* getFuncPtr() const override;
461
469 virtual std::string cxTypeStr() const override;
470
471 private:
472 funcPtr4 mFunction; // The actual function pointer
473 void *mParam1; // The first parameter to pass to the function
474 void *mParam2; // The second parameter to pass to the function
475 void *mParam3; // The 3rd parameter to pass to the function
476 void *mParam4; // The 4th parameter to pass to the function
477};
478
483template<typename T1, typename T2>
485{
486 public:
487 using FuncPtr = std::string (*)(T1 *, T2 *);
488
492 static std::shared_ptr<cxFunction2Templated<T1, T2>> create(FuncPtr pFuncPtr, T1 *pParam1, T2 *pParam2,
493 bool pUseReturnVal = false, bool pExitAfterRun = false,
494 bool pRunOnLeaveFunction = true)
495 {
496 return std::make_shared<cxFunction2Templated<T1, T2>>(pFuncPtr, pParam1, pParam2,
497 pUseReturnVal, pExitAfterRun, pRunOnLeaveFunction);
498 }
499
518 explicit cxFunction2Templated(FuncPtr pFuncPtr = nullptr, T1 *pParam1 = nullptr,
519 T2 *pParam2 = nullptr, bool pUseReturnVal = false,
520 bool pExitAfterRun = false,
521 bool pRunOnLeaveFunction = true)
522 : cxFunction(pUseReturnVal, pExitAfterRun, pRunOnLeaveFunction),
523 mFunction(pFuncPtr),
524 mParam1(pParam1),
525 mParam2(pParam2)
526 {
527 }
528
533
538 virtual bool functionIsSet() const override
539 {
540 return (mFunction != nullptr);
541 }
542
547 void setFunction(FuncPtr pFuncPtr)
548 {
549 mFunction = pFuncPtr;
550 }
551
558 {
559 return mFunction;
560 }
561
567 void setParams(T1 *pParam1, T2 *pParam2)
568 {
569 mParam1 = pParam1;
570 mParam2 = pParam2;
571 }
572
577 void setParam1(T1 *pParam)
578 {
579 mParam1 = pParam;
580 }
581
586 void setParam2(T2 *pParam)
587 {
588 mParam2 = pParam;
589 }
590
595 T1* getParam1() const
596 {
597 return mParam1;
598 }
599
604 T2* getParam2() const
605 {
606 return mParam2;
607 }
608
615 virtual std::string runFunction() const override
616 {
617 if (mFunction != nullptr)
618 {
619 return(mFunction(mParam1, mParam2));
620 }
621 else
622 {
623 return("");
624 }
625 }
626
627 virtual void* getFuncPtr() const override
628 {
629 return (void*)mFunction;
630 }
631
639 virtual std::string cxTypeStr() const override
640 {
641 return("cxFunction2Templated");
642 }
643
644 private:
645 FuncPtr mFunction; // The actual function pointer
646 T1 *mParam1; // The first parameter to pass to the function
647 T2 *mParam2; // The second parameter to pass to the function
648};
649
654template<typename T1>
656{
657 public:
658 using FuncPtr = std::string (*)(T1&);
659
660 static std::shared_ptr<cxFunction1RefTemplated<T1>> create(FuncPtr pFuncPtr, T1& pParam1,
661 bool pUseReturnVal = false, bool pExitAfterRun = false,
662 bool pRunOnLeaveFunction = true)
663 {
664 return std::make_shared<cxFunction1RefTemplated<T1>>(pFuncPtr, pParam1,
665 pUseReturnVal, pExitAfterRun, pRunOnLeaveFunction);
666 }
667
684 explicit cxFunction1RefTemplated(FuncPtr pFuncPtr, T1& pParam,
685 bool pUseReturnVal = false,
686 bool pExitAfterRun = false,
687 bool pRunOnLeaveFunction = true)
688 : cxFunction(pUseReturnVal, pExitAfterRun, pRunOnLeaveFunction),
689 mFunction(pFuncPtr),
690 mParam(pParam)
691 {
692 }
693
698
703 virtual bool functionIsSet() const override
704 {
705 return (mFunction != nullptr);
706 }
707
712 void setFunction(FuncPtr pFuncPtr)
713 {
714 mFunction = pFuncPtr;
715 }
716
723 {
724 return mFunction;
725 }
726
731 void setParam(T1& pParam)
732 {
733 mParam = pParam;
734 }
735
740 const T1& getParam() const
741 {
742 return mParam;
743 }
744
751 virtual std::string runFunction() const override
752 {
753 if (mFunction != nullptr)
754 {
755 return(mFunction(mParam));
756 }
757 else
758 {
759 return("");
760 }
761 }
762
763 virtual void* getFuncPtr() const override
764 {
765 return (void*)mFunction;
766 }
767
775 virtual std::string cxTypeStr() const override
776 {
777 return("cxFunction1RefTemplated");
778 }
779
780 private:
781 FuncPtr mFunction; // The actual function pointer
782 T1& mParam; // The parameter to pass to the function
783};
784
785
790template<typename T1, typename T2>
792{
793 public:
794 using FuncPtr = std::string (*)(T1&, T2&);
795
799 static std::shared_ptr<cxFunction2RefTemplated<T1, T2>> create(FuncPtr pFuncPtr, T1& pParam1, T2& pParam2,
800 bool pUseReturnVal = false, bool pExitAfterRun = false,
801 bool pRunOnLeaveFunction = true)
802 {
803 return std::make_shared<cxFunction2RefTemplated<T1, T2>>(pFuncPtr, pParam1, pParam2,
804 pUseReturnVal, pExitAfterRun, pRunOnLeaveFunction);
805 }
806
825 explicit cxFunction2RefTemplated(FuncPtr pFuncPtr, T1& pParam1,
826 T2 &pParam2, bool pUseReturnVal = false,
827 bool pExitAfterRun = false,
828 bool pRunOnLeaveFunction = true)
829 : cxFunction(pUseReturnVal, pExitAfterRun, pRunOnLeaveFunction),
830 mFunction(pFuncPtr),
831 mParam1(pParam1),
832 mParam2(pParam2)
833 {
834 }
835
840
845 virtual bool functionIsSet() const override
846 {
847 return (mFunction != nullptr);
848 }
849
854 void setFunction(FuncPtr pFuncPtr)
855 {
856 mFunction = pFuncPtr;
857 }
858
865 {
866 return mFunction;
867 }
868
874 void setParams(T1& pParam1, T2& pParam2)
875 {
876 mParam1 = pParam1;
877 mParam2 = pParam2;
878 }
879
884 void setParam1(T1& pParam)
885 {
886 mParam1 = pParam;
887 }
888
893 void setParam2(T2 &pParam)
894 {
895 mParam2 = pParam;
896 }
897
902 const T1& getParam1() const
903 {
904 return mParam1;
905 }
906
911 const T2& getParam2() const
912 {
913 return mParam2;
914 }
915
922 virtual std::string runFunction() const override
923 {
924 if (mFunction != nullptr)
925 {
926 return(mFunction(mParam1, mParam2));
927 }
928 else
929 {
930 return("");
931 }
932 }
933
934 virtual void* getFuncPtr() const override
935 {
936 return (void*)mFunction;
937 }
938
946 virtual std::string cxTypeStr() const override
947 {
948 return("cxFunction2RefTemplated");
949 }
950
951 private:
952 FuncPtr mFunction; // The actual function pointer
953 T1& mParam1; // The first parameter to pass to the function
954 T2& mParam2; // The second parameter to pass to the function
955};
956
961template<typename T1, typename T2, typename T3>
963{
964 public:
965 using FuncPtr = std::string (*)(T1&, T2&, T3&);
966
970 static std::shared_ptr<cxFunction3RefTemplated<T1, T2, T3>> create(FuncPtr pFuncPtr, T1& pParam1, T2& pParam2, T3& pParam3,
971 bool pUseReturnVal = false, bool pExitAfterRun = false,
972 bool pRunOnLeaveFunction = true)
973 {
974 return std::make_shared<cxFunction3RefTemplated<T1, T2, T3>>(pFuncPtr, pParam1, pParam2, pParam3,
975 pUseReturnVal, pExitAfterRun, pRunOnLeaveFunction);
976 }
977
998 explicit cxFunction3RefTemplated(FuncPtr pFuncPtr, T1& pParam1,
999 T2& pParam2, T3& pParam3,
1000 bool pUseReturnVal = false,
1001 bool pExitAfterRun = false,
1002 bool pRunOnLeaveFunction = true)
1003 : cxFunction(pUseReturnVal, pExitAfterRun, pRunOnLeaveFunction),
1004 mFunction(pFuncPtr),
1005 mParam1(pParam1),
1006 mParam2(pParam2),
1007 mParam3(pParam3)
1008 {
1009 }
1010
1015
1020 virtual bool functionIsSet() const override
1021 {
1022 return (mFunction != nullptr);
1023 }
1024
1029 void setFunction(FuncPtr pFuncPtr)
1030 {
1031 mFunction = pFuncPtr;
1032 }
1033
1040 {
1041 return mFunction;
1042 }
1043
1050 void setParams(T1& pParam1, T2& pParam2, T3& pParam3)
1051 {
1052 mParam1 = pParam1;
1053 mParam2 = pParam2;
1054 mParam3 = pParam3;
1055 }
1056
1061 void setParam1(T1& pParam)
1062 {
1063 mParam1 = pParam;
1064 }
1065
1070 void setParam2(T2& pParam)
1071 {
1072 mParam2 = pParam;
1073 }
1074
1079 void setParam2(T3& pParam)
1080 {
1081 mParam3 = pParam;
1082 }
1083
1088 const T1& getParam1() const
1089 {
1090 return mParam1;
1091 }
1092
1097 const T2& getParam2() const
1098 {
1099 return mParam2;
1100 }
1101
1106 const T3& getParam3() const
1107 {
1108 return mParam3;
1109 }
1110
1117 virtual std::string runFunction() const override
1118 {
1119 if (mFunction != nullptr)
1120 {
1121 return(mFunction(mParam1, mParam2));
1122 }
1123 else
1124 {
1125 return("");
1126 }
1127 }
1128
1129 virtual void* getFuncPtr() const override
1130 {
1131 return (void*)mFunction;
1132 }
1133
1141 virtual std::string cxTypeStr() const override
1142 {
1143 return("cxFunction3RefTemplated");
1144 }
1145
1146 private:
1147 FuncPtr mFunction; // The actual function pointer
1148 T1& mParam1; // The first parameter to pass to the function
1149 T2& mParam2; // The second parameter to pass to the function
1150 T3& mParam3; // The third parameter to pass to the function
1151};
1152
1157template<typename T1, typename T2, typename T3, typename T4>
1159{
1160 public:
1161 using FuncPtr = std::string (*)(T1 *, T2 *, T3 *, T4 *);
1162
1166 static std::shared_ptr<cxFunction4Templated<T1, T2, T3, T4>> create(FuncPtr pFuncPtr, T1 *pParam1, T2 *pParam2,
1167 T3 *pParam3, T4 *pParam4, bool pUseReturnVal = false,
1168 bool pExitAfterRun = false, bool pRunOnLeaveFunction = true)
1169 {
1170 return std::make_shared<cxFunction4Templated<T1, T2, T3, T4>>(pFuncPtr, pParam1, pParam2,
1171 pParam3, pParam4, pUseReturnVal, pExitAfterRun,
1172 pRunOnLeaveFunction);
1173 }
1174
1197 explicit cxFunction4Templated(FuncPtr pFuncPtr = nullptr, T1 *pParam1 = nullptr,
1198 T2 *pParam2 = nullptr, T3 *pParam3 = nullptr,
1199 T4 *pParam4 = nullptr, bool pUseReturnVal = false,
1200 bool pExitAfterRun = false,
1201 bool pRunOnLeaveFunction = true)
1202 : cxFunction(pUseReturnVal, pExitAfterRun, pRunOnLeaveFunction),
1203 mFunction(pFuncPtr),
1204 mParam1(pParam1),
1205 mParam2(pParam2),
1206 mParam3(pParam3),
1207 mParam4(pParam4)
1208 {
1209 }
1210
1215
1220 virtual bool functionIsSet() const override
1221 {
1222 return (mFunction != nullptr);
1223 }
1224
1229 void setFunction(FuncPtr pFuncPtr)
1230 {
1231 mFunction = pFuncPtr;
1232 }
1233
1240 {
1241 return mFunction;
1242 }
1243
1251 void setParams(T1 *pParam1, T2 *pParam2, T3 *pParam3, T4 *pParam4)
1252 {
1253 mParam1 = pParam1;
1254 mParam2 = pParam2;
1255 mParam3 = pParam3;
1256 mParam4 = pParam4;
1257 }
1258
1263 void setParam1(T1 *pParam)
1264 {
1265 mParam1 = pParam;
1266 }
1267
1272 void setParam2(T2 *pParam)
1273 {
1274 mParam2 = pParam;
1275 }
1276
1281 void setParam3(T3 *pParam)
1282 {
1283 mParam3 = pParam;
1284 }
1285
1290 void setParam4(T4 *pParam)
1291 {
1292 mParam4 = pParam;
1293 }
1294
1299 T1* getParam1() const
1300 {
1301 return mParam1;
1302 }
1303
1308 T2* getParam2() const
1309 {
1310 return mParam2;
1311 }
1312
1317 T3* getParam3() const
1318 {
1319 return mParam3;
1320 }
1321
1326 T4* getParam4() const
1327 {
1328 return mParam4;
1329 }
1330
1337 virtual std::string runFunction() const override
1338 {
1339 if (mFunction != nullptr)
1340 {
1341 return(mFunction(mParam1, mParam2, mParam3, mParam4));
1342 }
1343 else
1344 {
1345 return("");
1346 }
1347 }
1348
1349 virtual void* getFuncPtr() const override
1350 {
1351 return (void*)mFunction;
1352 }
1353
1361 virtual std::string cxTypeStr() const override
1362 {
1363 return("cxFunction4Templated");
1364 }
1365
1366 private:
1367 FuncPtr mFunction; // The actual function pointer
1368 T1 *mParam1; // The first parameter to pass to the function
1369 T2 *mParam2; // The second parameter to pass to the function
1370 T3 *mParam3; // The 3rd parameter to pass to the function
1371 T4 *mParam4; // The 4th parameter to pass to the function
1372};
1373
1378template<typename T1, typename T2, typename T3, typename T4>
1380{
1381 public:
1382 using FuncPtr = std::string (*)(T1&, T2&, T3&, T4&);
1383
1387 static std::shared_ptr<cxFunction4RefTemplated<T1, T2, T3, T4>> create(FuncPtr pFuncPtr, T1& pParam1, T2& pParam2,
1388 T3& pParam3, T4& pParam4, bool pUseReturnVal = false,
1389 bool pExitAfterRun = false, bool pRunOnLeaveFunction = true)
1390 {
1391 return std::make_shared<cxFunction4RefTemplated<T1, T2, T3, T4>>(pFuncPtr, pParam1, pParam2,
1392 pParam3, pParam4, pUseReturnVal, pExitAfterRun,
1393 pRunOnLeaveFunction);
1394 }
1395
1418 explicit cxFunction4RefTemplated(FuncPtr pFuncPtr, T1& pParam1,
1419 T2& pParam2, T3& pParam3, T4& pParam4,
1420 bool pUseReturnVal = false,
1421 bool pExitAfterRun = false,
1422 bool pRunOnLeaveFunction = true)
1423 : cxFunction(pUseReturnVal, pExitAfterRun, pRunOnLeaveFunction),
1424 mFunction(pFuncPtr),
1425 mParam1(pParam1),
1426 mParam2(pParam2),
1427 mParam3(pParam3),
1428 mParam4(pParam4)
1429 {
1430 }
1431
1436
1441 virtual bool functionIsSet() const override
1442 {
1443 return (mFunction != nullptr);
1444 }
1445
1450 void setFunction(FuncPtr pFuncPtr)
1451 {
1452 mFunction = pFuncPtr;
1453 }
1454
1461 {
1462 return mFunction;
1463 }
1464
1472 void setParams(T1& pParam1, T2& pParam2, T3& pParam3, T4& pParam4)
1473 {
1474 mParam1 = pParam1;
1475 mParam2 = pParam2;
1476 mParam3 = pParam3;
1477 mParam4 = pParam4;
1478 }
1479
1484 void setParam1(T1& pParam)
1485 {
1486 mParam1 = pParam;
1487 }
1488
1493 void setParam2(T2& pParam)
1494 {
1495 mParam2 = pParam;
1496 }
1497
1502 void setParam3(T3& pParam)
1503 {
1504 mParam3 = pParam;
1505 }
1506
1511 void setParam4(T4& pParam)
1512 {
1513 mParam4 = pParam;
1514 }
1515
1520 const T1& getParam1() const
1521 {
1522 return mParam1;
1523 }
1524
1529 const T2& getParam2() const
1530 {
1531 return mParam2;
1532 }
1533
1538 const T3& getParam3() const
1539 {
1540 return mParam3;
1541 }
1542
1547 const T4& getParam4() const
1548 {
1549 return mParam4;
1550 }
1551
1558 virtual std::string runFunction() const override
1559 {
1560 if (mFunction != nullptr)
1561 {
1562 return(mFunction(mParam1, mParam2, mParam3, mParam4));
1563 }
1564 else
1565 {
1566 return("");
1567 }
1568 }
1569
1570 virtual void* getFuncPtr() const override
1571 {
1572 return (void*)mFunction;
1573 }
1574
1582 virtual std::string cxTypeStr() const override
1583 {
1584 return("cxFunction4RefTemplated");
1585 }
1586
1587 private:
1588 FuncPtr mFunction; // The actual function pointer
1589 T1& mParam1; // The first parameter to pass to the function
1590 T2& mParam2; // The second parameter to pass to the function
1591 T3& mParam3; // The third parameter to pass to the function
1592 T4& mParam4; // The fourth parameter to pass to the function
1593};
1594
1595} // namespace cx
1596
1597#endif
A more intelligent function pointer, which can run a.
Definition cxFunction.h:138
virtual ~cxFunction0()
Definition cxFunction.cpp:62
virtual std::string runFunction() const override
Definition cxFunction.cpp:82
void setFunction(funcPtr0 pFuncPtr)
Definition cxFunction.cpp:71
virtual bool functionIsSet() const override
Definition cxFunction.cpp:66
virtual void * getFuncPtr() const override
Definition cxFunction.cpp:94
virtual std::string cxTypeStr() const override
Returns the name of the cxWidgets class, "cxFunction0". This can be.
Definition cxFunction.cpp:99
funcPtr0 getFunction() const
Accessor for the internal function pointer.
Definition cxFunction.cpp:76
This class is a cxFunction that is templated to take a reference of a specific type.
Definition cxFunction.h:656
cxFunction1RefTemplated(FuncPtr pFuncPtr, T1 &pParam, bool pUseReturnVal=false, bool pExitAfterRun=false, bool pRunOnLeaveFunction=true)
Default constructor. All parameters have default values.
Definition cxFunction.h:684
const T1 & getParam() const
Definition cxFunction.h:740
virtual bool functionIsSet() const override
Definition cxFunction.h:703
FuncPtr getFunction() const
Accessor for the internal function pointer.
Definition cxFunction.h:722
virtual std::string cxTypeStr() const override
Returns the name of the cxWidgets class, "cxFunction1RefTemplated". This can be.
Definition cxFunction.h:775
std::string(*)(T1 &) FuncPtr
Definition cxFunction.h:658
virtual ~cxFunction1RefTemplated()
Definition cxFunction.h:697
virtual void * getFuncPtr() const override
Definition cxFunction.h:763
static std::shared_ptr< cxFunction1RefTemplated< T1 > > create(FuncPtr pFuncPtr, T1 &pParam1, bool pUseReturnVal=false, bool pExitAfterRun=false, bool pRunOnLeaveFunction=true)
Definition cxFunction.h:660
void setParam(T1 &pParam)
Definition cxFunction.h:731
virtual std::string runFunction() const override
Definition cxFunction.h:751
void setFunction(FuncPtr pFuncPtr)
Definition cxFunction.h:712
This class is a cxFunction that is templated to take 2 references of specific types.
Definition cxFunction.h:792
const T2 & getParam2() const
Definition cxFunction.h:911
virtual bool functionIsSet() const override
Definition cxFunction.h:845
static std::shared_ptr< cxFunction2RefTemplated< T1, T2 > > create(FuncPtr pFuncPtr, T1 &pParam1, T2 &pParam2, bool pUseReturnVal=false, bool pExitAfterRun=false, bool pRunOnLeaveFunction=true)
Static create method for cxFunction2RefTemplated. This is the recommended way to create a cxFunction2...
Definition cxFunction.h:799
void setParams(T1 &pParam1, T2 &pParam2)
Definition cxFunction.h:874
virtual std::string cxTypeStr() const override
Returns the name of the cxWidgets class, "cxFunction2RefTemplated". This can be.
Definition cxFunction.h:946
FuncPtr getFunction() const
Accessor for the internal function pointer.
Definition cxFunction.h:864
virtual ~cxFunction2RefTemplated()
Definition cxFunction.h:839
void setParam2(T2 &pParam)
Definition cxFunction.h:893
void setParam1(T1 &pParam)
Definition cxFunction.h:884
virtual std::string runFunction() const override
Definition cxFunction.h:922
void setFunction(FuncPtr pFuncPtr)
Definition cxFunction.h:854
std::string(*)(T1 &, T2 &) FuncPtr
Definition cxFunction.h:794
const T1 & getParam1() const
Definition cxFunction.h:902
cxFunction2RefTemplated(FuncPtr pFuncPtr, T1 &pParam1, T2 &pParam2, bool pUseReturnVal=false, bool pExitAfterRun=false, bool pRunOnLeaveFunction=true)
Default constructor. All parameters have default values.
Definition cxFunction.h:825
virtual void * getFuncPtr() const override
Definition cxFunction.h:934
This class is a cxFunction that is templated to take 2 pointers of specific types.
Definition cxFunction.h:485
void setParam1(T1 *pParam)
Definition cxFunction.h:577
void setFunction(FuncPtr pFuncPtr)
Definition cxFunction.h:547
virtual void * getFuncPtr() const override
Definition cxFunction.h:627
virtual std::string runFunction() const override
Definition cxFunction.h:615
FuncPtr getFunction() const
Accessor for the internal function pointer.
Definition cxFunction.h:557
void setParam2(T2 *pParam)
Definition cxFunction.h:586
std::string(*)(T1 *, T2 *) FuncPtr
Definition cxFunction.h:487
cxFunction2Templated(FuncPtr pFuncPtr=nullptr, T1 *pParam1=nullptr, T2 *pParam2=nullptr, bool pUseReturnVal=false, bool pExitAfterRun=false, bool pRunOnLeaveFunction=true)
Default constructor. All parameters have default values.
Definition cxFunction.h:518
T2 * getParam2() const
Definition cxFunction.h:604
virtual ~cxFunction2Templated()
Definition cxFunction.h:532
static std::shared_ptr< cxFunction2Templated< T1, T2 > > create(FuncPtr pFuncPtr, T1 *pParam1, T2 *pParam2, bool pUseReturnVal=false, bool pExitAfterRun=false, bool pRunOnLeaveFunction=true)
Static create method for cxFunction2Templated. This is the recommended way to create a cxFunction2Tem...
Definition cxFunction.h:492
T1 * getParam1() const
Definition cxFunction.h:595
void setParams(T1 *pParam1, T2 *pParam2)
Definition cxFunction.h:567
virtual bool functionIsSet() const override
Definition cxFunction.h:538
virtual std::string cxTypeStr() const override
Returns the name of the cxWidgets class, "cxFunction2Templated". This can be.
Definition cxFunction.h:639
A more intelligent function pointer, which can run a function with.
Definition cxFunction.h:230
void * getParam1() const
Definition cxFunction.cpp:153
void setFunction(funcPtr2 pFuncPtr)
Definition cxFunction.cpp:125
funcPtr2 getFunction() const
Accessor for the internal function pointer.
Definition cxFunction.cpp:130
virtual bool functionIsSet() const override
Definition cxFunction.cpp:120
virtual std::string cxTypeStr() const override
Returns the name of the cxWidgets class, "cxFunction2". This can be.
Definition cxFunction.cpp:182
void setParams(void *pParam1, void *pParam2)
Definition cxFunction.cpp:136
void setParam2(void *pParam)
Definition cxFunction.cpp:147
void setParam1(void *pParam)
Definition cxFunction.cpp:142
void * getParam2() const
Definition cxFunction.cpp:159
virtual std::string runFunction() const override
Definition cxFunction.cpp:165
virtual void * getFuncPtr() const override
Definition cxFunction.cpp:177
virtual ~cxFunction2()
Definition cxFunction.cpp:116
This class is a cxFunction that is templated to take 2 references of specific types.
Definition cxFunction.h:963
void setParam2(T2 &pParam)
Definition cxFunction.h:1070
void setParam2(T3 &pParam)
Definition cxFunction.h:1079
static std::shared_ptr< cxFunction3RefTemplated< T1, T2, T3 > > create(FuncPtr pFuncPtr, T1 &pParam1, T2 &pParam2, T3 &pParam3, bool pUseReturnVal=false, bool pExitAfterRun=false, bool pRunOnLeaveFunction=true)
Static create method for cxFunction3RefTemplated. This is the recommended way to create a cxFunction3...
Definition cxFunction.h:970
virtual bool functionIsSet() const override
Definition cxFunction.h:1020
const T1 & getParam1() const
Definition cxFunction.h:1088
virtual std::string cxTypeStr() const override
Returns the name of the cxWidgets class, "cxFunction3RefTemplated". This can be.
Definition cxFunction.h:1141
virtual ~cxFunction3RefTemplated()
Definition cxFunction.h:1014
const T3 & getParam3() const
Definition cxFunction.h:1106
std::string(*)(T1 &, T2 &, T3 &) FuncPtr
Definition cxFunction.h:965
virtual void * getFuncPtr() const override
Definition cxFunction.h:1129
FuncPtr getFunction() const
Accessor for the internal function pointer.
Definition cxFunction.h:1039
void setParam1(T1 &pParam)
Definition cxFunction.h:1061
cxFunction3RefTemplated(FuncPtr pFuncPtr, T1 &pParam1, T2 &pParam2, T3 &pParam3, bool pUseReturnVal=false, bool pExitAfterRun=false, bool pRunOnLeaveFunction=true)
Default constructor. All parameters have default values.
Definition cxFunction.h:998
void setFunction(FuncPtr pFuncPtr)
Definition cxFunction.h:1029
void setParams(T1 &pParam1, T2 &pParam2, T3 &pParam3)
Definition cxFunction.h:1050
virtual std::string runFunction() const override
Definition cxFunction.h:1117
const T2 & getParam2() const
Definition cxFunction.h:1097
This class is a cxFunction that is templated to take 4 references of specific types.
Definition cxFunction.h:1380
static std::shared_ptr< cxFunction4RefTemplated< T1, T2, T3, T4 > > create(FuncPtr pFuncPtr, T1 &pParam1, T2 &pParam2, T3 &pParam3, T4 &pParam4, bool pUseReturnVal=false, bool pExitAfterRun=false, bool pRunOnLeaveFunction=true)
Static create method for cxFunction4RefTemplated. This is the recommended way to create a cxFunction4...
Definition cxFunction.h:1387
virtual std::string cxTypeStr() const override
Returns the name of the cxWidgets class, "cxFunction4RefTemplated". This can be.
Definition cxFunction.h:1582
const T3 & getParam3() const
Definition cxFunction.h:1538
const T2 & getParam2() const
Definition cxFunction.h:1529
void setParam4(T4 &pParam)
Definition cxFunction.h:1511
void setParam1(T1 &pParam)
Definition cxFunction.h:1484
virtual void * getFuncPtr() const override
Definition cxFunction.h:1570
void setParam3(T3 &pParam)
Definition cxFunction.h:1502
virtual ~cxFunction4RefTemplated()
Definition cxFunction.h:1435
virtual bool functionIsSet() const override
Definition cxFunction.h:1441
std::string(*)(T1 &, T2 &, T3 &, T4 &) FuncPtr
Definition cxFunction.h:1382
virtual std::string runFunction() const override
Definition cxFunction.h:1558
void setFunction(FuncPtr pFuncPtr)
Definition cxFunction.h:1450
FuncPtr getFunction() const
Accessor for the internal function pointer.
Definition cxFunction.h:1460
const T4 & getParam4() const
Definition cxFunction.h:1547
void setParams(T1 &pParam1, T2 &pParam2, T3 &pParam3, T4 &pParam4)
Definition cxFunction.h:1472
const T1 & getParam1() const
Definition cxFunction.h:1520
cxFunction4RefTemplated(FuncPtr pFuncPtr, T1 &pParam1, T2 &pParam2, T3 &pParam3, T4 &pParam4, bool pUseReturnVal=false, bool pExitAfterRun=false, bool pRunOnLeaveFunction=true)
Default constructor. All parameters have default values.
Definition cxFunction.h:1418
void setParam2(T2 &pParam)
Definition cxFunction.h:1493
This class is a cxFunction that is templated to take 4 pointers of specific types.
Definition cxFunction.h:1159
T4 * getParam4() const
Definition cxFunction.h:1326
virtual std::string runFunction() const override
Definition cxFunction.h:1337
void setFunction(FuncPtr pFuncPtr)
Definition cxFunction.h:1229
virtual bool functionIsSet() const override
Definition cxFunction.h:1220
FuncPtr getFunction() const
Accessor for the internal function pointer.
Definition cxFunction.h:1239
static std::shared_ptr< cxFunction4Templated< T1, T2, T3, T4 > > create(FuncPtr pFuncPtr, T1 *pParam1, T2 *pParam2, T3 *pParam3, T4 *pParam4, bool pUseReturnVal=false, bool pExitAfterRun=false, bool pRunOnLeaveFunction=true)
Static create method for cxFunction4Templated. This is the recommended way to create a cxFunction4Tem...
Definition cxFunction.h:1166
T2 * getParam2() const
Definition cxFunction.h:1308
void setParam3(T3 *pParam)
Definition cxFunction.h:1281
std::string(*)(T1 *, T2 *, T3 *, T4 *) FuncPtr
Definition cxFunction.h:1161
void setParams(T1 *pParam1, T2 *pParam2, T3 *pParam3, T4 *pParam4)
Definition cxFunction.h:1251
cxFunction4Templated(FuncPtr pFuncPtr=nullptr, T1 *pParam1=nullptr, T2 *pParam2=nullptr, T3 *pParam3=nullptr, T4 *pParam4=nullptr, bool pUseReturnVal=false, bool pExitAfterRun=false, bool pRunOnLeaveFunction=true)
Default constructor. All parameters have default values.
Definition cxFunction.h:1197
void setParam2(T2 *pParam)
Definition cxFunction.h:1272
virtual void * getFuncPtr() const override
Definition cxFunction.h:1349
void setParam4(T4 *pParam)
Definition cxFunction.h:1290
virtual ~cxFunction4Templated()
Definition cxFunction.h:1214
virtual std::string cxTypeStr() const override
Returns the name of the cxWidgets class, "cxFunction4Templated". This can be.
Definition cxFunction.h:1361
T1 * getParam1() const
Definition cxFunction.h:1299
T3 * getParam3() const
Definition cxFunction.h:1317
void setParam1(T1 *pParam)
Definition cxFunction.h:1263
This class is just like cxFunction2, but for functions.
Definition cxFunction.h:341
void * getParam1() const
Definition cxFunction.cpp:250
void setParam3(void *pParam)
Definition cxFunction.cpp:239
void setParam2(void *pParam)
Definition cxFunction.cpp:234
funcPtr4 getFunction() const
Accessor for the internal function pointer.
Definition cxFunction.cpp:215
void * getParam2() const
Definition cxFunction.cpp:256
virtual ~cxFunction4()
Definition cxFunction.cpp:201
void * getParam3() const
Definition cxFunction.cpp:262
void setParam1(void *pParam)
Definition cxFunction.cpp:229
void * getParam4() const
Definition cxFunction.cpp:268
virtual std::string runFunction() const override
Definition cxFunction.cpp:274
virtual bool functionIsSet() const override
Definition cxFunction.cpp:205
void setFunction(funcPtr4 pFuncPtr)
Definition cxFunction.cpp:210
void setParams(void *pParam1, void *pParam2, void *pParam3, void *pParam4)
Definition cxFunction.cpp:221
void setParam4(void *pParam)
Definition cxFunction.cpp:244
virtual std::string cxTypeStr() const override
Returns the name of the cxWidgets class, "cxFunction4". This can be.
Definition cxFunction.cpp:291
virtual void * getFuncPtr() const override
Definition cxFunction.cpp:286
Base class for cxFunction2 and cxFunction4. This class is pure.
Definition cxFunction.h:30
virtual void setUseReturnVal(bool pUseReturnVal)
Setter for whether or not the caller should make use of the return value.
Definition cxFunction.cpp:28
virtual bool getRunOnLeaveFunction() const
Accessor for whether the caller should run its onLeave function.
Definition cxFunction.cpp:43
virtual void setExitAfterRun(bool pExitAfterRun)
Setter for whether or not the caller should quit what.
Definition cxFunction.cpp:38
virtual void * getFuncPtr() const =0
virtual std::string runFunction() const =0
Runs the function pointed to by the cxFunction. This is a.
virtual bool functionIsSet() const =0
virtual bool getUseReturnVal() const
Accessor for whether the caller should use the return value.
Definition cxFunction.cpp:23
virtual ~cxFunction()
Definition cxFunction.cpp:19
virtual bool getExitAfterRun() const
Accessor for whether the caller should exit after the function.
Definition cxFunction.cpp:33
virtual void setRunOnLeaveFunction(bool pRunOnLeaveFunction)
Setter for whether or not the caller should run its.
Definition cxFunction.cpp:48
virtual std::string cxTypeStr() const =0
Returns the name of the class (either "cxFunction2".
cxBorderChars.h - Defines border characters to be used in drawing a box (i.e., in cxWindow and all it...
Definition cxApp.cpp:5
std::string(* funcPtr4)(void *p1, void *p2, void *p3, void *p4)
Definition cxFunction.h:21
std::string(* funcPtr0)()
Definition cxFunction.h:19
std::string(* funcPtr2)(void *p1, void *p2)
Definition cxFunction.h:20