From ac2a2c023633b2366915a119b6a6d1d184b188de Mon Sep 17 00:00:00 2001 From: ChunelFeng Date: Sat, 13 Jan 2024 16:10:45 +0800 Subject: [PATCH] [feat] optimize createGNode function. --- src/GraphCtrl/GraphPipeline/GPipeline.h | 6 ++++-- src/GraphCtrl/GraphPipeline/GPipeline.inl | 7 ++++--- xmake.lua | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/GraphCtrl/GraphPipeline/GPipeline.h b/src/GraphCtrl/GraphPipeline/GPipeline.h index 6f5304f1..487de95c 100644 --- a/src/GraphCtrl/GraphPipeline/GPipeline.h +++ b/src/GraphCtrl/GraphPipeline/GPipeline.h @@ -105,12 +105,14 @@ class GPipeline : public GPipelineObject, /** * 根据传入的info信息,创建node节点 * @tparam T + * @tparam Args * @param info + * @param args * @return */ - template::value, int> = 0> - GNodePtr createGNode(const GNodeInfo &info); + GNodePtr createGNode(const GNodeInfo &info, Args... args); /** * 根据传入的信息,创建Group信息 diff --git a/src/GraphCtrl/GraphPipeline/GPipeline.inl b/src/GraphCtrl/GraphPipeline/GPipeline.inl index 26b00e3f..f5c8d800 100644 --- a/src/GraphCtrl/GraphPipeline/GPipeline.inl +++ b/src/GraphCtrl/GraphPipeline/GPipeline.inl @@ -92,13 +92,14 @@ CStatus GPipeline::registerGElement(GTemplateNodePtr *elementRef, } -template::value, int>> -GNodePtr GPipeline::createGNode(const GNodeInfo &info) { +GNodePtr GPipeline::createGNode(const GNodeInfo &info, Args... args) { CGRAPH_FUNCTION_BEGIN CGRAPH_ASSERT_INIT_THROW_ERROR(false) - GNodePtr node = CGRAPH_SAFE_MALLOC_COBJECT(T) + GNodePtr node = new(std::nothrow) T(std::forward(args)...); + CGRAPH_ASSERT_NOT_NULL_THROW_ERROR(node) status = node->addElementInfo(info.dependence_, info.name_, info.loop_); CGRAPH_THROW_EXCEPTION_BY_STATUS(status) diff --git a/xmake.lua b/xmake.lua index 8a251016..a96abe1a 100644 --- a/xmake.lua +++ b/xmake.lua @@ -2,7 +2,7 @@ set_project("CGraph") -- set project version -set_version("2.5.4") +set_version("2.6.0") -- set language: c++11 set_languages("c++11")