diff --git a/src/CBasic/CStruct.h b/src/CBasic/CStruct.h index 500f84b5..920f4e89 100644 --- a/src/CBasic/CStruct.h +++ b/src/CBasic/CStruct.h @@ -20,11 +20,10 @@ CGRAPH_NAMESPACE_BEGIN * 仅针对类似 bean 数据类型的定义 */ class CStruct { - /** - * 初始化所有字段的值信息 - * @return - */ -public: + /** + * 初始化所有字段的值信息 + * @return + */ virtual CStatus setup() { CGRAPH_EMPTY_FUNCTION } diff --git a/src/DomainCtrl/Ann/DAnnObject.h b/src/DomainCtrl/Ann/DAnnObject.h index 9121100d..b4f9a828 100644 --- a/src/DomainCtrl/Ann/DAnnObject.h +++ b/src/DomainCtrl/Ann/DAnnObject.h @@ -14,7 +14,7 @@ CGRAPH_NAMESPACE_BEGIN class DAnnObject : public DomainObject { -public: +protected: CStatus run() override { CGRAPH_NO_SUPPORT } diff --git a/src/GraphCtrl/GraphElement/GAdapter/GFunction/GFunction.h b/src/GraphCtrl/GraphElement/GAdapter/GFunction/GFunction.h index 3dcf4e1f..e891e539 100644 --- a/src/GraphCtrl/GraphElement/GAdapter/GFunction/GFunction.h +++ b/src/GraphCtrl/GraphElement/GAdapter/GFunction/GFunction.h @@ -32,11 +32,11 @@ class GFunction : public GAdapter { private: explicit GFunction(); - CStatus init() override; + CStatus init() final; - CStatus run() override; + CStatus run() final; - CStatus destroy() override; + CStatus destroy() final; private: CGRAPH_CSTATUS_FUNCTION init_function_ = nullptr; diff --git a/src/GraphCtrl/GraphElement/GGroup/GCluster/GCluster.cpp b/src/GraphCtrl/GraphElement/GGroup/GCluster/GCluster.cpp index 34b5b398..abf4cc63 100644 --- a/src/GraphCtrl/GraphElement/GGroup/GCluster/GCluster.cpp +++ b/src/GraphCtrl/GraphElement/GGroup/GCluster/GCluster.cpp @@ -112,8 +112,8 @@ CBool GCluster::isDone() { /* 所有的element均被执行过,则提示true */ return std::all_of(group_elements_arr_.begin(), group_elements_arr_.end(), [](GElementPtr element) { - return element->done_; - }); + return element->done_; + }); } diff --git a/src/GraphCtrl/GraphElement/GGroup/GCondition/GCondition.cpp b/src/GraphCtrl/GraphElement/GGroup/GCondition/GCondition.cpp index 69a51547..983d8c17 100644 --- a/src/GraphCtrl/GraphElement/GGroup/GCondition/GCondition.cpp +++ b/src/GraphCtrl/GraphElement/GGroup/GCondition/GCondition.cpp @@ -59,7 +59,7 @@ CVoid GCondition::dump(std::ostream& oss) { const auto& cur = group_elements_arr_[i]; cur->dump(oss); - std::string label = "[label=\"" + std::to_string(i) + "\"]"; + const std::string& label = "[label=\"" + std::to_string(i) + "\"]"; dumpEdge(oss, this, cur, label); } diff --git a/src/GraphCtrl/GraphElement/GGroup/GCondition/GMultiCondition.inl b/src/GraphCtrl/GraphElement/GGroup/GCondition/GMultiCondition.inl index 5a6ca20a..e51d17ef 100644 --- a/src/GraphCtrl/GraphElement/GGroup/GCondition/GMultiCondition.inl +++ b/src/GraphCtrl/GraphElement/GGroup/GCondition/GMultiCondition.inl @@ -88,8 +88,20 @@ CIndex GMultiCondition::choose() { template CBool GMultiCondition::isSerializable() { - // 当其中只有一个元素,或者设定了串行模式的时候,才可以线性执行 - return group_elements_arr_.size() <= 1 || GMultiConditionType::SERIAL == type; + if (GMultiConditionType::PARALLEL == type && group_elements_arr_.size() > 1) { + /** + * 如果是PARALLEL模式的话,并且其中的元素个数大于1,则一定不可以串行执行 + * PARALLEL模式中,仅有一个元素的情况,和 SERIAL模式的判断方式一样, + * 均为判断其中所有的element是否可以并行 + * 故放在下面的条件中判断了 + */ + return false; + } + + return std::all_of(group_elements_arr_.begin(), group_elements_arr_.end(), + [](GElementPtr element) { + return element->isSerializable(); + }); } CGRAPH_NAMESPACE_END \ No newline at end of file diff --git a/src/GraphCtrl/GraphElement/GGroup/GGroup.cpp b/src/GraphCtrl/GraphElement/GGroup/GGroup.cpp index 7271f5db..c20ed307 100644 --- a/src/GraphCtrl/GraphElement/GGroup/GGroup.cpp +++ b/src/GraphCtrl/GraphElement/GGroup/GGroup.cpp @@ -64,4 +64,16 @@ CVoid GGroup::dumpGroupLabelEnd(std::ostream& oss) { oss << "}\n"; } + +CBool GGroup::isSerializable() { + /** + * 针对group的情况,应该是所有在其中的element 都是可以串行的,才认定为可串行 + * 但是在 region和 multiCondition中,有针对性的判断 + */ + return std::all_of(group_elements_arr_.begin(), group_elements_arr_.end(), + [](GElementPtr element) { + return element->isSerializable(); + }); +} + CGRAPH_NAMESPACE_END \ No newline at end of file diff --git a/src/GraphCtrl/GraphElement/GGroup/GGroup.h b/src/GraphCtrl/GraphElement/GGroup/GGroup.h index 39015ae4..83892f70 100644 --- a/src/GraphCtrl/GraphElement/GGroup/GGroup.h +++ b/src/GraphCtrl/GraphElement/GGroup/GGroup.h @@ -19,9 +19,7 @@ CGRAPH_NAMESPACE_BEGIN /* 所有节点组合的基类,所有节点组合功能,均继承自此类 */ class GGroup : public GElement { -public: - explicit GGroup(); - +protected: /** * 向group中,添加element信息 * @param element @@ -29,11 +27,6 @@ class GGroup : public GElement { */ virtual CStatus addElement(GElementPtr element) = 0; - CStatus init() override; - - CStatus destroy() override; - -protected: /** * 生成graphviz中 group对应的label 的开头信息 * @param oss @@ -48,8 +41,19 @@ class GGroup : public GElement { */ CVoid dumpGroupLabelEnd(std::ostream& oss); + explicit GGroup(); + + CStatus init() override; + + CStatus destroy() override; + + CBool isSerializable() override; + protected: GElementPtrArr group_elements_arr_; // 存放 element的数组 + + friend class GStaticEngine; + friend class GPipeline; }; using GGroupPtr = GGroup *; diff --git a/src/GraphCtrl/GraphPipeline/_GSchedule/GSchedule.h b/src/GraphCtrl/GraphPipeline/_GSchedule/GSchedule.h index 2925c386..49336601 100644 --- a/src/GraphCtrl/GraphPipeline/_GSchedule/GSchedule.h +++ b/src/GraphCtrl/GraphPipeline/_GSchedule/GSchedule.h @@ -15,7 +15,7 @@ CGRAPH_NAMESPACE_BEGIN class GSchedule : public GraphObject { -protected: +private: /** * 设置调度资源模式 * @param tp @@ -35,6 +35,8 @@ class GSchedule : public GraphObject { CStatus destroy() final; + explicit GSchedule() = default; + ~GSchedule() override; private: diff --git a/xmake.lua b/xmake.lua index 30412ea4..bd5efb90 100644 --- a/xmake.lua +++ b/xmake.lua @@ -2,7 +2,7 @@ set_project("CGraph") -- set project version -set_version("2.4.0") +set_version("2.4.3") -- set language: c++11 set_languages("c++11")