forked from ChunelFeng/CGraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathT03-Region.cpp
More file actions
47 lines (37 loc) · 1.56 KB
/
T03-Region.cpp
File metadata and controls
47 lines (37 loc) · 1.56 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
/***************************
@Author: Chunel
@Contact: chunel@foxmail.com
@File: T03-Region.cpp
@Time: 2021/6/7 8:58 下午
@Desc: 本例主要演示,GRegion的使用方法
***************************/
#include "MyGNode/MyNode1.h"
#include "MyGNode/MyNode2.h"
using namespace CGraph;
void tutorial_region() {
CStatus status;
GPipelinePtr pipeline = GPipelineFactory::create();
GElementPtr a, b_region, c = nullptr;
GElementPtr b1, b2, b3, b4 = nullptr;
b1 = pipeline->createGNode<MyNode1>(GNodeInfo({}, "nodeB1", 1)); // 创建名为nodeB1的node信息
b2 = pipeline->createGNode<MyNode2>(GNodeInfo({b1}, "nodeB2", 2)); // 创建名为nodeB2且自循环2次的node信息
b3 = pipeline->createGNode<MyNode1>(GNodeInfo({b1}, "nodeB3", 1));
b4 = pipeline->createGNode<MyNode1>(GNodeInfo({b2, b3}, "nodeB4", 1));
b_region = pipeline->createGGroup<GRegion>({b1, b2, b3, b4}); // 将 b1、b2、b3、b4 注册入b_region中
if (nullptr == b_region) {
return;
}
status = pipeline->registerGElement<MyNode1>(&a, {}, "nodeA", 1);
if (!status.isOK()) {
return;
}
status = pipeline->registerGElement<GRegion>(&b_region, {a}, "regionB", 1); // 将名为regionB,依赖a执行且自循环2次的cluster信息,注册入pipeline中
status = pipeline->registerGElement<MyNode2>(&c, {b_region}, "nodeC", 1);
status = pipeline->process();
CGRAPH_ECHO("pipeline process status is : [%d]", status.getCode());
GPipelineFactory::destroy(pipeline);
}
int main () {
tutorial_region();
return 0;
}