forked from ChunelFeng/CGraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathT26-Mutable.cpp
More file actions
42 lines (34 loc) · 1.37 KB
/
T26-Mutable.cpp
File metadata and controls
42 lines (34 loc) · 1.37 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
/***************************
@Author: Chunel
@Contact: chunel@foxmail.com
@File: T26-Mutable.cpp
@Time: 2023/11/15 21:18
@Desc: 本例主要演示,通过 GMutable 在pipeline执行的过程中,修改 GMutable 中的依赖关系逻辑
***************************/
#include "MyGMutable/MyMutable.h"
#include "MyGNode/MyNode1.h"
#include "MyGNode/MyNode2.h"
#include "MyGNode/MyWriteParamNode.h"
using namespace CGraph;
void tutorial_mutable() {
GPipelinePtr pipeline = GPipelineFactory::create();
GElementPtr a, b_mutable, c, d = nullptr;
// 创建一个 mutable(异变),在其中注入三个node
// ps:这里设定的依赖信息关系,是无效的
b_mutable = pipeline->createGGroup<MyMutable>({
pipeline->createGNode<MyNode1>(GNodeInfo("nodeB1")),
pipeline->createGNode<MyNode2>(GNodeInfo("nodeB2")),
pipeline->createGNode<MyNode1>(GNodeInfo("nodeB3"))
});
pipeline->registerGElement<MyNode1>(&a, {}, "nodeA", 1);
pipeline->registerGGroup(&b_mutable, {a}, "mutableB", 1);
pipeline->registerGElement<MyNode2>(&c, {a}, "nodeC", 1);
pipeline->registerGElement<MyWriteParamNode>(&d, {b_mutable, c}, "nodeD", 1);
// 执行多次,查看 b_mutable 中的执行结果。每次都是不同的
pipeline->process(6);
GPipelineFactory::remove(pipeline);
}
int main () {
tutorial_mutable();
return 0;
}