| 14 | using namespace CGraph; |
| 15 | |
| 16 | void tutorial_mutable() { |
| 17 | GPipelinePtr pipeline = GPipelineFactory::create(); |
| 18 | GElementPtr a, b_mutable, c, d = nullptr; |
| 19 | |
| 20 | // 创建一个 mutable(异变),在其中注入三个node |
| 21 | // ps:这里设定的依赖信息关系,是无效的 |
| 22 | b_mutable = pipeline->createGGroup<MyMutable>({ |
| 23 | pipeline->createGNode<MyNode1>(GNodeInfo("nodeB1")), |
| 24 | pipeline->createGNode<MyNode2>(GNodeInfo("nodeB2")), |
| 25 | pipeline->createGNode<MyNode1>(GNodeInfo("nodeB3")) |
| 26 | }); |
| 27 | |
| 28 | pipeline->registerGElement<MyNode1>(&a, {}, "nodeA", 1); |
| 29 | pipeline->registerGGroup(&b_mutable, {a}, "mutableB", 1); |
| 30 | pipeline->registerGElement<MyNode2>(&c, {a}, "nodeC", 1); |
| 31 | pipeline->registerGElement<MyWriteParamNode>(&d, {b_mutable, c}, "nodeD", 1); |
| 32 | |
| 33 | // 执行多次,查看 b_mutable 中的执行结果。每次都是不同的 |
| 34 | pipeline->process(6); |
| 35 | GPipelineFactory::remove(pipeline); |
| 36 | } |
| 37 | |
| 38 | |
| 39 | int main () { |