Skip to content

Commit

Permalink
[feat] optimize createGNode function.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunelFeng committed Jan 13, 2024
1 parent c6b2151 commit ac2a2c0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/GraphCtrl/GraphPipeline/GPipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,14 @@ class GPipeline : public GPipelineObject,
/**
* 根据传入的info信息,创建node节点
* @tparam T
* @tparam Args
* @param info
* @param args
* @return
*/
template<typename T,
template<typename T, typename ...Args,
c_enable_if_t<std::is_base_of<GNode, T>::value, int> = 0>
GNodePtr createGNode(const GNodeInfo &info);
GNodePtr createGNode(const GNodeInfo &info, Args... args);

/**
* 根据传入的信息,创建Group信息
Expand Down
7 changes: 4 additions & 3 deletions src/GraphCtrl/GraphPipeline/GPipeline.inl
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,14 @@ CStatus GPipeline::registerGElement(GTemplateNodePtr<Args ...> *elementRef,
}


template<typename T,
template<typename T, typename ...Args,
c_enable_if_t<std::is_base_of<GNode, T>::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 &&>(args)...);
CGRAPH_ASSERT_NOT_NULL_THROW_ERROR(node)
status = node->addElementInfo(info.dependence_, info.name_, info.loop_);
CGRAPH_THROW_EXCEPTION_BY_STATUS(status)

Expand Down
2 changes: 1 addition & 1 deletion xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit ac2a2c0

Please sign in to comment.