MCPcopy Create free account
hub / github.com/ChunelFeng/CGraph / MyMessageParam

Class MyMessageParam

tutorial/MyParams/MyMessageParam.h:14–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12#include "CGraph.h"
13
14struct MyMessageParam : public CGraph::GMessageParam {
15 int num = 0;
16 std::string info;
17
18 explicit MyMessageParam() = default;
19
20 /**
21 * 注意:
22 * 使用 GMessageParam 类型参数的时候,建议实现构造拷贝 和 赋值拷贝函数
23 * 否则,针对指针类型变量,可能会出现深浅拷贝的问题
24 */
25 MyMessageParam(const MyMessageParam& param) : CGraph::GMessageParam(param) {
26 /** 针对通过 unique_ptr<value> 获取的方式,推荐实现构造拷贝函数 */
27 this->info = param.info;
28 this->num = param.num;
29 }
30
31 MyMessageParam& operator=(const MyMessageParam& param) {
32 /** 针对通过 value 获取的方式,推荐实现赋值拷贝函数 */
33 if (this == &param) {
34 return *this;
35 }
36
37 this->info = param.info;
38 this->num = param.num;
39 return (*this);
40 }
41};
42
43#endif //CGRAPH_MYMESSAGEPARAM_H

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected