Skip to content

Commit

Permalink
[perf] set GAspectType as internal.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunelFeng committed Aug 31, 2024
1 parent b1411d7 commit 3351726
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 18 deletions.
2 changes: 2 additions & 0 deletions src/GraphCtrl/GraphAspect/GAspectDefine.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "../GraphObject.h"

CGRAPH_NAMESPACE_BEGIN
CGRAPH_INTERNAL_NAMESPACE_BEGIN

enum class GAspectType {
BEGIN_INIT = 0,
Expand All @@ -23,6 +24,7 @@ enum class GAspectType {
ENTER_CRASHED = 99,
};

CGRAPH_INTERNAL_NAMESPACE_END
CGRAPH_NAMESPACE_END

#endif //CGRAPH_GASPECTDEFINE_H
16 changes: 8 additions & 8 deletions src/GraphCtrl/GraphAspect/GAspectManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/GraphCtrl/GraphAspect/GAspectManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 8 additions & 8 deletions src/GraphCtrl/GraphElement/GElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

// 如果切面管理类为空,或者未添加切面,直接返回
Expand Down Expand Up @@ -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();
Expand All @@ -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())
Expand All @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/GraphCtrl/GraphElement/GElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -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());

/**
Expand Down

0 comments on commit 3351726

Please sign in to comment.