diff --git a/README.md b/README.md index e6f2192c..594b0c96 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ `CGraph`中文名为【色丶图】,是一套无任何第三方依赖的跨平台图流程执行框架。通过`GPipeline`(流水线)底层调度,实现了依赖元素依次顺序执行、非依赖元素并发执行的调度功能。 -使用者只需继承`GNode`(节点)类,实现子类的run()方法,并根据需要设定依赖关系,即可实现任务的图化执行。还可以通过设定各种包含多节点信息的`GGroup`(组),自行控制图的条件判断、循环和并发执行逻辑。 +使用者只需继承`GNode`(节点)类,实现子类的run()方法,并根据需要设定依赖关系,即可实现任务的图化执行或流水线执行。还可以通过设定各种包含多节点信息的`GGroup`(组),自行控制图的条件判断、循环和并发执行逻辑。 项目提供了丰富的`Param`(参数)类型,用于不同应用场景下的数据互通。此外,还可以通过添加`GAspect`(切面)的方式,实现以上各种元素功能的横向扩展;通过引入`GAdapter`(适配器)对单个节点功能进行加强;或者通过添加`GEvent`(信号),丰富和优化执行逻辑。 @@ -311,6 +311,7 @@ int main() { [2024.01.24 - v2.6.0 - Chunel] * 提供`pipeline`的拓扑执行的方式 +* 提供判定`element`之间是否有依赖关系的方法 diff --git a/src/CBasic/CDescInfo.h b/src/CBasic/CDescInfo.h index de3152cb..89deca41 100644 --- a/src/CBasic/CDescInfo.h +++ b/src/CBasic/CDescInfo.h @@ -21,7 +21,7 @@ class CDescInfo { * 获取名称信息 * @return */ - const std::string& getName() const { + virtual const std::string& getName() const { return name_.empty() ? session_ : name_; } diff --git a/src/GraphCtrl/GraphAspect/GAspectObject.cpp b/src/GraphCtrl/GraphAspect/GAspectObject.cpp new file mode 100644 index 00000000..7d1bc38e --- /dev/null +++ b/src/GraphCtrl/GraphAspect/GAspectObject.cpp @@ -0,0 +1,37 @@ +/*************************** +@Author: Chunel +@Contact: chunel@foxmail.com +@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 \ No newline at end of file diff --git a/src/GraphCtrl/GraphAspect/GAspectObject.h b/src/GraphCtrl/GraphAspect/GAspectObject.h index 12de9af2..90cdffde 100644 --- a/src/GraphCtrl/GraphAspect/GAspectObject.h +++ b/src/GraphCtrl/GraphAspect/GAspectObject.h @@ -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; /** * 获取切面参数内容 @@ -45,6 +43,15 @@ class GAspectObject : public GraphObject, c_enable_if_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 @@ -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; }; diff --git a/src/GraphCtrl/GraphElement/GElement.inl b/src/GraphCtrl/GraphElement/GElement.inl index c57d5c16..487fb4a6 100644 --- a/src/GraphCtrl/GraphElement/GElement.inl +++ b/src/GraphCtrl/GraphElement/GElement.inl @@ -23,10 +23,10 @@ GElementPtr GElement::addGAspect(TParam* param) { } GAspectPtr aspect = CGRAPH_SAFE_MALLOC_COBJECT(TAspect) - aspect->setName(this->getName()); aspect->setAParam(param); aspect->setGParamManager(this->param_manager_); aspect->setGEventManager(this->event_manager_); + aspect->setBelong(this); aspect_manager_->add(aspect); return this; } @@ -40,9 +40,9 @@ GElementPtr GElement::addGAspect(Args... args) { } auto aspect = UAllocator::safeMallocTemplateCObject(std::forward(args)...); - aspect->setName(this->getName()); aspect->setGParamManager(this->param_manager_); aspect->setGEventManager(this->event_manager_); + aspect->setBelong(this); aspect_manager_->add(aspect); return this; } diff --git a/src/GraphCtrl/GraphElement/GElementManager.cpp b/src/GraphCtrl/GraphElement/GElementManager.cpp index 0028409b..792cc26f 100644 --- a/src/GraphCtrl/GraphElement/GElementManager.cpp +++ b/src/GraphCtrl/GraphElement/GElementManager.cpp @@ -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 diff --git a/src/GraphCtrl/GraphElement/_GEngine/GTopoEngine/GTopoEngine.h b/src/GraphCtrl/GraphElement/_GEngine/GTopoEngine/GTopoEngine.h index 206e5f48..541f89c8 100644 --- a/src/GraphCtrl/GraphElement/_GEngine/GTopoEngine/GTopoEngine.h +++ b/src/GraphCtrl/GraphElement/_GEngine/GTopoEngine/GTopoEngine.h @@ -16,7 +16,7 @@ CGRAPH_NAMESPACE_BEGIN -class GTopoEngine : GEngine { +class GTopoEngine : public GEngine { protected: explicit GTopoEngine() = default;