| 12 | using namespace CGraph; |
| 13 | |
| 14 | void tutorial_trim() { |
| 15 | GPipelinePtr pipeline = GPipelineFactory::create(); |
| 16 | GElementPtr a, b, c, d = nullptr; |
| 17 | |
| 18 | pipeline->registerGElement<MyNode1>(&a, {}, "nodeA"); |
| 19 | pipeline->registerGElement<MyNode2>(&b, {a}, "nodeB"); |
| 20 | pipeline->registerGElement<MyNode1>(&c, {a}, "nodeC"); |
| 21 | |
| 22 | /** |
| 23 | * 可以看出,d节点 对a 的依赖,是可有可无的 |
| 24 | * 建议通过 trim() 接口删除冗余依赖 |
| 25 | * 参考文档:http://www.chunel.cn/archives/cgraph-remove-redundancy-link |
| 26 | */ |
| 27 | pipeline->registerGElement<MyNode2>(&d, {a, b, c}, "nodeD"); |
| 28 | |
| 29 | auto trimSize = pipeline->trim(); |
| 30 | CGRAPH_ECHO("trim size is: %d", (int)trimSize); |
| 31 | |
| 32 | // 查看 trim后的效果 |
| 33 | pipeline->dump(); |
| 34 | GPipelineFactory::remove(pipeline); |
| 35 | } |
| 36 | |
| 37 | |
| 38 | int main() { |