GlobalConfig中的静态变量变为可选extern
This commit is contained in:
@@ -267,9 +267,9 @@ constexpr int ConstexprStrCompare(
|
||||
#define __PLATFORM_VERSION "Unknown"
|
||||
#endif // __PLATFORM_VERSION
|
||||
|
||||
#ifndef PLATFORM_EXTENSION
|
||||
#define PLATFORM_EXTENSION ""
|
||||
#endif // PLATFORM_EXTENSION
|
||||
#ifndef __PLATFORM_EXTENSION
|
||||
#define __PLATFORM_EXTENSION ""
|
||||
#endif // __PLATFORM_EXTENSION
|
||||
|
||||
struct PlatformIndicator
|
||||
: public
|
||||
@@ -328,7 +328,6 @@ struct PlatformIndicator
|
||||
constexpr static bool IsGNUC = false;
|
||||
#endif // __GNUC__
|
||||
|
||||
|
||||
constexpr static const char* PlatformInfomation = __PLATFORM_NAME "-" __PLATFORM_VERSION "-" __PLATFORM_EXTENSION;
|
||||
// not lock current thread, if input is exist will return it otherwise return -1
|
||||
static int KeyboardInput() noexcept;
|
||||
@@ -1966,7 +1965,8 @@ namespace Convention
|
||||
/**
|
||||
* @brief 拷贝赋值函数
|
||||
*/
|
||||
virtual instance& operator=(const instance& value) noexcept
|
||||
template<typename = std::declval<instance>().WriteValue(std::declval<instance>().ReadConstValue())>
|
||||
instance& operator=(const instance& value) noexcept
|
||||
{
|
||||
if constexpr (IsUnique)
|
||||
{
|
||||
@@ -1979,6 +1979,21 @@ namespace Convention
|
||||
return *this;
|
||||
}
|
||||
/**
|
||||
* @brief 拷贝赋值函数
|
||||
*/
|
||||
virtual instance& operator=(const instance& value) noexcept
|
||||
{
|
||||
if constexpr (IsUnique)
|
||||
{
|
||||
throw std::runtime_error("unique ptr is not support to copy");
|
||||
}
|
||||
else
|
||||
{
|
||||
_Mybase::operator=(value);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
/**
|
||||
* @brief 移动赋值函数
|
||||
*/
|
||||
virtual instance& operator=(instance&& value) noexcept
|
||||
|
@@ -11,11 +11,11 @@ namespace Convention
|
||||
class GlobalConfig
|
||||
{
|
||||
public:
|
||||
static std::string ConstConfigFile;
|
||||
constexpr static auto ConstConfigFile = "config.json";
|
||||
|
||||
static void InitExtensionEnv()
|
||||
{
|
||||
ConstConfigFile = "config.json";
|
||||
|
||||
}
|
||||
|
||||
static void GenerateEmptyConfigJson(ToolFile& file)
|
||||
@@ -52,9 +52,12 @@ namespace Convention
|
||||
|
||||
// Build up init data file
|
||||
auto configFile = GetConfigFile();
|
||||
if (!configFile.Exists()) {
|
||||
if (!configFile.Exists())
|
||||
{
|
||||
GenerateEmptyConfigJson(configFile);
|
||||
} else if (isLoad) {
|
||||
}
|
||||
else if (isLoad)
|
||||
{
|
||||
LoadProperties();
|
||||
}
|
||||
}
|
||||
@@ -270,7 +273,7 @@ namespace Convention
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T FindItem(const std::string& key, const T& defaultValue = T{}) const
|
||||
T FindItem(const std::string& key, const T& defaultValue = T{})
|
||||
{
|
||||
auto it = data_pair.find(key);
|
||||
if (it != data_pair.end())
|
||||
@@ -285,32 +288,20 @@ namespace Convention
|
||||
}
|
||||
} else
|
||||
{
|
||||
LogPropertyNotFound(std::string("Key not found: ") + key);
|
||||
LogPropertyNotFound(std::string("Key not found: ") + key, std::to_string(defaultValue));
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
};
|
||||
|
||||
// Static member definition
|
||||
std::string GlobalConfig::ConstConfigFile = "config.json";
|
||||
|
||||
class ProjectConfig : public GlobalConfig
|
||||
{
|
||||
private:
|
||||
static std::string ProjectConfigFileFocus;
|
||||
constexpr static auto ProjectConfigFileFocus = "Assets/";
|
||||
|
||||
public:
|
||||
static void InitExtensionEnv()
|
||||
{
|
||||
ProjectConfigFileFocus = "Assets/";
|
||||
}
|
||||
|
||||
ProjectConfig(bool isLoad = true) : GlobalConfig(ProjectConfigFileFocus, true, isLoad) {}
|
||||
|
||||
static void SetProjectConfigFileFocus(const std::string& path)
|
||||
{
|
||||
ProjectConfigFileFocus = path;
|
||||
}
|
||||
ProjectConfig(bool isLoad = true) : GlobalConfig(ToolFile(ProjectConfigFileFocus), true, isLoad) {}
|
||||
|
||||
static std::string GetProjectConfigFileFocus()
|
||||
{
|
||||
@@ -318,8 +309,7 @@ namespace Convention
|
||||
}
|
||||
};
|
||||
|
||||
// Static member definition
|
||||
std::string ProjectConfig::ProjectConfigFileFocus = "Assets/";
|
||||
|
||||
}
|
||||
|
||||
#endif // Convention_Runtime_GlobalConfig_hpp
|
||||
|
Reference in New Issue
Block a user