INOS
cinostaskextmpl.h
Go to the documentation of this file.
1//******************************************************************************
26//******************************************************************************
27
28#ifndef INC_CINOSTASKEXTMPL_H
29#define INC_CINOSTASKEXTMPL_H
30
31//
32//------------------------------------------------------------------------------
33// includes
34//------------------------------------------------------------------------------
35//
36// system
37//
38#include <inos.h>
39#include <cinoseventlogger.h>
40#include <cinostaskexdef.h>
41
42
46template<typename T>
48{
49public:
59 TINOSTaskExValDef (const char* Name,
60 T Value,
61 T Min,
62 T Max,
63 const char* Unit = "",
65 uint32 Flags = 0)
66 :
67 m_pName(Name),
68 m_Value(Value),
69 m_Min(Min),
70 m_Max(Max),
71 m_pUnit(Unit),
72 m_uCharacteristics(Characteristics),
73 m_uFlags(Flags),
74 m_pComboData(nullptr) {};
75
87 TINOSTaskExValDef (const char* Name,
88 const char* ComboData,
89 T Value,
90 T Min,
91 T Max,
92 const char* Unit = "",
94 uint32 Flags = 0)
95 :
96 m_pName(Name),
97 m_Value(Value),
98 m_Min(Min),
99 m_Max(Max),
100 m_pUnit(Unit),
101 m_uCharacteristics(Characteristics),
102 m_uFlags(Flags),
103 m_pComboData(ComboData) {};
104
111 CINOSTaskExMsgDefaultParam* pParam = aMsg.AddDefaultParam(m_pName, m_Value);
112 pParam->SetMaxValue((real64)m_Max);
113 pParam->SetMinValue((real64)m_Min);
114 pParam->SetUnit(m_pUnit);
115 pParam->SetCharacteristics(m_uCharacteristics);
116 pParam->SetFlag(m_uFlags);
117 pParam->SetComboData(m_pComboData);
118 return pParam;
119 };
120
121private:
122 const char* m_pName;
123 T m_Value;
124 T m_Min;
125 T m_Max;
126 const char* m_pUnit;
127 uint32 m_uCharacteristics;
128 uint32 m_uFlags;
129 const char* m_pComboData;
130
131};
132
136template<typename T>
138{
139public:
145 T* Value,
146 uint32 Flags = 0)
147 :
148 m_pName(Name),
149 m_Value(Value),
150 m_uFlags(Flags){};
151
165 CINOSTaskExMsgDefaultParam* pParam = aMsg.AddDefaultParam(m_pName, m_Value);
166 pParam->SetFlag(m_uFlags);
167 return pParam;
168 };
169
170private:
171 const char* m_pName;
172 T* m_Value;
173 uint32 m_uFlags;
174};
175
176
180template<>
182{
183public:
191 const char* Default,
192 const char* ComboData = nullptr,
193 uint32 Flags = 0) :
194 m_pName(Name),
195 m_Value(Default),
196 m_pComboData(ComboData),
197 m_uFlags(Flags) {};
198
204 CINOSTaskExMsgDefaultParam* pParam = aMsg.AddDefaultParam(m_pName, m_Value);
205 pParam->SetComboData(m_pComboData);
206 pParam->SetFlag(m_uFlags);
207 return pParam;
208 }
209
210private:
211 const char* m_pName;
212 const char* m_Value;
213 const char* m_pComboData;
214 uint32 m_uFlags;
215};
216
220template<>
222{
223public:
231 bool Value,
233 uint32 Flags = 0) :
234 m_pName(Name),
235 m_Value(Value),
236 m_uCharacteristics(Characteristics),
237 m_uFlags(Flags) {};
238
244 CINOSTaskExMsgDefaultParam* pParam = aMsg.AddDefaultParam(m_pName, m_Value);
245 pParam->SetCharacteristics(m_uCharacteristics);
246 pParam->SetFlag(m_uFlags);
247 return pParam;
248 }
249
250private:
251 const char* m_pName;
252 bool m_Value;
253 uint32 m_uCharacteristics;
254 uint32 m_uFlags;
255};
256
257
258//------------------------------------------------------------------------------
263public:
269
278
280 const char* GetName() const {
281 return m_cName;
282 }
283
286 { return (strcmp(m_cName,aHook.GetName())<0);}
288 { return (strcmp(m_cName, aHook.GetName())==0);}
289 int operator < (const char* aName)
290 { return (strcmp(m_cName, aName)<0);}
291 int operator == (const char* aName)
292 { return (strcmp(m_cName, aName)==0);}
293
299
305
308
309protected:
311 // see TINOSTaskExCmdHook for further information
313 strncpy(m_cName, apName, sizeof(m_cName));
314 aTask.RegisterHook(this);
315 }
316private:
318 inosName64 m_cName;
319};
320
321
322
323//------------------------------------------------------------------------------
324template <typename ObjectType>
326public:
332
341
376 const char* apName,
380 ) :
382 m_PreDispatchFunction(apPreDispatchFunction),
383 m_MsgDoneFunction(apMsgDoneFunction)
384 {};
385
386
392 if(dynamic_cast<ObjectType*>(::ActualTask()) != nullptr) {
393 return tPreDispatchFunctionBase(m_PreDispatchFunction);
394 }
395 return nullptr;
396 };
397
403 if(dynamic_cast<ObjectType*>(::ActualTask()) != nullptr) {
404 return tOnMsgDoneFunctionBase(m_MsgDoneFunction);
405 }
406 return nullptr;
407 };
408
411
412private:
416 tPreDispatchFunction m_PreDispatchFunction;
417
421 tOnMsgDoneFunction m_MsgDoneFunction;
422};
423
424
425
426
427//------------------------------------------------------------------------------
428// class CINOSTaskExCmdBase
429//------------------------------------------------------------------------------
430
435{
436 // friends
437 friend class CINOSTaskEx;
438
439public:
440
446
452 if(ActualTask() == m_pTask) {
453 m_pPreDispatchFunction = apPreDispatchHook->GetPreDispatchFunction();
454 }
455 };
456
457
466
467
473 if(ActualTask() == m_pTask) {
474 m_pMsgDoneFunction = apOnMsgDoneHook->GetOnMsgDoneFunction();
475 }
476 }
477
478
484 virtual uint32 AddCommand(bool abDeleteOnRemove = false)
485 {
486 if(m_pTask== nullptr) {
488 }
489 auto pCmdMsg = new CINOSTaskExMsg(this->m_CommandMsg);
490 pCmdMsg->SetFlags(this->m_CommandMsg.GetFlags());
493
494 // Crate a new message from prototype message and add the command with the needed parameters
496 return 0;
497 };
498
508 uint64 aChar, // characteristics of object
509 uint16 aKeyLevel, // keylevel of object
510 bool abRegisterInco=true,
511 bool abDeleteOnRemove = false)
512 {
513
514 if(m_pTask== nullptr) {
516 }
517 auto pCmdMsg = new CINOSTaskExMsg(this->m_CommandMsg);
518
521
524 return 0;
525 };
526
531 auto pMsg = new CINOSTaskExMsg(CINOSTaskExDef::eMsgCall, (uintptr) this, apSync);
532 pMsg->AddFlags(this->m_CommandMsg.GetFlags());
533 return pMsg;
534 }
535
540 const char* GetOption() const {
541 return m_pOption;
542 }
543
547 const char* GetName() {
548 return m_CommandMsg.GetName(false);
549 }
550
554 void SetName(const char* apName) {
556 }
557
562 return m_CommandMsg;
563 }
564
565 void SetTask(CINOSTaskEx* apTask) {
566 m_pTask = apTask;
567 }
568
581 void AddParam(const char* apName, real64 arValue, real64 arMin,
582 real64 arMax, const char* apUnit = "", uint32 auChar = 0, uint32 auFlags = 0)
583 {
584
586 pParam->SetMinValue(arMin);
587 pParam->SetMaxValue(arMax);
588 pParam->SetUnit(apUnit);
589 pParam->SetCharacteristics(auChar);
590 pParam->SetFlag(auFlags);
591 // end AddParam
592 }
602 void AddParam(const char* apName, const char* apValue,
603 const char* apComboData=nullptr, uint32 auFlags = 0) {
605 pParam->SetFlag(auFlags);
606 if(apComboData) {
607 pParam->SetComboData(apComboData);
608 }
609 }
610
611
620 void AddParam(const char* apName, bool abValue, uint32 auFlags = 0) {
622 pParam->SetFlag(auFlags);
623 }
624
625 // TODO !OI! Add the other add param variants as in the CINOSTaskEx, arguments should be
626 // exactly the same to allow easy migration
627
628
636
639 { return (strcmp(m_CommandMsg.GetName(), aTaskExMsg.m_CommandMsg.GetName())<0);}
641 { return (strcmp(m_CommandMsg.GetName(), aTaskExMsg.m_CommandMsg.GetName())==0);}
642 int operator < (const char* aName)
643 { return (strcmp(m_CommandMsg.GetName(), aName)<0);}
644 int operator == (const char* aName)
645 { return (strcmp(m_CommandMsg.GetName(), aName)==0);}
646
649 if(m_pOption != nullptr) {
650 delete [] m_pOption;
651 }
652 }
653
655 // is removed, the object will be alive until all calls of commands are completed.
656 // It is used by the corresponding message objects in their constructor.
657 void Claim() {
658 // If reference count is 0 this is a "static" object or member object.
659 if(m_uReferenceCount != 0) {
661 }
662 }
663
665 // is deleted, in case the command was removed during a call of this command.
666 // It is used by the corresponding message objects in their destructor.
667 void Release(CINOSTaskExMsg* apMsg = nullptr) {
668 // is the msg the registered message?
669 if(apMsg == this->m_pRegisterMsg) {
670 // null the registered message to avoid using dangling pointer
671 this->m_pRegisterMsg = nullptr;
672 }
673
674 // If reference count is 0 this is a "static" object or member object.
675 if(m_uReferenceCount != 0) {
677
678 // Was the caller the last reference of this object?
679 if(uCount == 1) {
680 // Yes, delete it
682 }
683 }
684 }
685
686
687
688
689protected:
693 virtual void Dispatch(CINOSTaskExMsg* apMsg) = 0;
694
698 virtual void DispatchTmd(CINOSTaskExMsg* apMsg) = 0;
699
707 // Check if the command has a valid task
708 if(m_pTask == nullptr) {
710 return false;
711 }
712 if(this->m_uAllowedStates & (1 << m_pTask->CINOSTaskEx::GetState())) {
713 if(m_pPreDispatchFunction != nullptr) {
714 return (m_pTask->*m_pPreDispatchFunction)(apMsg);
715 }
716 return true;
717 }
718 return false;
719 }
720
727 void OnMsgDone(CINOSTaskExMsg* apMsg, CINOSTaskExDef::ERplId aRplId, tMcAppError aAppError) {
728 if(m_pMsgDoneFunction && m_pTask != nullptr) {
730 }
731 };
732
733
735 // see CINOSTaskExCmd or CINOSTaskExCmdMsg for further information
737 const char* apOption, uint64 auCharacteristics, uint16 auKeyLevel,
738 bool abRegisterInco) :
746 {
747 if(apName != nullptr) {
749 }
750 if(apOption != nullptr) {
751 const size_t uBufLen = strlen(apOption) + 1;
752 char* pOption = new char[uBufLen];
755 }
756 };
757
759 bool CheckParams(size_t count, ...) {
760 auto pParam = m_CommandMsg.GetFirstParamPtr(false);
763 for (size_t ix = 0; ix < count; ix++) {
764 if(pParam == nullptr || pParam->GetType() != va_arg(args, int32)) {
765 INOS_ERROR("CINOSTaskExCmdBase::CheckParams type mismatch");
766 return false;
767 }
768 pParam = pParam->GetNext();
769 }
770 va_end(args);
771
772 return pParam == nullptr;
773 }
774
776 // other task than the task of this command.
777 virtual void DeleteCommand() {
778 // Actual task os 'own' task?
779 if(::ActualTask() == m_pTask) {
780 // yes -> just delete this
781 delete this;
782 }
783 else {
784 // no -> dispatch and let the task delete this object.
785 auto pMsg = new CINOSTaskExMsg(CINOSTaskExDef::eMsgInternal,
786 CINOSTaskEx::eIntDeleteCommand, DF_INOS_ASYNCHRONOUS);
787 pMsg->AddParam<CINOSTaskExCmdBase*>(this);
789 }
790 };
791
794
797
800
802 // if AddCommand is called with no arguments.
804
807
809 // if AddCommand is called with no arguments.
810 uint16 m_uKeyLevel = cKeyLevelMin; // keylevel of object
812 // if AddCommand is called with no arguments.
813 bool m_bRegisterInco = true;
814
817
820
824 // at startup.
825 const char* m_pOption = nullptr;
826
828 // object was not dynamically created and must not be deleted.
829 std::atomic_ulong m_uReferenceCount;
830};
831
832//------------------------------------------------------------------------------
833// class TINOSTaskExCmdDyn
834//------------------------------------------------------------------------------
835
840template<class ObjectType>
842{
843public:
849
856 template<typename... ParamType>
858 if(m_pTask == nullptr) {
860 }
861 if(m_pObject == nullptr) {
863 }
864
865 // Check the params
866 if(!this->CheckParams(sizeof...(Params), (int32)TINCOType<ParamType>::eType...)) {
868 return r;
869 }
870
872 CINOSTaskExMsgParam* dummy[sizeof...(Params)] = { AddParam(pMsg, Params)... };
873 (void)dummy; // Suppress compiler warning
874
875 // Check for errors set in AddParam (e.g. JSON parse errors).
876 uint32 uRet = pMsg->GetRetValue();
877 if(uRet != 0) {
878 delete pMsg;
879 CMcResult r(uRet);
880 return r;
881 }
882
883 return this->m_pTask->PutMsg(pMsg);
884 }
885
TINOSTaskExCmdDyn(const char* apName,
912 uint32 auStateBitmap = 0xFFFFFFFF,
913 const char* apOption = "",
914 uint64 auCharacteristics = 0,
915 uint16 auKeyLevel = cKeyLevelMin,
916 bool abRegisterInco = true) :
920 m_pFunction(apFunction),
921 m_pFunctionTmd(apFunctionTmd){}
922
923
924
927
928
929protected:
933 virtual void Dispatch(CINOSTaskExMsg* apMsg) override{
934
935 // Check if object is set
936 if(this->m_pObject == nullptr) {
937 // Don't use internal task pointer as this could be the wrong one or not set
939 return;
940 }
941
942 // Check if function is set
943 if(m_pFunction == nullptr) {
944 // Don't use internal task pointer as this could be the wrong one or not set
946 return;
947 }
948
949 // Call the function
950 (this->m_pObject->*m_pFunction)(apMsg);
951 }
952
956 virtual void DispatchTmd(CINOSTaskExMsg* apMsg) override {
957 if(m_pFunctionTmd) {
958 (this->m_pObject->*m_pFunctionTmd)(apMsg);
959 }
960 }
961
964
965 private:
967 // message of this command is dispatched.
968 tCommandFunction m_pFunction = nullptr;
970 // this command msg is put into the queue even if the msg has a trigger.
971 tCommandFunction m_pFunctionTmd = nullptr;
972
973};
974
975//------------------------------------------------------------------------------
976// template class TINOSTaskExCmdBase
977//------------------------------------------------------------------------------
978
984template<class ObjectType, typename... ParamType>
986{
987public:
995 // Check if command ready to be called
996 if(m_pTask == nullptr) {
998 }
999 if(m_pObject == nullptr) {
1001 }
1002
1003 // now create the message
1005 CINOSTaskExMsgParam* dummy[sizeof...(Params)] = { AddParam(pMsg, Params)... };
1006 (void)dummy; // Suppress compiler warning
1007
1008 // Check for errors set in AddParam (e.g. JSON parse errors).
1009 uint32 uRet = pMsg->GetRetValue();
1010 if(uRet != 0) {
1011 delete pMsg;
1012 CMcResult r(uRet);
1013 return r;
1014 }
1015
1016 return this->m_pTask->PutMsg(pMsg);
1017 }
1018
1019
1024 virtual uint32 AddCommand(bool abDeleteOnRemove = false) override
1025 {
1028 }
1030 };
1031
1040 uint64 aChar, // characteristics of object
1041 uint16 aKeyLevel, // keylevel of object
1042 bool abRegisterInco=true,
1043 bool abDeleteOnRemove = false) override
1044 {
1047 }
1049 };
1050
1051 virtual void SetDefaults(ParamType... Default) {
1052 this->m_CommandMsg.FstParam();
1053 uint32 dummy[sizeof...(Default)] = {
1054 ( this->m_CommandMsg.GetParamPtr()->SetTypedValue(Default))... };
1055 (void)dummy;
1056
1057 if(this->m_pRegisterMsg) {
1058 this->m_pRegisterMsg->FstParam();
1059 uint32 dummy[sizeof...(Default)] = {
1060 ( this->m_pRegisterMsg->GetParamPtr()->SetTypedValue(Default))... };
1061 (void)dummy;
1062 }
1063 }
1064
1067
1068protected:
1070 // see CINOSTaskExCmd or CINOSTaskExCmdMsg for further information
1076 const char* apOption,
1077 uint64 auCharacteristics,
1078 uint16 auKeyLevel,
1079 bool abRegisterInco) :
1083 {
1084 CINOSTaskExMsgDefaultParam* params[sizeof...(apDefaultParams)] = { apDefaultParams.AddToMsg(this->m_CommandMsg)...};
1085
1086 for(uint32 uIx = 0; uIx < sizeof...(apDefaultParams); uIx++) {
1087 if((params[uIx]->GetFlag() & CINOSTaskExMsgParam::eFlgStructure) != 0) {
1088 this->m_uIsStructureBitmap |= (1<<uIx);
1089 }
1090 }
1091 this->m_uAllowedStates = auStateBitmap;
1092
1093 INOS_CONCURRENCY_CHECK_FREE(&this->m_CommandMsg);
1094
1095 // name and task available ?
1096 if(this->m_pTask != nullptr && apName != nullptr) {
1097 // yes -> add this command to command registry
1098 this->m_pTask->CINOSTaskEx::RegisterCommand(this);
1099 }
1100 };
1101 template<typename T>
1102 CINOSTaskExMsgParam* AddParam(CINOSTaskExMsg* apMsg, T aValue) {
1103 return apMsg->AddParam(aValue);
1104 }
1105
1106 CINOSTaskExMsgParam* AddParam(CINOSTaskExMsg* apMsg, const char* pValue) {
1107 if((this->m_uIsStructureBitmap & (1<< apMsg->GetParamCnt())) != 0) {
1108 return apMsg->AddJsonParam(pValue);
1109 }
1110 else {
1111 return apMsg->AddParam(pValue);
1112 }
1113 }
1114
1117
1118};
1119
1120
1121//------------------------------------------------------------------------------
1122// template class TINOSTaskExCmd
1123//------------------------------------------------------------------------------
1131template<class ObjectType, typename... ParamType>
1132class TINOSTaskExCmd : public TINOSTaskExCmdBaseParam<ObjectType, ParamType...>
1133{
1134public:
1139 typedef void (ObjectType::*tCommandFunction)(ParamType... Params);
1140
1141
1219
1297
1298 // This helper struct is needed to get ordered calls to GetParam
1299 struct CallStruct {
1300 // Constructor that simply calls the given function with the given params
1302 (Object.*function)(Params...);
1303 }
1304 };
1305
1307 virtual ~TINOSTaskExCmd() { }
1308
1309protected:
1313 virtual void Dispatch(CINOSTaskExMsg* apMsg) {
1314
1315 // Check if object is set
1316 if(this->m_pObject == nullptr) {
1317 // Don't use internal task pointer as this could be the wrong one or not set
1319 return;
1320 }
1321
1322 // Check if function is set
1323 if(m_pFunction == nullptr) {
1324 // Don't use internal task pointer as this could be the wrong one or not set
1326 return;
1327 }
1328
1329 // Use list-initialization "{}" to get the parameters from the message
1330 // as list-initialization is guaranteed to be ordered
1331 // Function call "()" unfortunately not ordered and some compilers then call
1332 // GetParam in the wrong order!
1333 CallStruct dummy = {*(this->m_pObject), m_pFunction, apMsg->GetParam<ParamType>()...};
1334 (void)dummy;
1335 }
1336
1340 virtual void DispatchTmd(CINOSTaskExMsg* apMsg) {
1341 if(m_pFunctionTmd) {
1342 // Use list-initialization "{}" to get the parameters from the message
1343 // as list-initialization is guaranteed to be ordered
1344 // Function call "()" unfortunately not ordered and some compilers then call
1345 // GetParam in the wrong order!
1346 CallStruct dummy = {*(this->m_pObject), m_pFunctionTmd, apMsg->GetParam<ParamType>()...};
1347 (void)dummy;
1348 }
1349 }
1350
1351private:
1352
1354 // message of this command is dispatched.
1355 tCommandFunction m_pFunction = nullptr;
1357 // this command msg is put into the queue even if the msg has a trigger.
1358 tCommandFunction m_pFunctionTmd = nullptr;
1359
1360};
1361
1362//------------------------------------------------------------------------------
1363// template class TINOSTaskExCmdMsg
1364//------------------------------------------------------------------------------
1371template<class ObjectType, typename... ParamType>
1372class TINOSTaskExCmdMsg : public TINOSTaskExCmdBaseParam<ObjectType, ParamType...>
1373{
1374public:
1380
1381 private:
1383 // message of this command is dispatched.
1384 tCommandFunction m_pFunction;
1386 // this command msg is put into the queue even if the msg has a trigger.
1387 tCommandFunction m_pFunctionTmd;
1388
1389 public:
1390
1455
1521
1522
1523
1525 virtual ~TINOSTaskExCmdMsg () { }
1526
1527
1528protected:
1529
1533 virtual void Dispatch(CINOSTaskExMsg* apMsg) override {
1534
1535 // Check if object is set
1536 if(this->m_pObject == nullptr) {
1537 // Don't use internal task pointer as this could be the wrong one or not set
1539 return;
1540 }
1541
1542 // Check if function is set
1543 if(m_pFunction == nullptr) {
1544 // Don't use internal task pointer as this could be the wrong one or not set
1546 return;
1547 }
1548
1549 // Call the function
1550 (this->m_pObject->*m_pFunction)(apMsg);
1551 }
1552
1556 virtual void DispatchTmd(CINOSTaskExMsg* apMsg) override {
1557 if(m_pFunctionTmd) {
1558 (this->m_pObject->*m_pFunctionTmd)(apMsg);
1559 }
1560 }
1561
1562
1563
1564
1565
1566};
1567
1568//------------------------------------------------------------------------------
1569
1570#endif // INC_CINOSTASKEXTMPL_H
1571
1572
1573//------------------------------------------------------------------------------
1574// end of file
CINOSTaskEx * ActualTaskEx()
Definition cinostaskex.h:2575
Definition cinosmcmodule.h:1900
Definition inos_syn.h:67
Definition cinostaskextmpl.h:435
uint16 m_uKeyLevel
Key level of the INCO registration of this commands.
Definition cinostaskextmpl.h:810
tPreDispatchFunction m_pPreDispatchFunction
Function that is called before messages of this command are dispatched.
Definition cinostaskextmpl.h:796
void OnMsgDone(CINOSTaskExMsg *apMsg, CINOSTaskExDef::ERplId aRplId, tMcAppError aAppError)
Function is called by the module (CINOSTaskEx) when MsgDone is called on a message of this command.
Definition cinostaskextmpl.h:727
void SetName(const char *apName)
Returns the name of this command.
Definition cinostaskextmpl.h:554
void AddParam(const char *apName, const char *apValue, const char *apComboData=nullptr, uint32 auFlags=0)
Adds a string (char*) param description. This function may only be used if the param description has ...
Definition cinostaskextmpl.h:602
CINOSTaskExMsg & GetMsg()
Returns the message of this command.
Definition cinostaskextmpl.h:561
virtual void SetPreDispatcher(const CINOSTaskExCmdHookBase *apPreDispatchHook)
Sets the pre dispatch callback which is called before a message is of this command is dispatched.
Definition cinostaskextmpl.h:451
CINOSTaskEx * m_pTask
Task of this command.
Definition cinostaskextmpl.h:793
uint64 m_uIsStructureBitmap
Bitmap that defines if the parameter corresponding to the bit number is a structure.
Definition cinostaskextmpl.h:806
CINOSTaskExMsg * m_pRegisterMsg
Register message for this command (in the task ex for INCO tree)
Definition cinostaskextmpl.h:819
virtual void DispatchTmd(CINOSTaskExMsg *apMsg)=0
Dispatches a timed message if this command. Used by CINOSTaskEx.
uint64 m_uCharacteristics
Characteristics of the INCO registration of this commands.
Definition cinostaskextmpl.h:803
virtual uint32 AddCommand(bool abDeleteOnRemove=false)
Adds this command to the module it belongs to. And makes it therefore callable. This function also ch...
Definition cinostaskextmpl.h:484
virtual uint32 AddCommand(uint64 aChar, uint16 aKeyLevel, bool abRegisterInco=true, bool abDeleteOnRemove=false)
Adds this command to the module it belongs to. And makes it therefore callable. This function also ch...
Definition cinostaskextmpl.h:507
void AddParam(const char *apName, bool abValue, uint32 auFlags=0)
Adds a bool param description. This function may only be used if the param description has not be pro...
Definition cinostaskextmpl.h:620
CINOSTaskExMsg m_CommandMsg
Prototype message for this command.
Definition cinostaskextmpl.h:816
void SetAllowedStates(uint32 auStateBitmap)
Sets the states in which this command is allowed to be called.
Definition cinostaskextmpl.h:633
tOnMsgDoneFunction m_pMsgDoneFunction
Function that is called when MsgDone is called on messages of this command.
Definition cinostaskextmpl.h:799
bool PreDispatch(CINOSTaskExMsg *apMsg)
Function is called by the module (CINOSTaskEx) before the message of this command is dispatched.
Definition cinostaskextmpl.h:706
void AddParam(const char *apName, real64 arValue, real64 arMin, real64 arMax, const char *apUnit="", uint32 auChar=0, uint32 auFlags=0)
Adds a real64 param description. This function may only be used if the param description has not be p...
Definition cinostaskextmpl.h:581
void Claim()
Claims the object of this command. This ensures that in case this command.
Definition cinostaskextmpl.h:657
const char * GetOption() const
Returns the option string of this command.
Definition cinostaskextmpl.h:540
bool(CINOSTaskEx::* tPreDispatchFunction)(CINOSTaskExMsg *apMsg)
Type of pre-dispatch functions. Functions of this type can be used as a callback in SetPreDispatcher.
Definition cinostaskextmpl.h:445
void Release(CINOSTaskExMsg *apMsg=nullptr)
Releases the object of this command. This ensures that in case this command.
Definition cinostaskextmpl.h:667
int operator<(CINOSTaskExCmdBase &aTaskExMsg)
binary tree operators
Definition cinostaskextmpl.h:638
virtual ~CINOSTaskExCmdBase()
Destructor.
Definition cinostaskextmpl.h:648
bool m_bRegisterInco
Defines if this command is registered to the INCO tree if not.
Definition cinostaskextmpl.h:813
virtual void DeleteCommand()
Deletes the object of this command, dispatch if called from.
Definition cinostaskextmpl.h:777
CINOSTaskExMsg * CreateMsg(CINOSSync *apSync=DF_INOS_SYNCHRONOUS)
Create a message of this command. Can be used for manual, customized call.
Definition cinostaskextmpl.h:530
bool CheckParams(size_t count,...)
Checks if thie added parameters match the template definition.
Definition cinostaskextmpl.h:759
const char * GetName()
Returns the name of this command.
Definition cinostaskextmpl.h:547
std::atomic_ulong m_uReferenceCount
Reference count for dynamically created and added objects. If count is 0 the.
Definition cinostaskextmpl.h:829
CINOSTaskExCmdBase(const char *apName, CINOSTaskEx *apTask, uint32 auStateBitmap, const char *apOption, uint64 auCharacteristics, uint16 auKeyLevel, bool abRegisterInco)
Constructor (base constructor is protected, as this class is abstract)
Definition cinostaskextmpl.h:736
void(CINOSTaskEx::* tOnMsgDoneFunction)(CINOSTaskExMsg *apMsg, CINOSTaskExDef::ERplId aRplId, tMcAppError aAppError)
Type of OnMsgDone functions. Functions of this type can be used as a callback in SetOnMsgDone.
Definition cinostaskextmpl.h:465
virtual void SetOnMsgDone(const CINOSTaskExCmdHookBase *apOnMsgDoneHook)
Sets the OnMsgDone callback which is called when MsgDone is called on a message of this command.
Definition cinostaskextmpl.h:472
virtual void Dispatch(CINOSTaskExMsg *apMsg)=0
Dispatches a message if this command. Used by CINOSTaskEx.
const char * m_pOption
Option(s) of the module which are required for this command to be added.
Definition cinostaskextmpl.h:825
uint32 m_uAllowedStates
Bitmap of states in which this command is allowed to be called.
Definition cinostaskextmpl.h:822
Definition cinostaskextmpl.h:262
virtual tOnMsgDoneFunctionBase GetOnMsgDoneFunction() const =0
Returns the on-msg-done hook function if it is set and if the task calling it is of the same type or ...
int operator<(CINOSTaskExCmdHookBase &aHook)
binary tree operators
Definition cinostaskextmpl.h:285
void(CINOSTaskEx::* tOnMsgDoneFunctionBase)(CINOSTaskExMsg *apMsg, CINOSTaskExDef::ERplId aRplId, tMcAppError aAppError)
Base type of OnMsgDone functions. Functions of this type can be used as a callback in SetOnMsgDone.
Definition cinostaskextmpl.h:277
virtual ~CINOSTaskExCmdHookBase()
virtual destructor to avoid compiler warning
Definition cinostaskextmpl.h:307
virtual tPreDispatchFunctionBase GetPreDispatchFunction() const =0
Returns the pre-dispatch hook function if it is set and if the task calling it is of the same type or...
const char * GetName() const
Returns the name of the hook.
Definition cinostaskextmpl.h:280
CINOSTaskExCmdHookBase(const char *apName, CINOSTaskEx &aTask)
Constructor (base constructor is protected, as this class is abstract)
Definition cinostaskextmpl.h:312
bool(CINOSTaskEx::* tPreDispatchFunctionBase)(CINOSTaskExMsg *apMsg)
Base type of pre-dispatch functions. Functions of this type can be used as a callback in SetPreDispat...
Definition cinostaskextmpl.h:268
Definition cinostaskexdef.h:70
Definition cinostaskexdef.h:610
Definition cinostaskexdef.h:129
uint32 SetTypedValue(T aValue)
SetTypedValue.
Definition cinostaskexdef.h:202
Definition cinostaskex.h:396
void FstParam()
reset internal pointer to first param
Definition cinostaskex.h:412
uint32 GetFlags()
get flags
Definition cinostaskex.h:636
char * GetName(bool abResolveIfEmpty=false)
CINOSTaskExMsgDefaultParam * AddDefaultParam(const char *apName, T aValue)
add default param
Definition cinostaskex.h:2454
void SetName(const char *apName)
set name
Definition cinostaskex.h:715
uint32 GetParamCnt() const
get number of param's
Definition cinostaskex.h:448
Definition cinostaskex.h:966
virtual CMcResult PutMsg(CINOSTaskExMsg *apMsg, tMsgId aMsgId=0)
put message to queue and return command id
virtual void MsgError(CINOSTaskExMsg *apMsg, tMcAppError aAppError)
message error
virtual void AddCommand(const char *apName, uint32 auCode, CINCOProcedure *apProc)
add inco command
virtual void MsgDone(tMsgId aMsgId, tMcAppError aAppError=0)
message done (used for deferred messages)
Abstract template base class for all TINOSTaskExCmd variants.
Definition cinostaskextmpl.h:986
virtual uint32 AddCommand(bool abDeleteOnRemove=false) override
Adds this command to the module it belongs to. And makes it therefore callable. This function also ch...
Definition cinostaskextmpl.h:1024
ObjectType * m_pObject
Object of this command.
Definition cinostaskextmpl.h:1116
virtual uint32 AddCommand(uint64 aChar, uint16 aKeyLevel, bool abRegisterInco=true, bool abDeleteOnRemove=false) override
Adds this command to the module it belongs to. And makes it therefore callable. This function also ch...
Definition cinostaskextmpl.h:1039
virtual ~TINOSTaskExCmdBaseParam()
Destructor.
Definition cinostaskextmpl.h:1066
CMcResult operator()(ParamType... Params, CINOSSync *apSync=DF_INOS_SYNCHRONOUS)
Calls this command (dispatched). This function creates and puts a message of this command to the task...
Definition cinostaskextmpl.h:994
TINOSTaskExCmdBaseParam(const char *apName, CINOSTaskEx *apTask, ObjectType *apObject, TINOSTaskExValDef< ParamType >... apDefaultParams, uint32 auStateBitmap, const char *apOption, uint64 auCharacteristics, uint16 auKeyLevel, bool abRegisterInco)
Constructor (base constructor is protected, as this class is abstract)
Definition cinostaskextmpl.h:1071
Class for dynamically created commands. As dynamic (programmatically) created code can not instantiat...
Definition cinostaskextmpl.h:842
void(ObjectType::* tCommandFunction)(CINOSTaskExMsg *apMsg)
Type of functions of this command. Functions of this type must be used in the constructor of this com...
Definition cinostaskextmpl.h:848
ObjectType * m_pObject
Object of this command.
Definition cinostaskextmpl.h:963
CMcResult operator()(ParamType... Params, CINOSSync *apSync=DF_INOS_SYNCHRONOUS)
Calls this command (dispatched). This function creates and puts a message of this command to the task...
Definition cinostaskextmpl.h:857
virtual void DispatchTmd(CINOSTaskExMsg *apMsg) override
Dispatches a timed message if this command. Used by CINOSTaskEx.
Definition cinostaskextmpl.h:956
virtual ~TINOSTaskExCmdDyn()
Destructor.
Definition cinostaskextmpl.h:926
virtual void Dispatch(CINOSTaskExMsg *apMsg) override
Dispatches a message if this command. Used by CINOSTaskEx.
Definition cinostaskextmpl.h:933
Definition cinostaskextmpl.h:325
TINOSTaskExCmdHook(const char *apName, ObjectType &aTask, tPreDispatchFunction apPreDispatchFunction=nullptr, tOnMsgDoneFunction apMsgDoneFunction=nullptr)
Constructor.
Definition cinostaskextmpl.h:375
virtual tOnMsgDoneFunctionBase GetOnMsgDoneFunction() const
Returns the on-msg-done hook function if it is set and if the task calling it is of the same type or ...
Definition cinostaskextmpl.h:402
virtual ~TINOSTaskExCmdHook()
virtual destructor to avoid compiler warning
Definition cinostaskextmpl.h:410
virtual tPreDispatchFunctionBase GetPreDispatchFunction() const
Returns the pre-dispatch hook function if it is set and if the task calling it is of the same type or...
Definition cinostaskextmpl.h:391
bool(ObjectType::* tPreDispatchFunction)(CINOSTaskExMsg *apMsg)
Definition cinostaskextmpl.h:331
void(ObjectType::* tOnMsgDoneFunction)(CINOSTaskExMsg *apMsg, CINOSTaskExDef::ERplId aRplId, tMcAppError aAppError)
Type of OnMsgDone functions. Functions of this type can be used as a callback in SetOnMsgDone.
Definition cinostaskextmpl.h:340
Template class that can be used for methods that take the command message as function argument.
Definition cinostaskextmpl.h:1373
virtual void Dispatch(CINOSTaskExMsg *apMsg) override
Dispatches a message if this command. Used by CINOSTaskEx.
Definition cinostaskextmpl.h:1533
void(ObjectType::* tCommandFunction)(CINOSTaskExMsg *apMsg)
Type of functions of this command. Functions of this type must be used in the constructor of this com...
Definition cinostaskextmpl.h:1379
virtual ~TINOSTaskExCmdMsg()
Destructor.
Definition cinostaskextmpl.h:1525
virtual void DispatchTmd(CINOSTaskExMsg *apMsg) override
Dispatches a timed message if this command. Used by CINOSTaskEx.
Definition cinostaskextmpl.h:1556
TINOSTaskExCmdMsg(const char *apName, tCommandFunction apFunction, tCommandFunction apFunctionTmd, ObjectType &aObject, TINOSTaskExValDef< ParamType >... apDefaultParams, uint32 auStateBitmap=0xFFFFFFFF, const char *apOption=nullptr, uint64 auCharacteristics=0, uint16 auKeyLevel=cKeyLevelMin, bool abRegisterInco=true)
Constructor. This variant takes the parameter definitions and INCO item properties....
Definition cinostaskextmpl.h:1441
TINOSTaskExCmdMsg(const char *apName, CINOSTaskEx *apTask, ObjectType *apObject, tCommandFunction apFunction, tCommandFunction apFunctionTmd, TINOSTaskExValDef< ParamType >... apDefaultParams, uint32 auStateBitmap=0xFFFFFFFF, const char *apOption=nullptr, uint64 auCharacteristics=0, uint16 auKeyLevel=cKeyLevelMin, bool abRegisterInco=true)
Constructor. This variant takes a separate object pointer and task pointer the command is only added ...
Definition cinostaskextmpl.h:1506
Template class that can be used for methods that take the command parameters as function arguments.
Definition cinostaskextmpl.h:1133
TINOSTaskExCmd(const char *apName, CINOSTaskEx *apTask, ObjectType *apObject, tCommandFunction apFunction, tCommandFunction apFunctionTmd, TINOSTaskExValDef< ParamType >... apParamDefinitions, uint32 auStateBitmap=0xFFFFFFFF, const char *apOption=nullptr, uint64 auCharacteristics=0, uint16 auKeyLevel=cKeyLevelMin, bool abRegisterInco=true)
Constructor. This variant takes a separate object pointer and task pointer the command is only added ...
Definition cinostaskextmpl.h:1282
TINOSTaskExCmd(const char *apName, tCommandFunction apFunction, tCommandFunction apFunctionTmd, ObjectType &aObject, TINOSTaskExValDef< ParamType >... apParamDefinitions, uint32 auStateBitmap=0xFFFFFFFF, const char *apOption=nullptr, uint64 auCharacteristics=0, uint16 auKeyLevel=cKeyLevelMin, bool abRegisterInco=true)
Constructor. This variant takes the parameter definitions and INCO item properties....
Definition cinostaskextmpl.h:1205
virtual void Dispatch(CINOSTaskExMsg *apMsg)
Dispatches a message if this command. Used by CINOSTaskEx.
Definition cinostaskextmpl.h:1313
virtual void DispatchTmd(CINOSTaskExMsg *apMsg)
Dispatches a timed message if this command. Used by CINOSTaskEx.
Definition cinostaskextmpl.h:1340
virtual ~TINOSTaskExCmd()
Destructor.
Definition cinostaskextmpl.h:1307
void(ObjectType::* tCommandFunction)(ParamType... Params)
Type of functions of this command. Functions of this type must be used in the constructor of this com...
Definition cinostaskextmpl.h:1139
CINOSTaskExMsgDefaultParam * AddToMsg(CINOSTaskExMsg &aMsg)
Creates a parameter definition object with combo data used by TINOSTaskExCmd templates.
Definition cinostaskextmpl.h:164
TINOSTaskExValDef(const char *Name, T *Value, uint32 Flags=0)
Creates a parameter definition object used by TINOSTaskExCmd templates.
Definition cinostaskextmpl.h:144
CINOSTaskExMsgDefaultParam * AddToMsg(CINOSTaskExMsg &aMsg)
Adds a CINOSTaskExMsgDefaultParam that represent this definition to given message....
Definition cinostaskextmpl.h:243
TINOSTaskExValDef(const char *Name, bool Value, uint32 Characteristics=0, uint32 Flags=0)
Creates a parameter definition object used by TINOSTaskExCmd templates.
Definition cinostaskextmpl.h:230
CINOSTaskExMsgDefaultParam * AddToMsg(CINOSTaskExMsg &aMsg)
Adds a CINOSTaskExMsgDefaultParam that represent this definition to given message....
Definition cinostaskextmpl.h:203
TINOSTaskExValDef(const char *Name, const char *Default, const char *ComboData=nullptr, uint32 Flags=0)
Creates a parameter definition object used by TINOSTaskExCmd templates.
Definition cinostaskextmpl.h:190
Definition cinostaskextmpl.h:48
TINOSTaskExValDef(const char *Name, const char *ComboData, T Value, T Min, T Max, const char *Unit="", uint32 Characteristics=0, uint32 Flags=0)
Creates a parameter definition object with combo data used by TINOSTaskExCmd templates.
Definition cinostaskextmpl.h:87
CINOSTaskExMsgDefaultParam * AddToMsg(CINOSTaskExMsg &aMsg)
Adds a CINOSTaskExMsgDefaultParam that represent this definition to given message....
Definition cinostaskextmpl.h:110
TINOSTaskExValDef(const char *Name, T Value, T Min, T Max, const char *Unit="", uint32 Characteristics=0, uint32 Flags=0)
Creates a parameter definition object used by TINOSTaskExCmd templates.
Definition cinostaskextmpl.h:59
CINOSTask * ActualTask()
uint32 INOS_MCMSG_CODE_TSKEX_CMD_NO_FUNCTION
Definition inoserror.h:1677
uint32 INOS_MCMSG_CODE_TSKEX_CMD_NO_OBJECT
Definition inoserror.h:1677
uint32 INOS_MCMSG_CODE_TSKEX_CMD_NO_TASK
Definition inoserror.h:1677
uint32 INOS_MCMSG_CODE_TSKEX_WRONG_PARAMS
Definition inoserror.h:1677
#define DF_INOS_ASYNCHRONOUS
Definition inosmacro.h:337
#define DF_INOS_SYNCHRONOUS
Definition inosmacro.h:332
Definition cinostaskextmpl.h:1299