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 
46 template<typename T>
48 {
49 public:
59  TINOSTaskExValDef (const char* Name,
60  T Value,
61  T Min,
62  T Max,
63  const char* Unit = "",
64  uint32 Characteristics = 0,
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 = "",
93  uint32 Characteristics = 0,
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 
121 private:
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 
136 template<typename T>
138 {
139 public:
144  TINOSTaskExValDef (const char* Name,
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 
170 private:
171  const char* m_pName;
172  T* m_Value;
173  uint32 m_uFlags;
174 };
175 
176 
180 template<>
181 class TINOSTaskExValDef<const char*>
182 {
183 public:
190  TINOSTaskExValDef(const char* Name,
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 
210 private:
211  const char* m_pName;
212  const char* m_Value;
213  const char* m_pComboData;
214  uint32 m_uFlags;
215 };
216 
220 template<>
221 class TINOSTaskExValDef<bool>
222 {
223 public:
230  TINOSTaskExValDef(const char* Name,
231  bool Value,
232  uint32 Characteristics = 0,
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 
250 private:
251  const char* m_pName;
252  bool m_Value;
253  uint32 m_uCharacteristics;
254  uint32 m_uFlags;
255 };
256 
257 
258 //------------------------------------------------------------------------------
263 public:
269 
277  typedef void (CINOSTaskEx::*tOnMsgDoneFunctionBase)(CINOSTaskExMsg* apMsg, CINOSTaskExDef::ERplId aRplId, tMcAppError aAppError);
278 
280  const char* GetName() const {
281  return m_cName;
282  }
283 
286  { return (strcmp(m_cName,aHook.GetName())<0);}
287  int operator == (CINOSTaskExCmdHookBase& aHook)
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 
304  virtual tOnMsgDoneFunctionBase GetOnMsgDoneFunction() const = 0;
305 
308 
309 protected:
311  // see TINOSTaskExCmdHook for further information
312  CINOSTaskExCmdHookBase(const char* apName, CINOSTaskEx& aTask) {
313  strncpy(m_cName, apName, sizeof(m_cName));
314  aTask.RegisterHook(this);
315  }
316 private:
318  inosName64 m_cName;
319 };
320 
321 
322 
323 //------------------------------------------------------------------------------
324 template <typename ObjectType>
326 public:
331  typedef bool (ObjectType::*tPreDispatchFunction)(CINOSTaskExMsg* apMsg);
332 
340  typedef void (ObjectType::*tOnMsgDoneFunction)(CINOSTaskExMsg* apMsg, CINOSTaskExDef::ERplId aRplId, tMcAppError aAppError);
341 
376  const char* apName,
377  ObjectType& aTask,
378  tPreDispatchFunction apPreDispatchFunction = nullptr,
379  tOnMsgDoneFunction apMsgDoneFunction = nullptr
380  ) :
381  CINOSTaskExCmdHookBase(apName,aTask),
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 
410  virtual ~TINOSTaskExCmdHook() {};
411 
412 private:
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 
439 public:
440 
446 
451  virtual void SetPreDispatcher(const CINOSTaskExCmdHookBase* apPreDispatchHook) {
452  if(ActualTask() == m_pTask) {
453  m_pPreDispatchFunction = apPreDispatchHook->GetPreDispatchFunction();
454  }
455  };
456 
457 
465  typedef void (CINOSTaskEx::*tOnMsgDoneFunction)(CINOSTaskExMsg* apMsg, CINOSTaskExDef::ERplId aRplId, tMcAppError aAppError);
466 
467 
472  virtual void SetOnMsgDone(const CINOSTaskExCmdHookBase* apOnMsgDoneHook) {
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());
491  m_uReferenceCount = abDeleteOnRemove ? 1 : 0;
492  m_pRegisterMsg = pCmdMsg;
493 
494  // Crate a new message from prototype message and add the command with the needed parameters
496  return 0;
497  };
498 
507  virtual uint32 AddCommand(
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 
519  m_uReferenceCount = abDeleteOnRemove ? 1 : 0;
520  m_pRegisterMsg = pCmdMsg;
521 
522  this->m_pTask->AddCommand(pCmdMsg,
523  aChar, aKeyLevel, abRegisterInco);
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) {
555  return m_CommandMsg.SetName(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 
585  auto pParam = m_CommandMsg.AddDefaultParam(apName, arValue);
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) {
604  auto pParam = m_CommandMsg.AddDefaultParam(apName, apValue);
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) {
621  auto pParam = m_CommandMsg.AddDefaultParam(apName, abValue);
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 
633  void SetAllowedStates(uint32 auStateBitmap) {
634  m_uAllowedStates= auStateBitmap;
635  }
636 
639  { return (strcmp(m_CommandMsg.GetName(), aTaskExMsg.m_CommandMsg.GetName())<0);}
640  int operator == (CINOSTaskExCmdBase& aTaskExMsg)
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) {
676  uint32 uCount = (uint32)(m_uReferenceCount--);
677 
678  // Was the caller the last reference of this object?
679  if(uCount == 1) {
680  // Yes, delete it
681  DeleteCommand();
682  }
683  }
684  }
685 
686 
687 
688 
689 protected:
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) {
729  (m_pTask->*m_pMsgDoneFunction)(apMsg, aRplId,aAppError );
730  }
731  };
732 
733 
735  // see CINOSTaskExCmd or CINOSTaskExCmdMsg for further information
736  CINOSTaskExCmdBase(const char* apName, CINOSTaskEx* apTask, uint32 auStateBitmap,
737  const char* apOption, uint64 auCharacteristics, uint16 auKeyLevel,
738  bool abRegisterInco) :
739  m_pTask(apTask),
740  m_uCharacteristics(auCharacteristics),
741  m_uKeyLevel(auKeyLevel),
742  m_bRegisterInco(abRegisterInco),
743  m_CommandMsg(CINOSTaskExDef::eMsgCall, (uintptr) this),
744  m_uAllowedStates(auStateBitmap),
746  {
747  if(apName != nullptr) {
748  m_CommandMsg.SetName(apName);
749  }
750  if(apOption != nullptr) {
751  const size_t uBufLen = strlen(apOption) + 1;
752  char* pOption = new char[uBufLen];
753  strncpy(pOption, apOption, uBufLen);
754  m_pOption = pOption;
755  }
756  };
757 
759  bool CheckParams(size_t count, ...) {
760  auto pParam = m_CommandMsg.GetFirstParamPtr(false);
761  va_list args;
762  va_start(args, count);
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);
788  m_pTask->PutMsg(pMsg);
789  }
790  };
791 
794 
797 
800 
802  // if AddCommand is called with no arguments.
803  uint64 m_uCharacteristics = 0;
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 
840 template<class ObjectType>
842 {
843 public:
848  typedef void (ObjectType::*tCommandFunction)(CINOSTaskExMsg* apMsg);
849 
856  template<typename... ParamType>
857  CMcResult operator() (ParamType... Params, CINOSSync* apSync=DF_INOS_SYNCHRONOUS) {
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,
909  tCommandFunction apFunction,
910  tCommandFunction apFunctionTmd,
911  ObjectType& aObject,
912  uint32 auStateBitmap = 0xFFFFFFFF,
913  const char* apOption = "",
914  uint64 auCharacteristics = 0,
915  uint16 auKeyLevel = cKeyLevelMin,
916  bool abRegisterInco = true) :
917  CINOSTaskExCmdBase(apName, &aObject, auStateBitmap, apOption,
918  auCharacteristics, auKeyLevel, abRegisterInco),
919  m_pObject(&aObject),
920  m_pFunction(apFunction),
921  m_pFunctionTmd(apFunctionTmd){}
922 
923 
924 
926  virtual ~TINOSTaskExCmdDyn() {}
927 
928 
929 protected:
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 
963  ObjectType* m_pObject;
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 
984 template<class ObjectType, typename... ParamType>
986 {
987 public:
994  CMcResult operator() (ParamType... Params, CINOSSync* apSync=DF_INOS_SYNCHRONOUS) {
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  {
1026  if(CINOSTaskExCmdBase::CheckParams(sizeof...(ParamType), (int32)TINCOType<ParamType>::eType...)) {
1027  return CINOSTaskExCmdBase::AddCommand(abDeleteOnRemove);
1028  }
1030  };
1031 
1039  virtual uint32 AddCommand(
1040  uint64 aChar, // characteristics of object
1041  uint16 aKeyLevel, // keylevel of object
1042  bool abRegisterInco=true,
1043  bool abDeleteOnRemove = false) override
1044  {
1045  if(CINOSTaskExCmdBase::CheckParams(sizeof...(ParamType), (int32)TINCOType<ParamType>::eType...)) {
1046  return CINOSTaskExCmdBase::AddCommand(aChar, aKeyLevel, abRegisterInco, abDeleteOnRemove);
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 
1068 protected:
1070  // see CINOSTaskExCmd or CINOSTaskExCmdMsg for further information
1071  TINOSTaskExCmdBaseParam(const char* apName,
1072  CINOSTaskEx* apTask,
1073  ObjectType* apObject,
1074  TINOSTaskExValDef<ParamType>... apDefaultParams,
1075  uint32 auStateBitmap,
1076  const char* apOption,
1077  uint64 auCharacteristics,
1078  uint16 auKeyLevel,
1079  bool abRegisterInco) :
1080  CINOSTaskExCmdBase(apName, apTask, auStateBitmap, apOption,
1081  auCharacteristics, auKeyLevel, abRegisterInco),
1082  m_pObject(apObject)
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 
1116  ObjectType* m_pObject;
1117 
1118 };
1119 
1120 
1121 //------------------------------------------------------------------------------
1122 // template class TINOSTaskExCmd
1123 //------------------------------------------------------------------------------
1131 template<class ObjectType, typename... ParamType>
1132 class TINOSTaskExCmd : public TINOSTaskExCmdBaseParam<ObjectType, ParamType...>
1133 {
1134 public:
1139  typedef void (ObjectType::*tCommandFunction)(ParamType... Params);
1140 
1141 
1205  TINOSTaskExCmd(const char* apName,
1206  tCommandFunction apFunction,
1207  tCommandFunction apFunctionTmd,
1208  ObjectType& aObject,
1209  TINOSTaskExValDef<ParamType>... apParamDefinitions,
1210  uint32 auStateBitmap = 0xFFFFFFFF,
1211  const char* apOption = nullptr,
1212  uint64 auCharacteristics = 0,
1213  uint16 auKeyLevel = cKeyLevelMin,
1214  bool abRegisterInco = true) :
1215  TINOSTaskExCmdBaseParam<ObjectType, ParamType...>(apName, &aObject, &aObject, apParamDefinitions...,
1216  auStateBitmap, apOption, auCharacteristics, auKeyLevel, abRegisterInco),
1217  m_pFunction(apFunction),
1218  m_pFunctionTmd(apFunctionTmd) {};
1219 
1282  TINOSTaskExCmd(const char* apName,
1283  CINOSTaskEx* apTask,
1284  ObjectType* apObject,
1285  tCommandFunction apFunction,
1286  tCommandFunction apFunctionTmd,
1287  TINOSTaskExValDef<ParamType>... apParamDefinitions,
1288  uint32 auStateBitmap = 0xFFFFFFFF,
1289  const char* apOption = nullptr,
1290  uint64 auCharacteristics = 0,
1291  uint16 auKeyLevel = cKeyLevelMin,
1292  bool abRegisterInco = true) :
1293  TINOSTaskExCmdBaseParam<ObjectType, ParamType...>(apName, apTask, apObject, apParamDefinitions...,
1294  auStateBitmap, apOption, auCharacteristics, auKeyLevel, abRegisterInco),
1295  m_pFunction(apFunction),
1296  m_pFunctionTmd(apFunctionTmd) {};
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
1301  CallStruct(ObjectType& Object, tCommandFunction function, ParamType... Params) {
1302  (Object.*function)(Params...);
1303  }
1304  };
1305 
1307  virtual ~TINOSTaskExCmd() { }
1308 
1309 protected:
1313  virtual void Dispatch(CINOSTaskExMsg* apMsg) override {
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) override {
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 
1351 private:
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 //------------------------------------------------------------------------------
1371 template<class ObjectType, typename... ParamType>
1372 class TINOSTaskExCmdMsg : public TINOSTaskExCmdBaseParam<ObjectType, ParamType...>
1373 {
1374 public:
1379  typedef void (ObjectType::*tCommandFunction)(CINOSTaskExMsg* apMsg);
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 
1441  TINOSTaskExCmdMsg(const char* apName,
1442  tCommandFunction apFunction,
1443  tCommandFunction apFunctionTmd,
1444  ObjectType& aObject,
1445  TINOSTaskExValDef<ParamType>... apDefaultParams,
1446  uint32 auStateBitmap = 0xFFFFFFFF,
1447  const char* apOption = nullptr,
1448  uint64 auCharacteristics = 0,
1449  uint16 auKeyLevel = cKeyLevelMin,
1450  bool abRegisterInco = true) :
1451  TINOSTaskExCmdBaseParam<ObjectType, ParamType...>(apName, &aObject, &aObject, apDefaultParams...,
1452  auStateBitmap, apOption, auCharacteristics, auKeyLevel, abRegisterInco),
1453  m_pFunction(apFunction),
1454  m_pFunctionTmd(apFunctionTmd) {};
1455 
1506  TINOSTaskExCmdMsg(const char* apName,
1507  CINOSTaskEx* apTask,
1508  ObjectType* apObject,
1509  tCommandFunction apFunction,
1510  tCommandFunction apFunctionTmd,
1511  TINOSTaskExValDef<ParamType>... apDefaultParams,
1512  uint32 auStateBitmap = 0xFFFFFFFF,
1513  const char* apOption = nullptr,
1514  uint64 auCharacteristics = 0,
1515  uint16 auKeyLevel = cKeyLevelMin,
1516  bool abRegisterInco = true) :
1517  TINOSTaskExCmdBaseParam<ObjectType, ParamType...>(apName, apTask, apObject, apDefaultParams...,
1518  auStateBitmap, apOption, auCharacteristics, auKeyLevel, abRegisterInco),
1519  m_pFunction(apFunction),
1520  m_pFunctionTmd(apFunctionTmd) {};
1521 
1522 
1523 
1525  virtual ~TINOSTaskExCmdMsg () { }
1526 
1527 
1528 protected:
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
CINOSTaskExCmdHookBase::tOnMsgDoneFunctionBase
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
ActualTask
CINOSTask * ActualTask()
CINOSTaskExCmdBase::CINOSTaskExCmdBase
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
TINOSTaskExCmdBaseParam::TINOSTaskExCmdBaseParam
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
TINOSTaskExCmdHook::GetPreDispatchFunction
virtual tPreDispatchFunctionBase GetPreDispatchFunction() const override
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
CINOSTaskExCmdBase::~CINOSTaskExCmdBase
virtual ~CINOSTaskExCmdBase()
Destructor.
Definition: cinostaskextmpl.h:648
CINOSTaskExCmdBase::DeleteCommand
virtual void DeleteCommand()
Deletes the object of this command, dispatch if called from.
Definition: cinostaskextmpl.h:777
TINOSTaskExCmd::TINOSTaskExCmd
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
TINOSTaskExCmdHook::TINOSTaskExCmdHook
TINOSTaskExCmdHook(const char *apName, ObjectType &aTask, tPreDispatchFunction apPreDispatchFunction=nullptr, tOnMsgDoneFunction apMsgDoneFunction=nullptr)
Constructor.
Definition: cinostaskextmpl.h:375
CINOSTaskExCmdBase::m_bRegisterInco
bool m_bRegisterInco
Defines if this command is registered to the INCO tree if not.
Definition: cinostaskextmpl.h:813
CINOSTaskExCmdBase::operator<
int operator<(CINOSTaskExCmdBase &aTaskExMsg)
binary tree operators
Definition: cinostaskextmpl.h:638
CINOSTaskExCmdHookBase::~CINOSTaskExCmdHookBase
virtual ~CINOSTaskExCmdHookBase()
virtual destructor to avoid compiler warning
Definition: cinostaskextmpl.h:307
CINOSTaskExCmdBase::SetPreDispatcher
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
TINOSTaskExCmd::CallStruct
Definition: cinostaskextmpl.h:1299
TINOSTaskExCmd::DispatchTmd
virtual void DispatchTmd(CINOSTaskExMsg *apMsg) override
Dispatches a timed message if this command. Used by CINOSTaskEx.
Definition: cinostaskextmpl.h:1340
CINOSTaskExCmdBase::m_pOption
const char * m_pOption
Option(s) of the module which are required for this command to be added.
Definition: cinostaskextmpl.h:825
CINOSTaskExCmdBase::m_uAllowedStates
uint32 m_uAllowedStates
Bitmap of states in which this command is allowed to be called.
Definition: cinostaskextmpl.h:822
TINOSTaskExCmd::~TINOSTaskExCmd
virtual ~TINOSTaskExCmd()
Destructor.
Definition: cinostaskextmpl.h:1307
CINOSTaskExMsg::GetFlags
uint32 GetFlags()
get flags
Definition: cinostaskex.h:636
TINOSTaskExValDef< const char * >::TINOSTaskExValDef
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
TINOSTaskExValDef
Definition: cinostaskextmpl.h:47
CINOSTaskExCmdBase::m_uReferenceCount
std::atomic_ulong m_uReferenceCount
Reference count for dynamically created and added objects. If count is 0 the.
Definition: cinostaskextmpl.h:829
INOS_MCMSG_CODE_TSKEX_WRONG_PARAMS
uint32 INOS_MCMSG_CODE_TSKEX_WRONG_PARAMS
Definition: inoserror.h:1680
CINOSTaskExCmdHookBase::operator<
int operator<(CINOSTaskExCmdHookBase &aHook)
binary tree operators
Definition: cinostaskextmpl.h:285
TINOSTaskExValDef< T * >::TINOSTaskExValDef
TINOSTaskExValDef(const char *Name, T *Value, uint32 Flags=0)
Creates a parameter definition object used by TINOSTaskExCmd templates.
Definition: cinostaskextmpl.h:144
CINOSTaskExCmdBase
Definition: cinostaskextmpl.h:434
TINOSTaskExValDef::TINOSTaskExValDef
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
TINOSTaskExValDef< bool >::TINOSTaskExValDef
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
TINOSTaskExCmdBaseParam::AddCommand
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
CINOSTaskExCmdBase::m_uCharacteristics
uint64 m_uCharacteristics
Characteristics of the INCO registration of this commands.
Definition: cinostaskextmpl.h:803
CINOSTaskExCmdBase::GetMsg
CINOSTaskExMsg & GetMsg()
Returns the message of this command.
Definition: cinostaskextmpl.h:561
CINOSTaskExCmdBase::CheckParams
bool CheckParams(size_t count,...)
Checks if thie added parameters match the template definition.
Definition: cinostaskextmpl.h:759
TINOSTaskExCmdDyn::DispatchTmd
virtual void DispatchTmd(CINOSTaskExMsg *apMsg) override
Dispatches a timed message if this command. Used by CINOSTaskEx.
Definition: cinostaskextmpl.h:956
ActualTaskEx
CINOSTaskEx * ActualTaskEx()
Definition: cinostaskex.h:2577
TINOSTaskExCmdDyn::m_pObject
ObjectType * m_pObject
Object of this command.
Definition: cinostaskextmpl.h:963
CINOSTaskExCmdHookBase::GetOnMsgDoneFunction
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 ...
TINOSTaskExCmdMsg::TINOSTaskExCmdMsg
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
CINOSTaskExCmdBase::tPreDispatchFunction
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
TINOSTaskExCmd::Dispatch
virtual void Dispatch(CINOSTaskExMsg *apMsg) override
Dispatches a message if this command. Used by CINOSTaskEx.
Definition: cinostaskextmpl.h:1313
TINOSTaskExCmdDyn::tCommandFunction
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
CINOSTaskExMsg::SetName
void SetName(const char *apName)
set name
Definition: cinostaskex.h:715
DF_INOS_ASYNCHRONOUS
#define DF_INOS_ASYNCHRONOUS
Definition: inosmacro.h:337
TINOSTaskExCmdMsg::Dispatch
virtual void Dispatch(CINOSTaskExMsg *apMsg) override
Dispatches a message if this command. Used by CINOSTaskEx.
Definition: cinostaskextmpl.h:1533
TINOSTaskExCmdHook::tPreDispatchFunction
bool(ObjectType::* tPreDispatchFunction)(CINOSTaskExMsg *apMsg)
Definition: cinostaskextmpl.h:331
CINOSTaskExCmdBase::AddCommand
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
TINOSTaskExValDef::AddToMsg
CINOSTaskExMsgDefaultParam * AddToMsg(CINOSTaskExMsg &aMsg)
Adds a CINOSTaskExMsgDefaultParam that represent this definition to given message....
Definition: cinostaskextmpl.h:110
CINOSTaskExCmdBase::m_pRegisterMsg
CINOSTaskExMsg * m_pRegisterMsg
Register message for this command (in the task ex for INCO tree)
Definition: cinostaskextmpl.h:819
TINOSTaskExCmdBaseParam::m_pObject
ObjectType * m_pObject
Object of this command.
Definition: cinostaskextmpl.h:1116
CINOSTaskExMsgParam
Definition: cinostaskexdef.h:128
CINOSTaskEx
Definition: cinostaskex.h:965
CINOSTaskExCmdBase::GetName
const char * GetName()
Returns the name of this command.
Definition: cinostaskextmpl.h:547
TINOSTaskExCmdHook::~TINOSTaskExCmdHook
virtual ~TINOSTaskExCmdHook()
virtual destructor to avoid compiler warning
Definition: cinostaskextmpl.h:410
CINOSTaskExCmdBase::AddParam
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
TINOSTaskExValDef< T * >::AddToMsg
CINOSTaskExMsgDefaultParam * AddToMsg(CINOSTaskExMsg &aMsg)
Creates a parameter definition object with combo data used by TINOSTaskExCmd templates.
Definition: cinostaskextmpl.h:164
CINOSTaskExCmdBase::tOnMsgDoneFunction
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
TINOSTaskExCmdBaseParam::~TINOSTaskExCmdBaseParam
virtual ~TINOSTaskExCmdBaseParam()
Destructor.
Definition: cinostaskextmpl.h:1066
TINOSTaskExCmdBaseParam::AddCommand
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
INOS_MCMSG_CODE_TSKEX_CMD_NO_OBJECT
uint32 INOS_MCMSG_CODE_TSKEX_CMD_NO_OBJECT
Definition: inoserror.h:1680
CINOSTaskExCmdBase::AddParam
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
CINOSTaskExCmdBase::AddCommand
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
cinostaskexdef.h
CINOSTaskExCmdHookBase::GetName
const char * GetName() const
Returns the name of the hook.
Definition: cinostaskextmpl.h:280
CINOSTaskExMsg::FstParam
void FstParam()
reset internal pointer to first param
Definition: cinostaskex.h:412
CINOSTaskExMsg::GetParamCnt
uint32 GetParamCnt() const
get number of param's
Definition: cinostaskex.h:448
TINOSTaskExCmdDyn::TINOSTaskExCmdDyn
TINOSTaskExCmdDyn(const char *apName, tCommandFunction apFunction, tCommandFunction apFunctionTmd, ObjectType &aObject, uint32 auStateBitmap=0xFFFFFFFF, const char *apOption="", uint64 auCharacteristics=0, uint16 auKeyLevel=cKeyLevelMin, bool abRegisterInco=true)
Constructor. Does not take any parameter definition. They need to be provided later with AddParam....
Definition: cinostaskextmpl.h:908
TINOSTaskExCmd
Template class that can be used for methods that take the command parameters as function arguments.
Definition: cinostaskextmpl.h:1132
CINOSTaskExDef
Definition: cinostaskexdef.h:69
CINOSTaskEx::AddCommand
virtual void AddCommand(const char *apName, uint32 auCode, CINCOProcedure *apProc)
add inco command
TINOSTaskExCmdDyn::~TINOSTaskExCmdDyn
virtual ~TINOSTaskExCmdDyn()
Destructor.
Definition: cinostaskextmpl.h:926
TINOSTaskExCmdDyn
Class for dynamically created commands. As dynamic (programmatically) created code can not instantiat...
Definition: cinostaskextmpl.h:841
CINOSTaskExCmdBase::m_uIsStructureBitmap
uint64 m_uIsStructureBitmap
Bitmap that defines if the parameter corresponding to the bit number is a structure.
Definition: cinostaskextmpl.h:806
tMcAppError
uint32 tMcAppError
Definition: cinostaskexdef.h:53
TINOSTaskExCmdHook
Definition: cinostaskextmpl.h:325
CINOSTaskEx::MsgError
virtual void MsgError(CINOSTaskExMsg *apMsg, tMcAppError aAppError)
message error
TINOSTaskExCmdDyn::operator()
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
TINOSTaskExCmdHook::GetOnMsgDoneFunction
virtual tOnMsgDoneFunctionBase GetOnMsgDoneFunction() const override
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
CINOSTaskExCmdBase::m_uKeyLevel
uint16 m_uKeyLevel
Key level of the INCO registration of this commands.
Definition: cinostaskextmpl.h:810
CINOSTaskExCmdHookBase::CINOSTaskExCmdHookBase
CINOSTaskExCmdHookBase(const char *apName, CINOSTaskEx &aTask)
Constructor (base constructor is protected, as this class is abstract)
Definition: cinostaskextmpl.h:312
INOS_MCMSG_CODE_TSKEX_CMD_NO_TASK
uint32 INOS_MCMSG_CODE_TSKEX_CMD_NO_TASK
Definition: inoserror.h:1680
CINOSTaskExCmdBase::Dispatch
virtual void Dispatch(CINOSTaskExMsg *apMsg)=0
Dispatches a message if this command. Used by CINOSTaskEx.
CINOSTaskExCmdHookBase::GetPreDispatchFunction
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...
CINOSTaskExCmdBase::m_pPreDispatchFunction
tPreDispatchFunction m_pPreDispatchFunction
Function that is called before messages of this command are dispatched.
Definition: cinostaskextmpl.h:796
CINOSTaskExCmdBase::SetAllowedStates
void SetAllowedStates(uint32 auStateBitmap)
Sets the states in which this command is allowed to be called.
Definition: cinostaskextmpl.h:633
DF_INOS_SYNCHRONOUS
#define DF_INOS_SYNCHRONOUS
Definition: inosmacro.h:332
CINOSTaskEx::PutMsg
virtual CMcResult PutMsg(CINOSTaskExMsg *apMsg, tMsgId aMsgId=0)
put message to queue and return command id
TINOSTaskExValDef< bool >::AddToMsg
CINOSTaskExMsgDefaultParam * AddToMsg(CINOSTaskExMsg &aMsg)
Adds a CINOSTaskExMsgDefaultParam that represent this definition to given message....
Definition: cinostaskextmpl.h:243
CINOSTaskExCmdBase::DispatchTmd
virtual void DispatchTmd(CINOSTaskExMsg *apMsg)=0
Dispatches a timed message if this command. Used by CINOSTaskEx.
CINOSTaskExCmdHookBase
Definition: cinostaskextmpl.h:262
TINOSTaskExCmdMsg::~TINOSTaskExCmdMsg
virtual ~TINOSTaskExCmdMsg()
Destructor.
Definition: cinostaskextmpl.h:1525
CINOSTaskExCmdBase::m_pTask
CINOSTaskEx * m_pTask
Task of this command.
Definition: cinostaskextmpl.h:790
CINOSTaskExCmdBase::CreateMsg
CINOSTaskExMsg * CreateMsg(CINOSSync *apSync=DF_INOS_SYNCHRONOUS)
Create a message of this command. Can be used for manual, customized call.
Definition: cinostaskextmpl.h:530
CINOSTaskExCmdBase::Release
void Release(CINOSTaskExMsg *apMsg=nullptr)
Releases the object of this command. This ensures that in case this command.
Definition: cinostaskextmpl.h:667
CINOSTaskExCmdBase::PreDispatch
bool PreDispatch(CINOSTaskExMsg *apMsg)
Function is called by the module (CINOSTaskEx) before the message of this command is dispatched.
Definition: cinostaskextmpl.h:706
CINOSTaskExMsg::GetRetValue
uint32 GetRetValue() const
get return value. !!!OBSOLETE!!! Will be removed soon
Definition: cinostaskex.h:614
TINOSTaskExCmdMsg::tCommandFunction
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
CINOSTaskExCmdHookBase::tPreDispatchFunctionBase
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
CINOSTaskExCmdBase::m_pMsgDoneFunction
tOnMsgDoneFunction m_pMsgDoneFunction
Function that is called when MsgDone is called on messages of this command.
Definition: cinostaskextmpl.h:799
CINOSTaskExMsgDefaultParam
Definition: cinostaskexdef.h:609
CINOSTaskExMsgParam::SetTypedValue
uint32 SetTypedValue(T aValue)
SetTypedValue.
Definition: cinostaskexdef.h:202
TINOSTaskExValDef::TINOSTaskExValDef
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
CINOSTaskExCmdBase::Claim
void Claim()
Claims the object of this command. This ensures that in case this command.
Definition: cinostaskextmpl.h:657
TINOSTaskExValDef< const char * >::AddToMsg
CINOSTaskExMsgDefaultParam * AddToMsg(CINOSTaskExMsg &aMsg)
Adds a CINOSTaskExMsgDefaultParam that represent this definition to given message....
Definition: cinostaskextmpl.h:203
CINOSTaskExCmdBase::m_CommandMsg
CINOSTaskExMsg m_CommandMsg
Prototype message for this command.
Definition: cinostaskextmpl.h:816
CINOSTaskEx::MsgDone
virtual void MsgDone(tMsgId aMsgId, tMcAppError aAppError=0)
message done (used for deferred messages)
CINOSSync
Definition: inos_syn.h:66
TINOSTaskExCmdMsg
Template class that can be used for methods that take the command message as function argument.
Definition: cinostaskextmpl.h:1372
TINOSTaskExCmdHook::tOnMsgDoneFunction
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
TINOSTaskExCmdDyn::Dispatch
virtual void Dispatch(CINOSTaskExMsg *apMsg) override
Dispatches a message if this command. Used by CINOSTaskEx.
Definition: cinostaskextmpl.h:933
TINOSTaskExCmdMsg::TINOSTaskExCmdMsg
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
TINOSTaskExCmd::tCommandFunction
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
CINOSTaskExMsg::AddDefaultParam
CINOSTaskExMsgDefaultParam * AddDefaultParam(const char *apName, T aValue)
add default param
Definition: cinostaskex.h:2456
CINOSTaskExMsg
Definition: cinostaskex.h:395
TINOSTaskExCmdMsg::DispatchTmd
virtual void DispatchTmd(CINOSTaskExMsg *apMsg) override
Dispatches a timed message if this command. Used by CINOSTaskEx.
Definition: cinostaskextmpl.h:1556
TINOSTaskExCmdBaseParam
Abstract template base class for all TINOSTaskExCmd variants.
Definition: cinostaskextmpl.h:985
INOS_MCMSG_CODE_TSKEX_CMD_NO_FUNCTION
uint32 INOS_MCMSG_CODE_TSKEX_CMD_NO_FUNCTION
Definition: inoserror.h:1680
CINOSTaskExCmdBase::GetOption
const char * GetOption() const
Returns the option string of this command.
Definition: cinostaskextmpl.h:540
TINOSTaskExCmd::TINOSTaskExCmd
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
CINOSTaskEx::RegisterHook
void RegisterHook(CINOSTaskExCmdHookBase *apHook)
register a command hook which can be set to a command later
CINOSTaskExCmdBase::SetOnMsgDone
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
CINOSTaskExCmdBase::SetName
void SetName(const char *apName)
Returns the name of this command.
Definition: cinostaskextmpl.h:554
CINOSTaskExCmdBase::AddParam
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
CINOSTaskExCmdBase::OnMsgDone
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
CINOSTaskExMsg::GetName
char * GetName(bool abResolveIfEmpty=false)
TINOSTaskExCmdBaseParam::operator()
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