Skip to content

Commit

Permalink
[perf] change aspect get name function.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunelFeng committed Apr 1, 2024
1 parent 5f2c575 commit 30f9524
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 12 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

`CGraph`中文名为【色丶图】,是一套无任何第三方依赖的跨平台图流程执行框架。通过`GPipeline`(流水线)底层调度,实现了依赖元素依次顺序执行、非依赖元素并发执行的调度功能。

使用者只需继承`GNode`(节点)类,实现子类的run()方法,并根据需要设定依赖关系,即可实现任务的图化执行。还可以通过设定各种包含多节点信息的`GGroup`(组),自行控制图的条件判断、循环和并发执行逻辑。
使用者只需继承`GNode`(节点)类,实现子类的run()方法,并根据需要设定依赖关系,即可实现任务的图化执行或流水线执行。还可以通过设定各种包含多节点信息的`GGroup`(组),自行控制图的条件判断、循环和并发执行逻辑。

项目提供了丰富的`Param`(参数)类型,用于不同应用场景下的数据互通。此外,还可以通过添加`GAspect`(切面)的方式,实现以上各种元素功能的横向扩展;通过引入`GAdapter`(适配器)对单个节点功能进行加强;或者通过添加`GEvent`(信号),丰富和优化执行逻辑。

Expand Down Expand Up @@ -311,6 +311,7 @@ int main() {

[2024.01.24 - v2.6.0 - Chunel]
* 提供`pipeline`的拓扑执行的方式
* 提供判定`element`之间是否有依赖关系的方法

</details>

Expand Down
2 changes: 1 addition & 1 deletion src/CBasic/CDescInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CDescInfo {
* 获取名称信息
* @return
*/
const std::string& getName() const {
virtual const std::string& getName() const {
return name_.empty() ? session_ : name_;
}

Expand Down
37 changes: 37 additions & 0 deletions src/GraphCtrl/GraphAspect/GAspectObject.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/***************************
@Author: Chunel
@Contact: [email protected]
@File: GAspectObject.cpp
@Time: 2024/4/1 21:53
@Desc:
***************************/

#include "GAspectObject.h"
#include "../GraphElement/GElementInclude.h"

CGRAPH_NAMESPACE_BEGIN

GAspectObject::GAspectObject() {
session_ = URandom<>::generateSession(CGRAPH_STR_ASPECT);
}


const std::string& GAspectObject::getName() const {
CGRAPH_ASSERT_NOT_NULL_THROW_ERROR(belong_);
return belong_->getName();
}


GAspectObject::~GAspectObject() {
CGRAPH_DELETE_PTR(param_)
}


auto GAspectObject::setBelong(GElementPtr belong)
-> decltype(this) {
CGRAPH_ASSERT_NOT_NULL_THROW_ERROR(belong)
belong_ = belong;
return this;
}

CGRAPH_NAMESPACE_END
21 changes: 15 additions & 6 deletions src/GraphCtrl/GraphAspect/GAspectObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,14 @@

CGRAPH_NAMESPACE_BEGIN

class GElement;

class GAspectObject : public GraphObject,
public CDescInfo {
protected:
explicit GAspectObject() {
session_ = URandom<>::generateSession(CGRAPH_STR_ASPECT);
}
explicit GAspectObject();

~GAspectObject() override {
CGRAPH_DELETE_PTR(param_)
}
~GAspectObject() override;

/**
* 获取切面参数内容
Expand All @@ -45,6 +43,15 @@ class GAspectObject : public GraphObject,
c_enable_if_t<std::is_base_of<GAspectParam, T>::value, int> = 0>
GAspectObject* setAParam(T* param);

/**
* 设置从属的 element信息
* @param belong
* @return
*/
auto setBelong(GElement* belong)-> decltype(this);

const std::string& getName() const override;

CGRAPH_NO_ALLOWED_COPY(GAspectObject)

CGRAPH_DECLARE_GPARAM_MANAGER_WRAPPER
Expand All @@ -64,8 +71,10 @@ class GAspectObject : public GraphObject,
GAspectParamPtr param_ { nullptr }; // 参数信息
GParamManagerPtr param_manager_ { nullptr }; // GParam参数管理类
GEventManagerPtr event_manager_ { nullptr }; // 事件管理类
GElement* belong_ { nullptr }; // 从属的 element信息

friend class GAspectManager;
friend class GAspect;
friend class GElement;
};

Expand Down
4 changes: 2 additions & 2 deletions src/GraphCtrl/GraphElement/GElement.inl
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ GElementPtr GElement::addGAspect(TParam* param) {
}

GAspectPtr aspect = CGRAPH_SAFE_MALLOC_COBJECT(TAspect)
aspect->setName(this->getName());
aspect->setAParam<TParam>(param);
aspect->setGParamManager(this->param_manager_);
aspect->setGEventManager(this->event_manager_);
aspect->setBelong(this);
aspect_manager_->add(aspect);
return this;
}
Expand All @@ -40,9 +40,9 @@ GElementPtr GElement::addGAspect(Args... args) {
}

auto aspect = UAllocator::safeMallocTemplateCObject<TAspect>(std::forward<Args>(args)...);
aspect->setName(this->getName());
aspect->setGParamManager(this->param_manager_);
aspect->setGEventManager(this->event_manager_);
aspect->setBelong(this);
aspect_manager_->add(aspect);
return this;
}
Expand Down
1 change: 0 additions & 1 deletion src/GraphCtrl/GraphElement/GElementManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ CStatus GElementManager::destroy() {

CStatus GElementManager::run() {
CGRAPH_FUNCTION_BEGIN
CGRAPH_ASSERT_NOT_NULL(engine_)

status = engine_->run(); // 通过引擎来执行全部的逻辑
CGRAPH_FUNCTION_CHECK_STATUS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

CGRAPH_NAMESPACE_BEGIN

class GTopoEngine : GEngine {
class GTopoEngine : public GEngine {
protected:
explicit GTopoEngine() = default;

Expand Down

0 comments on commit 30f9524

Please sign in to comment.