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

Function tutorial_complex

tutorial/T04-Complex.cpp:14–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12using namespace CGraph;
13
14void tutorial_complex() {
15 CStatus status;
16 GPipelinePtr pipeline = GPipelineFactory::create();
17 GElementPtr a, b_cluster, c, d_region, e = nullptr;
18
19 b_cluster = pipeline->createGGroup<GCluster>({
20 pipeline->createGNode<MyNode1>(GNodeInfo("nodeB1", 1)), // 创建名为nodeB1的node信息,并将其放入b_cluster中
21 pipeline->createGNode<MyNode1>(GNodeInfo("nodeB2", 3)), // 创建名为nodeB2且自循环3次的node信息,并将其放入b_cluster中
22 pipeline->createGNode<MyNode2>(GNodeInfo("nodeB3", 1))
23 });
24
25 GElementPtr d1, d2, d3, d4, d23_cluster = nullptr;
26 d1 = pipeline->createGNode<MyNode1>(GNodeInfo({}, "nodeD1", 1));
27 d2 = pipeline->createGNode<MyNode1>(GNodeInfo("nodeD2", 1)); // 创建node,稍后放入cluster中
28 d3 = pipeline->createGNode<MyNode1>(GNodeInfo("nodeD3", 1));
29 d23_cluster = pipeline->createGGroup<GCluster>({d2, d3}, {d1}, "clusterD23", 1);
30 d4 = pipeline->createGNode<MyNode2>(GNodeInfo({d1}, "nodeD4", 1));
31 d_region = pipeline->createGGroup<GRegion>({d1, d23_cluster, d4}); // 创建名为d_region的region信息,并将{d1,d23_cluster,d4}放入其中
32
33 status += pipeline->registerGElement<MyNode1>(&a, {}, "nodeA", 1);
34 status += pipeline->registerGElement<GCluster>(&b_cluster, {}, "clusterB", 1);
35 status += pipeline->registerGElement<MyNode1>(&c, {a, b_cluster}, "nodeC", 1);
36 status += pipeline->registerGElement<GRegion>(&d_region, {a, b_cluster}, "regionD", 2); // 将名为regionD,依赖{a,b_cluster}执行且自循环2次的region信息,注册入pipeline中
37 status += pipeline->registerGElement<MyNode1>(&e, {c, d_region}, "nodeE", 1);
38 if (!status.isOK()) {
39 return;
40 }
41
42 pipeline->process();
43 GPipelineFactory::remove(pipeline);
44}
45
46
47int main () {

Callers 1

mainFunction · 0.70

Calls 5

createFunction · 0.85
GNodeInfoClass · 0.85
removeFunction · 0.85
isOKMethod · 0.80
processMethod · 0.45

Tested by

no test coverage detected