CMother-KidExample¶
概述¶
此example实现功能为介绍Mother Function如何加载Kid Function以及他们之间的通信。主要用于展现Function的子Function机制。
主要结构¶
CMother-KidExample两个QT工程,用QTCreator打开CMotherExample.pro和CKidExample.pro文件即可加载。
主要代码在CMotherExample和CKidExample文件中:
-
在Mother Function Initialize函数中开启一个定时器(SetTimer设置定时间隔3000ms),调用AddChildFun加载Kid Function并传递字符串strParam,该字符串可以调用SetParamStr来进行参数字符串化。
-
Kid Function在ProcSetFunParam中调用GetParamStrVal和GetParamIntVal来解析Mother Function传来的字符串。
-
Mother Function 3000ms后,架构调用ProcTimer,之后调用PostStopCmdToAllChildFun关闭所有Kid Function。
-
Kid Function中,ProcCloseCmd被调用,用FunQuit发送字符串给Mother Function。
-
Mother Function中,架构调用ProcChildFunQuit接受kid message。