forked from ChunelFeng/CGraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathT06-Condition.cpp
More file actions
59 lines (47 loc) · 2.06 KB
/
T06-Condition.cpp
File metadata and controls
59 lines (47 loc) · 2.06 KB
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
59
/***************************
@Author: Chunel
@Contact: chunel@foxmail.com
@File: T06-Condition.cpp
@Time: 2021/6/19 10:44 下午
@Desc: 本例主要演示,根据条件进行逻辑判断的功能
***************************/
#include "MyGCondition/MyCondition.h"
#include "MyGCondition/MyParamCondition.h"
#include "MyGNode/MyNode1.h"
#include "MyGNode/MyNode2.h"
#include "MyGNode/MyReadParamNode.h"
#include "MyGNode/MyWriteParamNode.h"
using namespace CGraph;
void tutorial_condition() {
CStatus status;
GPipelinePtr pipeline = GPipelineFactory::create();
GElementPtr a, b_condition, c, d_condition = nullptr;
b_condition = pipeline->createGGroup<MyCondition>({
pipeline->createGNode<MyNode1>(GNodeInfo("conditionNodeB0", 1)),
pipeline->createGNode<MyNode2>(GNodeInfo("conditionNodeB1", 1)),
pipeline->createGNode<MyNode1>(GNodeInfo("conditionNodeB2", 1))
}); // 生成 b_condition。执行的时候,根据choose()的返回值,在B0,B1,B2中选择一个执行
d_condition = pipeline->createGGroup<MyParamCondition>({
pipeline->createGNode<MyNode1>(GNodeInfo("paramConditionNodeD0", 1)),
pipeline->createGNode<MyNode1>(GNodeInfo("paramConditionNodeD1", 1)),
pipeline->createGNode<MyNode1>(GNodeInfo("paramConditionNodeD2", 1))
});
status += pipeline->registerGElement<MyWriteParamNode>(&a, {}, "writeNodeA", 1);
status += pipeline->registerGElement<MyCondition>(&b_condition, {a}, "conditionB", 1);
status += pipeline->registerGElement<MyReadParamNode>(&c, {b_condition}, "readNodeC", 1);
status += pipeline->registerGElement<MyParamCondition>(&d_condition, {c}, "conditionD", 1);
if (!status.isOK()) {
return;
}
status = pipeline->init();
for (int i = 0; i < 3; i++) {
status += pipeline->run();
std::cout << "[CGraph] tutorial_condition, loop : " << i + 1 << ", and run status = " << status.getCode() << std::endl;
}
status = pipeline->destroy();
GPipelineFactory::remove(pipeline);
}
int main() {
tutorial_condition();
return 0;
}