Skip to content

Commit

Permalink
[bugfix] change CStatus= override. Add namespace ::internal
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunelFeng committed Nov 17, 2023
1 parent a313979 commit 30c2952
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 27 deletions.
9 changes: 9 additions & 0 deletions src/CBasic/CBasicDefine.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ namespace CGraph { \

CGRAPH_NAMESPACE_BEGIN

#define CGRAPH_INTERNAL_NAMESPACE_BEGIN \
namespace internal { \

#define CGRAPH_INTERNAL_NAMESPACE_END \
} /* end of namespace internal */ \

CGRAPH_INTERNAL_NAMESPACE_BEGIN

using CCHAR = char;
using CUINT = unsigned int;
using CVOID = void;
Expand All @@ -32,6 +40,7 @@ using CDOUBLE = double;
using CCONSTR = const char*;
using CSIZE = size_t;

CGRAPH_INTERNAL_NAMESPACE_END
CGRAPH_NAMESPACE_END

#endif //CGRAPH_CBASICDEFINE_H
2 changes: 2 additions & 0 deletions src/CBasic/CException.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "CStrDefine.h"

CGRAPH_NAMESPACE_BEGIN
CGRAPH_INTERNAL_NAMESPACE_BEGIN

class CEXCEPTION : public std::exception {
public:
Expand All @@ -39,6 +40,7 @@ class CEXCEPTION : public std::exception {
std::string exception_info_; // 异常状态信息
};

CGRAPH_INTERNAL_NAMESPACE_END
CGRAPH_NAMESPACE_END

#endif //CGRAPH_CEXCEPTION_H
13 changes: 12 additions & 1 deletion src/CBasic/CStatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "CStrDefine.h"

CGRAPH_NAMESPACE_BEGIN
CGRAPH_INTERNAL_NAMESPACE_BEGIN

/**
* 说明:
Expand Down Expand Up @@ -66,7 +67,7 @@ class CSTATUS {
}

CSTATUS& operator=(const CSTATUS& status) {
if (!status.isOK()) {
if (this->error_code_ != status.error_code_) {
// 如果status是正常的话,则所有数据保持不变
this->error_code_ = status.error_code_;
this->error_info_ = status.error_info_;
Expand All @@ -89,6 +90,15 @@ class CSTATUS {
return (*this);
}

/**
* 恢复状态信息
*/
void reset() {
this->error_code_ = STATUS_OK;
this->error_info_.clear();
this->error_locate_.clear();
}

/**
* 获取异常值信息
* @return
Expand Down Expand Up @@ -143,6 +153,7 @@ class CSTATUS {
std::string error_locate_; // 错误发生的具体位置,形如:file|function|line
};

CGRAPH_INTERNAL_NAMESPACE_END
CGRAPH_NAMESPACE_END

#endif //CGRAPH_CSTATUS_H
40 changes: 20 additions & 20 deletions src/CBasic/CValType.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@
#include "CStatus.h"
#include "CException.h"

using CChar = CGraph::CCHAR;
using CUint = CGraph::CUINT;
using CSize = CGraph::CSIZE;
using CVoid = CGraph::CVOID;
using CVoidPtr = CGraph::CVOID *;
using CInt = CGraph::CINT;
using CLong = CGraph::CLONG;
using CULong = CGraph::CULONG;
using CBool = CGraph::CBOOL;
using CIndex = CGraph::CINT; // 表示标识信息,可以为负数
using CFloat = CGraph::CFLOAT;
using CDouble = CGraph::CDOUBLE;
using CConStr = CGraph::CCONSTR; // 表示 const char*
using CBigBool = CGraph::CBIGBOOL;
using CChar = CGraph::internal::CCHAR;
using CUint = CGraph::internal::CUINT;
using CSize = CGraph::internal::CSIZE;
using CVoid = CGraph::internal::CVOID;
using CVoidPtr = CGraph::internal::CVOID *;
using CInt = CGraph::internal::CINT;
using CLong = CGraph::internal::CLONG;
using CULong = CGraph::internal::CULONG;
using CBool = CGraph::internal::CBOOL;
using CIndex = CGraph::internal::CINT; // 表示标识信息,可以为负数
using CFloat = CGraph::internal::CFLOAT;
using CDouble = CGraph::internal::CDOUBLE;
using CConStr = CGraph::internal::CCONSTR; // 表示 const char*
using CBigBool = CGraph::internal::CBIGBOOL;

using CLevel = CGraph::CINT;
using CSec = CGraph::CLONG; // 表示秒信息, for second
using CMSec = CGraph::CLONG; // 表示毫秒信息, for millisecond
using CFMSec = CGraph::CDOUBLE; // 表示毫秒信息,包含小数点信息
using CLevel = CGraph::internal::CINT;
using CSec = CGraph::internal::CLONG; // 表示秒信息, for second
using CMSec = CGraph::internal::CLONG; // 表示毫秒信息, for millisecond
using CFMSec = CGraph::internal::CDOUBLE; // 表示毫秒信息,包含小数点信息

using CStatus = CGraph::CSTATUS;
using CException = CGraph::CEXCEPTION;
using CStatus = CGraph::internal::CSTATUS;
using CException = CGraph::internal::CEXCEPTION;

#endif //CGRAPH_CVALTYPE_H
2 changes: 1 addition & 1 deletion src/GraphCtrl/GraphElement/GElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ CBool GElement::isMutable() const {


CStatus GElement::crashed(const CException& ex) {
return CStatus(STATUS_CRASH, ex.what(), CGRAPH_GET_LOCATE);
return CStatus(internal::STATUS_CRASH, ex.what(), CGRAPH_GET_LOCATE);
}


Expand Down
5 changes: 3 additions & 2 deletions src/GraphCtrl/GraphElement/GGroup/GMutable/GMutable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ CStatus GMutable::run() {

/**
* 1. 初始化内容
* 2. 通过外部复写 translate(),来实现关系设定。其中,通过 --> 设定的,是会自动恢复visible的
* 2. 通过外部复写 reshape(),来实现关系设定。其中,通过 --> 设定的,是会自动恢复visible的
* 3. 通过 manager 执行
*/
setup();
convert(group_elements_arr_);
status = reshape(group_elements_arr_);
CGRAPH_FUNCTION_CHECK_STATUS

status = manager_->process({group_elements_arr_.begin(), group_elements_arr_.end()});
CGRAPH_FUNCTION_END
Expand Down
4 changes: 2 additions & 2 deletions src/GraphCtrl/GraphElement/GGroup/GMutable/GMutable.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ CGRAPH_NAMESPACE_BEGIN
class GMutable : public GGroup {
protected:
/**
* 修改内部数据的
* 重新设定内部数据的结构信息
* @param elements
* @return
*/
virtual CVoid convert(GElementPtrArr& elements) = 0;
virtual CStatus reshape(GElementPtrArr& elements) = 0;

explicit GMutable();

Expand Down
1 change: 1 addition & 0 deletions src/GraphCtrl/GraphPipeline/GPipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ CStatus GPipeline::dump(std::ostream& oss) {
}

oss << "}\n\n";
std::cout.unsetf(std::ios::fixed);
CGRAPH_FUNCTION_END
}

Expand Down
4 changes: 3 additions & 1 deletion tutorial/MyGMutable/MyMutable.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

class MyMutable : public CGraph::GMutable {
public:
CVoid convert(CGraph::GElementPtrArr& elements) override {
CStatus reshape(CGraph::GElementPtrArr& elements) override {
auto param = CGRAPH_GET_GPARAM_WITH_NO_EMPTY(MyParam, "param1")
int count = param->iCount % 4;
if (0 == count) {
Expand All @@ -36,6 +36,8 @@ class MyMutable : public CGraph::GMutable {
} else {
CGraph::CGRAPH_ECHO("---- run nothing"); // 理论不会进入这种情况
}

return CStatus();
}
};

Expand Down

0 comments on commit 30c2952

Please sign in to comment.