forked from ChunelFeng/CGraph
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathT15-ElementParam.cpp
58 lines (47 loc) · 1.56 KB
/
T15-ElementParam.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/***************************
@Author: Chunel
@Contact: [email protected]
@File: T15-EParam.cpp
@Time: 2022/5/29 22:29
@Desc: 本例子主要展示,向 MyEParamNode 节点中,传递特定参数,并在节点执行时候打印的逻辑
***************************/
#include "MyGNode/MyNode1.h"
#include "MyGNode/MyEParamNode.h"
#include "MyGParam/MyConnParam.h"
using namespace CGraph;
void tutorial_element_param() {
GPipelinePtr pipeline = GPipelineFactory::create();
GElementPtr a, v1, v2 = nullptr;
pipeline->registerGElement<MyNode1>(&a, {}, "node-1");
/**
* 注册同样类型(MyEParamNode)的节点,但在下方传入不同类型的参数(EParam)
* 从而执行不同的结果
*/
pipeline->registerGElement<MyEParamNode>(&v1, {a}, "version-1");
pipeline->registerGElement<MyEParamNode>(&v2, {v1}, "version-2");
MyVersionParam vp1;
vp1.priority_ = 1;
vp1.secondary_ = 1;
/**
* 往v1中,传入参数特定参数
*/
v1->addEParam(VERSION_PARAM_KEY, &vp1);
/**
* 可以根据需要,传入不同 key 值的不同类型的参数
* 被传入的参数类,需要是GPassedParam类(或其衍生类)的子类
*/
MyVersionParam vp2;
vp2.priority_ = 2;
vp2.secondary_ = 2;
v2->addEParam(VERSION_PARAM_KEY, &vp2);
MyConnParam cp;
cp.ip_ = "127.0.0.1";
cp.port_ = 8080;
v2->addEParam(CONN_PARAM_KEY, &cp);
pipeline->process(); // 运行pipeline
GPipelineFactory::remove(pipeline);
}
int main() {
tutorial_element_param();
return 0;
}