From 3351726fed9790cfba88d35e7b401b477f25f66f Mon Sep 17 00:00:00 2001 From: ChunelFeng Date: Sun, 1 Sep 2024 00:25:47 +0800 Subject: [PATCH] [perf] set GAspectType as internal. --- src/GraphCtrl/GraphAspect/GAspectDefine.h | 2 ++ src/GraphCtrl/GraphAspect/GAspectManager.cpp | 16 ++++++++-------- src/GraphCtrl/GraphAspect/GAspectManager.h | 2 +- src/GraphCtrl/GraphElement/GElement.cpp | 16 ++++++++-------- src/GraphCtrl/GraphElement/GElement.h | 2 +- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/GraphCtrl/GraphAspect/GAspectDefine.h b/src/GraphCtrl/GraphAspect/GAspectDefine.h index e0fcc1dc..7c2c245c 100644 --- a/src/GraphCtrl/GraphAspect/GAspectDefine.h +++ b/src/GraphCtrl/GraphAspect/GAspectDefine.h @@ -12,6 +12,7 @@ #include "../GraphObject.h" CGRAPH_NAMESPACE_BEGIN +CGRAPH_INTERNAL_NAMESPACE_BEGIN enum class GAspectType { BEGIN_INIT = 0, @@ -23,6 +24,7 @@ enum class GAspectType { ENTER_CRASHED = 99, }; +CGRAPH_INTERNAL_NAMESPACE_END CGRAPH_NAMESPACE_END #endif //CGRAPH_GASPECTDEFINE_H diff --git a/src/GraphCtrl/GraphAspect/GAspectManager.cpp b/src/GraphCtrl/GraphAspect/GAspectManager.cpp index 2bc13223..81fe9939 100644 --- a/src/GraphCtrl/GraphAspect/GAspectManager.cpp +++ b/src/GraphCtrl/GraphAspect/GAspectManager.cpp @@ -20,7 +20,7 @@ GAspectManager::~GAspectManager() { } -CStatus GAspectManager::reflect(const GAspectType &type, +CStatus GAspectManager::reflect(const internal::GAspectType &type, const CStatus &curStatus) { CGRAPH_FUNCTION_BEGIN @@ -30,25 +30,25 @@ CStatus GAspectManager::reflect(const GAspectType &type, * 仅针对Begin对应的内容,进行返回值判断 * run()方法切面更容易被执行,故放在最前方判断 */ - case GAspectType::BEGIN_RUN : + case internal::GAspectType::BEGIN_RUN : status = aspect->beginRun(); break; - case GAspectType::FINISH_RUN : + case internal::GAspectType::FINISH_RUN : aspect->finishRun(curStatus); break; - case GAspectType::BEGIN_INIT : + case internal::GAspectType::BEGIN_INIT : status = aspect->beginInit(); break; - case GAspectType::FINISH_INIT : + case internal::GAspectType::FINISH_INIT : aspect->finishInit(curStatus); break; - case GAspectType::BEGIN_DESTROY : + case internal::GAspectType::BEGIN_DESTROY : status = aspect->beginDestroy(); break; - case GAspectType::FINISH_DESTROY : + case internal::GAspectType::FINISH_DESTROY : aspect->finishDestroy(curStatus); break; - case GAspectType::ENTER_CRASHED : + case internal::GAspectType::ENTER_CRASHED : aspect->enterCrashed(); break; default: diff --git a/src/GraphCtrl/GraphAspect/GAspectManager.h b/src/GraphCtrl/GraphAspect/GAspectManager.h index cc948ef7..6ff33222 100644 --- a/src/GraphCtrl/GraphAspect/GAspectManager.h +++ b/src/GraphCtrl/GraphAspect/GAspectManager.h @@ -28,7 +28,7 @@ class GAspectManager : public GAspectObject, * @param curStatus * @return */ - CStatus reflect(const GAspectType& type, + CStatus reflect(const internal::GAspectType& type, const CStatus& curStatus = CStatus()); CStatus add(GAspectPtr aspect) final; diff --git a/src/GraphCtrl/GraphElement/GElement.cpp b/src/GraphCtrl/GraphElement/GElement.cpp index 2ddfca89..8cf6dca7 100644 --- a/src/GraphCtrl/GraphElement/GElement.cpp +++ b/src/GraphCtrl/GraphElement/GElement.cpp @@ -206,7 +206,7 @@ CStatus GElement::addManagers(GParamManagerPtr paramManager, GEventManagerPtr ev } -CStatus GElement::doAspect(const GAspectType& aspectType, const CStatus& curStatus) { +CStatus GElement::doAspect(const internal::GAspectType& aspectType, const CStatus& curStatus) { CGRAPH_FUNCTION_BEGIN // 如果切面管理类为空,或者未添加切面,直接返回 @@ -242,7 +242,7 @@ CStatus GElement::fatProcessor(const CFunctionType& type) { for (CSize i = 0; i < this->loop_ && status.isOK() && GElementState::NORMAL == this->getCurState(); i++) { /** 执行带切面的run方法 */ - status += doAspect(GAspectType::BEGIN_RUN); + status += doAspect(internal::GAspectType::BEGIN_RUN); CGRAPH_FUNCTION_CHECK_STATUS do { status += isAsync() ? asyncRun() : run(); @@ -253,7 +253,7 @@ CStatus GElement::fatProcessor(const CFunctionType& type) { * 可以根据需求,对任意element类型,添加特定的isHold条件 * */ } while (checkYield(), this->isHold() && status.isOK()); - doAspect(GAspectType::FINISH_RUN, status); + doAspect(internal::GAspectType::FINISH_RUN, status); } CGRAPH_THROW_EXCEPTION_BY_STATUS(checkRunResult()) @@ -262,24 +262,24 @@ CStatus GElement::fatProcessor(const CFunctionType& type) { case CFunctionType::INIT: { concerned_params_.clear(); // 仅需要记录这一轮使用到的 GParam 信息 is_prepared_ = false; - status = doAspect(GAspectType::BEGIN_INIT); + status = doAspect(internal::GAspectType::BEGIN_INIT); CGRAPH_FUNCTION_CHECK_STATUS status = init(); - doAspect(GAspectType::FINISH_INIT, status); + doAspect(internal::GAspectType::FINISH_INIT, status); break; } case CFunctionType::DESTROY: { - status = doAspect(GAspectType::BEGIN_DESTROY); + status = doAspect(internal::GAspectType::BEGIN_DESTROY); CGRAPH_FUNCTION_CHECK_STATUS status = destroy(); - doAspect(GAspectType::FINISH_DESTROY, status); + doAspect(internal::GAspectType::FINISH_DESTROY, status); break; } default: CGRAPH_RETURN_ERROR_STATUS("get function type error") } } catch (const CException& ex) { - doAspect(GAspectType::ENTER_CRASHED); + doAspect(internal::GAspectType::ENTER_CRASHED); status = crashed(ex); } diff --git a/src/GraphCtrl/GraphElement/GElement.h b/src/GraphCtrl/GraphElement/GElement.h index ae2e56cb..d83032e7 100644 --- a/src/GraphCtrl/GraphElement/GElement.h +++ b/src/GraphCtrl/GraphElement/GElement.h @@ -296,7 +296,7 @@ class GElement : public GElementObject, * @param curStatus * @return */ - CStatus doAspect(const GAspectType& aspectType, + CStatus doAspect(const internal::GAspectType& aspectType, const CStatus& curStatus = CStatus()); /**