mirror of
https://gitee.com/jiuyilian/embedded-framework.git
synced 2025-01-06 10:16:51 -05:00
Remove files.
This commit is contained in:
parent
882af7f6b0
commit
2af2c45e7a
|
@ -1,24 +0,0 @@
|
|||
|
||||
include(${CMAKE_SOURCE_DIR_IPCSDK}/build/global_config.cmake)
|
||||
set(EXECUTABLE_OUTPUT_PATH ${EXEC_OUTPUT_PATH})
|
||||
set(LIBRARY_OUTPUT_PATH ${LIBS_OUTPUT_PATH})
|
||||
|
||||
include_directories(
|
||||
./src
|
||||
./include
|
||||
${UTILS_SOURCE_PATH}/ReturnCode/include
|
||||
${UTILS_SOURCE_PATH}/Log/include
|
||||
)
|
||||
#do not rely on any other library
|
||||
#link_directories(
|
||||
#)
|
||||
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
aux_source_directory(./src SRC_FILES)
|
||||
|
||||
set(TARGET_NAME ReturnCode)
|
||||
add_library(${TARGET_NAME} STATIC ${SRC_FILES})
|
||||
target_link_libraries(${TARGET_NAME} Log)
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
#ifndef RETURN_CODE_H
|
||||
#define RETURN_CODE_H
|
||||
/*
|
||||
** Make sure we can call this stuff from C++.
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
enum C_RETURN_CODE
|
||||
{
|
||||
C_RETURN_CODE_OK = 0,
|
||||
C_RETURN_CODE_NOT_OK,
|
||||
C_RETURN_CODE_VIRTUAL_FUNCTION,
|
||||
C_RETURN_CODE_INVALID_PARAMENTER,
|
||||
C_RETURN_CODE_END
|
||||
};
|
||||
typedef struct returnCodeC RETURN_CODE_C;
|
||||
typedef struct returnCodeC
|
||||
{
|
||||
const char *(*printStringCode)(const RETURN_CODE_C);
|
||||
const long int mCode;
|
||||
} RETURN_CODE_C;
|
||||
const RETURN_CODE_C CreateReturnCode(const long int code);
|
||||
static inline const char *GetStringCode(const RETURN_CODE_C code)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
|
@ -1,54 +0,0 @@
|
|||
#ifndef V_RETURN_CODE_H
|
||||
#define V_RETURN_CODE_H
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
/**
|
||||
* @brief
|
||||
* The base return code.
|
||||
* Attention: VReturnCOdeDefineStr must be added one item when define one new code.
|
||||
*/
|
||||
enum class VReturnCodeDefine
|
||||
{
|
||||
OK = 0,
|
||||
NOT_OK_UNDEFINE_REASON,
|
||||
NOT_OK_VIRTUAL_FUNCTION,
|
||||
MAKE_SHARED_PTR_FAILED,
|
||||
END
|
||||
};
|
||||
class VReturnCode
|
||||
{
|
||||
protected:
|
||||
VReturnCode(const int &code) : mCode(code)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
virtual ~VReturnCode() = default;
|
||||
virtual const int GetIntCode() { return mCode; }
|
||||
bool IsCodeOK();
|
||||
/**
|
||||
* @brief
|
||||
* Print the code translate into a readable string.
|
||||
* @return int
|
||||
*/
|
||||
virtual std::string PrintStringCode();
|
||||
void SetTips(const std::string &tips) { mTips = tips; }
|
||||
const std::string &GetTips() { return mTips; }
|
||||
/**
|
||||
* @brief
|
||||
* Create a new return code, which is the only way to create a code shared ptr.
|
||||
* @param code
|
||||
* @return std::make_shared<VReturnCode>
|
||||
*/
|
||||
static std::shared_ptr<VReturnCode> NewCode(const VReturnCodeDefine &code);
|
||||
|
||||
private:
|
||||
const int mCode; // Can't be reset.
|
||||
std::string mTips; // Give some tips for return code, such as the not OK detail.
|
||||
};
|
||||
/**
|
||||
* @brief
|
||||
* Define the VReturnCode as shared ptr, which other modules can redefine VReturnCode.
|
||||
*/
|
||||
using RETURN_CODE = std::shared_ptr<VReturnCode>;
|
||||
#endif
|
|
@ -1,35 +0,0 @@
|
|||
#include "ReturnCode.h"
|
||||
#include "Log.h"
|
||||
#include <stdio.h>
|
||||
static const char *RETRUN_CODE_STRING[C_RETURN_CODE_END + 1]={
|
||||
"C_RETURN_CODE_OK",
|
||||
"C_RETURN_CODE_NOT_OK",
|
||||
"C_RETURN_CODE_INVALID_PARAMENTER",
|
||||
"C_RETURN_CODE_END"
|
||||
};
|
||||
static const char *PrintStringCode(const RETURN_CODE_C this)
|
||||
{
|
||||
if (C_RETURN_CODE_OK <= this.mCode && this.mCode <= C_RETURN_CODE_END)
|
||||
{
|
||||
LogInfo("Return code = [ %s ]\n", RETRUN_CODE_STRING[this.mCode]);
|
||||
return RETRUN_CODE_STRING[this.mCode];
|
||||
}
|
||||
LogError("Return code = [ %s ]\n", RETRUN_CODE_STRING[C_RETURN_CODE_INVALID_PARAMENTER]);
|
||||
return RETRUN_CODE_STRING[C_RETURN_CODE_INVALID_PARAMENTER];
|
||||
}
|
||||
const RETURN_CODE_C CreateReturnCode(const long int code)
|
||||
{
|
||||
if (C_RETURN_CODE_OK <= code && code <= C_RETURN_CODE_END)
|
||||
{
|
||||
RETURN_CODE_C result = {NULL, code};
|
||||
result.printStringCode = PrintStringCode;
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogError("undefined code.\n");
|
||||
RETURN_CODE_C result = {NULL, C_RETURN_CODE_INVALID_PARAMENTER};
|
||||
result.printStringCode = PrintStringCode;
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
#include "VReturnCode.h"
|
||||
#include "Log.h"
|
||||
const std::string VReturnCOdeDefineStr[static_cast<int>(VReturnCodeDefine::END) + 1] = {
|
||||
"OK",
|
||||
"NOT_OK_UNDEFINE_REASON, undefine reason",
|
||||
"NOT_OK_VIRTUAL_FUNCTION, do nothing function",
|
||||
"MAKE_SHARED_PTR_FAILED, std::make_shared<T> failed",
|
||||
"END"};
|
||||
std::shared_ptr<VReturnCode> VReturnCode::NewCode(const VReturnCodeDefine &code)
|
||||
{
|
||||
// return std::make_shared<VReturnCode>(static_cast<int>(code));
|
||||
class MakeShared : public VReturnCode
|
||||
{
|
||||
public:
|
||||
MakeShared(const int &code) : VReturnCode(code) {}
|
||||
};
|
||||
return std::make_shared<MakeShared>(static_cast<int>(code));
|
||||
}
|
||||
bool VReturnCode::IsCodeOK()
|
||||
{
|
||||
bool result = mCode == static_cast<int>(VReturnCodeDefine::OK) ? true : false;
|
||||
// if (!result)
|
||||
// {
|
||||
// PrintStringCode(); // Don't print code when run ok.
|
||||
// }
|
||||
return result;
|
||||
}
|
||||
std::string VReturnCode::PrintStringCode()
|
||||
{
|
||||
if (mCode < static_cast<long int>(VReturnCodeDefine::OK) || mCode > static_cast<long int>(VReturnCodeDefine::END))
|
||||
{
|
||||
LogError("Illegal code, cross the border.\n");
|
||||
return "Illegal code.";
|
||||
}
|
||||
if (mCode > static_cast<long int>(VReturnCodeDefine::OK))
|
||||
{
|
||||
LogError("Return code:[ %s ]\n", VReturnCOdeDefineStr[mCode].c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
LogInfo("Return code:[ %s %s]\n", VReturnCOdeDefineStr[mCode].c_str(), GetTips().c_str());
|
||||
}
|
||||
return VReturnCOdeDefineStr[mCode];
|
||||
}
|
Loading…
Reference in New Issue
Block a user