forked from ChunelFeng/CGraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathT08-Template.cpp
More file actions
39 lines (32 loc) · 1.23 KB
/
T08-Template.cpp
File metadata and controls
39 lines (32 loc) · 1.23 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
/***************************
@Author: Chunel
@Contact: chunel@foxmail.com
@File: T08-Template.cpp
@Time: 2021/9/18 9:52 下午
@Desc: 本例主要演示,注册节点的时候,传入模板节点类型的情况
***************************/
#include "MyGNode/MyTemplateNode.h"
#include "MyGNode/MyTemplateV2Node.h"
using namespace CGraph;
void tutorial_template() {
GPipelinePtr pipeline = GPipelineFactory::create();
GTemplateNodePtr<int, float> a = nullptr;
GTemplateNodePtr<int, float> b = nullptr;
GTemplateNodePtr<int> c = nullptr;
GElementPtr d = nullptr;
/**
* 注册几个模板节点
* 可以根据 MyTemplateNode 构造函数的不同,而实现不同的构造方式
* 也可以参考 MyTemplateV2Node 的方式进行构造
*/
pipeline->registerGElement<MyTemplateNode<int, float>>(&a, {}, 3, 3.5f);
pipeline->registerGElement<MyTemplateNode<int, float>>(&b, {a}, 5, 3.75f);
pipeline->registerGElement<MyTemplateNode<int>>(&c, {b}, 8);
pipeline->registerGElement<MyTemplateV2Node<4>>(&d, {c}); // 也可以通过模板,传递参数数据
pipeline->process(); // 运行pipeline
GPipelineFactory::remove(pipeline);
}
int main() {
tutorial_template();
return 0;
}