Skip to content

Commit

Permalink
[tutorial] add template v2 node.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunelFeng committed Feb 1, 2024
1 parent 33b0722 commit f0078c4
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/GraphCtrl/GraphAspect/GAspectManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ CStatus GAspectManager::add(GAspectPtr aspect) {
}


GAspectManager *GAspectManager::setName(const std::string &name) {
GAspectManagerPtr GAspectManager::setName(const std::string &name) {
for (GAspectPtr aspect : aspect_arr_) {
CGRAPH_ASSERT_NOT_NULL_THROW_ERROR(aspect)
aspect->setName(name);
Expand Down
2 changes: 1 addition & 1 deletion src/GraphCtrl/GraphElement/_GEngine/GEngineDefine.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ CGRAPH_NAMESPACE_BEGIN
enum class GEngineType {
STATIC = 1, /** 静态图运行 */
DYNAMIC = 2, /** 动态图运行 */
TOPO = 3, /** 拓扑运行(针对仅包含node的情况) */
TOPO = 3, /** 拓扑运行 */
};

CGRAPH_NAMESPACE_END
Expand Down
23 changes: 23 additions & 0 deletions tutorial/MyGNode/MyTemplateV2Node.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/***************************
@Author: Chunel
@Contact: [email protected]
@File: MyTemplateV2Node.h
@Time: 2024/2/1 21:51
@Desc:
***************************/

#ifndef CGRAPH_MYTEMPLATEV2NODE_H
#define CGRAPH_MYTEMPLATEV2NODE_H

#include "CGraph.h"

template<int TID>
class MyTemplateV2Node : public CGraph::GNode {
public:
CStatus run() override {
CGraph::CGRAPH_ECHO("[MyTemplateV2Node] template id = [%d] ", TID);
return CStatus();
}
};

#endif //CGRAPH_MYTEMPLATEV2NODE_H
6 changes: 5 additions & 1 deletion tutorial/T08-Template.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
***************************/

#include "MyGNode/MyTemplateNode.h"
#include "MyGNode/MyTemplateV2Node.h"

using namespace CGraph;

Expand All @@ -15,14 +16,17 @@ void tutorial_template() {
GTemplateNodePtr<int, float> a = nullptr;
GTemplateNodePtr<int, float> b = nullptr;
GTemplateNodePtr<int> c = nullptr;
GElementPtr d = nullptr;

/**
* 注册几个模板节点
* 可以根据 MyTemplateNode构造函数的不同,而实现不同的构造方式
* 可以根据 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);
Expand Down

0 comments on commit f0078c4

Please sign in to comment.