| 12 | using namespace CGraph; |
| 13 | |
| 14 | void tutorial_template() { |
| 15 | GPipelinePtr pipeline = GPipelineFactory::create(); |
| 16 | GTemplateNodePtr<int, float> a = nullptr; |
| 17 | GTemplateNodePtr<int, float> b = nullptr; |
| 18 | GTemplateNodePtr<int> c = nullptr; |
| 19 | GElementPtr d = nullptr; |
| 20 | |
| 21 | /** |
| 22 | * 注册几个模板节点 |
| 23 | * 可以根据 MyTemplateNode 构造函数的不同,而实现不同的构造方式 |
| 24 | * 也可以参考 MyTemplateV2Node 的方式进行构造 |
| 25 | */ |
| 26 | pipeline->registerGElement<MyTemplateNode<int, float>>(&a, {}, 3, 3.5f); |
| 27 | pipeline->registerGElement<MyTemplateNode<int, float>>(&b, {a}, 5, 3.75f); |
| 28 | pipeline->registerGElement<MyTemplateNode<int>>(&c, {b}, 8); |
| 29 | pipeline->registerGElement<MyTemplateV2Node<4>>(&d, {c}); // 也可以通过模板,传递参数数据 |
| 30 | |
| 31 | pipeline->process(); // 运行pipeline |
| 32 | GPipelineFactory::remove(pipeline); |
| 33 | } |
| 34 | |
| 35 | |
| 36 | int main() { |