From 19da1011648beb324122f36e6da4cd14cc4c7217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Sat, 2 May 2020 14:39:40 +0200 Subject: Remove redundant Config prefix from ConfigInfo/ConfigLocation Both structs are already in the Config namespace. --- Source/Core/Common/Config/Config.cpp | 2 +- Source/Core/Common/Config/Config.h | 18 +++++++++--------- Source/Core/Common/Config/ConfigInfo.cpp | 6 +++--- Source/Core/Common/Config/ConfigInfo.h | 18 +++++++++--------- Source/Core/Common/Config/Layer.cpp | 12 ++++++------ Source/Core/Common/Config/Layer.h | 18 +++++++++--------- Source/Core/Common/Logging/LogManager.cpp | 15 +++++++-------- 7 files changed, 44 insertions(+), 45 deletions(-) (limited to 'Source/Core/Common') diff --git a/Source/Core/Common/Config/Config.cpp b/Source/Core/Common/Config/Config.cpp index 2587dc5aac..2211d0d5fb 100644 --- a/Source/Core/Common/Config/Config.cpp +++ b/Source/Core/Common/Config/Config.cpp @@ -159,7 +159,7 @@ const std::string& GetLayerName(LayerType layer) return layer_to_name.at(layer); } -LayerType GetActiveLayerForConfig(const ConfigLocation& config) +LayerType GetActiveLayerForConfig(const Location& config) { ReadLock lock(s_layers_rw_lock); diff --git a/Source/Core/Common/Config/Config.h b/Source/Core/Common/Config/Config.h index 2d69e0809e..fa315857bf 100644 --- a/Source/Core/Common/Config/Config.h +++ b/Source/Core/Common/Config/Config.h @@ -37,10 +37,10 @@ void ClearCurrentRunLayer(); const std::string& GetSystemName(System system); std::optional GetSystemFromName(const std::string& system); const std::string& GetLayerName(LayerType layer); -LayerType GetActiveLayerForConfig(const ConfigLocation&); +LayerType GetActiveLayerForConfig(const Location&); template -T Get(LayerType layer, const ConfigInfo& info) +T Get(LayerType layer, const Info& info) { if (layer == LayerType::Meta) return Get(info); @@ -48,44 +48,44 @@ T Get(LayerType layer, const ConfigInfo& info) } template -T Get(const ConfigInfo& info) +T Get(const Info& info) { return GetLayer(GetActiveLayerForConfig(info.location))->Get(info); } template -T GetBase(const ConfigInfo& info) +T GetBase(const Info& info) { return Get(LayerType::Base, info); } template -LayerType GetActiveLayerForConfig(const ConfigInfo& info) +LayerType GetActiveLayerForConfig(const Info& info) { return GetActiveLayerForConfig(info.location); } template -void Set(LayerType layer, const ConfigInfo& info, const std::common_type_t& value) +void Set(LayerType layer, const Info& info, const std::common_type_t& value) { GetLayer(layer)->Set(info, value); InvokeConfigChangedCallbacks(); } template -void SetBase(const ConfigInfo& info, const std::common_type_t& value) +void SetBase(const Info& info, const std::common_type_t& value) { Set(LayerType::Base, info, value); } template -void SetCurrent(const ConfigInfo& info, const std::common_type_t& value) +void SetCurrent(const Info& info, const std::common_type_t& value) { Set(LayerType::CurrentRun, info, value); } template -void SetBaseOrCurrent(const ConfigInfo& info, const std::common_type_t& value) +void SetBaseOrCurrent(const Info& info, const std::common_type_t& value) { if (GetActiveLayerForConfig(info) == LayerType::Base) Set(LayerType::Base, info, value); diff --git a/Source/Core/Common/Config/ConfigInfo.cpp b/Source/Core/Common/Config/ConfigInfo.cpp index 1d4084c3c6..76c5933e27 100644 --- a/Source/Core/Common/Config/ConfigInfo.cpp +++ b/Source/Core/Common/Config/ConfigInfo.cpp @@ -9,18 +9,18 @@ namespace Config { -bool ConfigLocation::operator==(const ConfigLocation& other) const +bool Location::operator==(const Location& other) const { return system == other.system && strcasecmp(section.c_str(), other.section.c_str()) == 0 && strcasecmp(key.c_str(), other.key.c_str()) == 0; } -bool ConfigLocation::operator!=(const ConfigLocation& other) const +bool Location::operator!=(const Location& other) const { return !(*this == other); } -bool ConfigLocation::operator<(const ConfigLocation& other) const +bool Location::operator<(const Location& other) const { if (system != other.system) return system < other.system; diff --git a/Source/Core/Common/Config/ConfigInfo.h b/Source/Core/Common/Config/ConfigInfo.h index ecea74a04b..20051c1003 100644 --- a/Source/Core/Common/Config/ConfigInfo.h +++ b/Source/Core/Common/Config/ConfigInfo.h @@ -18,36 +18,36 @@ template using UnderlyingType = typename std::enable_if_t{}, std::underlying_type>::type; } // namespace detail -struct ConfigLocation +struct Location { System system; std::string section; std::string key; - bool operator==(const ConfigLocation& other) const; - bool operator!=(const ConfigLocation& other) const; - bool operator<(const ConfigLocation& other) const; + bool operator==(const Location& other) const; + bool operator!=(const Location& other) const; + bool operator<(const Location& other) const; }; template -struct ConfigInfo +struct Info { - ConfigInfo(const ConfigLocation& location_, const T& default_value_) + Info(const Location& location_, const T& default_value_) : location{location_}, default_value{default_value_} { } - // Make it easy to convert ConfigInfo into ConfigInfo> + // Make it easy to convert Info into Info> // so that enum settings can still easily work with code that doesn't care about the enum values. template >::value>* = nullptr> - ConfigInfo(const ConfigInfo& other) + Info(const Info& other) : location{other.location}, default_value{static_cast>( other.default_value)} { } - ConfigLocation location; + Location location; T default_value; }; } // namespace Config diff --git a/Source/Core/Common/Config/Layer.cpp b/Source/Core/Common/Config/Layer.cpp index 573c79c04e..311e99ded2 100644 --- a/Source/Core/Common/Config/Layer.cpp +++ b/Source/Core/Common/Config/Layer.cpp @@ -37,13 +37,13 @@ Layer::~Layer() Save(); } -bool Layer::Exists(const ConfigLocation& location) const +bool Layer::Exists(const Location& location) const { const auto iter = m_map.find(location); return iter != m_map.end() && iter->second.has_value(); } -bool Layer::DeleteKey(const ConfigLocation& location) +bool Layer::DeleteKey(const Location& location) { m_is_dirty = true; bool had_value = false; @@ -68,14 +68,14 @@ void Layer::DeleteAllKeys() Section Layer::GetSection(System system, const std::string& section) { - return Section{m_map.lower_bound(ConfigLocation{system, section, ""}), - m_map.lower_bound(ConfigLocation{system, section + '\001', ""})}; + return Section{m_map.lower_bound(Location{system, section, ""}), + m_map.lower_bound(Location{system, section + '\001', ""})}; } ConstSection Layer::GetSection(System system, const std::string& section) const { - return ConstSection{m_map.lower_bound(ConfigLocation{system, section, ""}), - m_map.lower_bound(ConfigLocation{system, section + '\001', ""})}; + return ConstSection{m_map.lower_bound(Location{system, section, ""}), + m_map.lower_bound(Location{system, section + '\001', ""})}; } void Layer::Load() diff --git a/Source/Core/Common/Config/Layer.h b/Source/Core/Common/Config/Layer.h index 87c6b91f90..c309810719 100644 --- a/Source/Core/Common/Config/Layer.h +++ b/Source/Core/Common/Config/Layer.h @@ -45,10 +45,10 @@ inline std::optional TryParse(const std::string& str_value) } // namespace detail template -struct ConfigInfo; +struct Info; class Layer; -using LayerMap = std::map>; +using LayerMap = std::map>; class ConfigLayerLoader { @@ -98,18 +98,18 @@ public: virtual ~Layer(); // Convenience functions - bool Exists(const ConfigLocation& location) const; - bool DeleteKey(const ConfigLocation& location); + bool Exists(const Location& location) const; + bool DeleteKey(const Location& location); void DeleteAllKeys(); template - T Get(const ConfigInfo& config_info) const + T Get(const Info& config_info) const { return Get(config_info.location).value_or(config_info.default_value); } template - std::optional Get(const ConfigLocation& location) const + std::optional Get(const Location& location) const { const auto iter = m_map.find(location); if (iter == m_map.end() || !iter->second.has_value()) @@ -118,18 +118,18 @@ public: } template - void Set(const ConfigInfo& config_info, const std::common_type_t& value) + void Set(const Info& config_info, const std::common_type_t& value) { Set(config_info.location, value); } template - void Set(const ConfigLocation& location, const T& value) + void Set(const Location& location, const T& value) { Set(location, ValueToString(value)); } - void Set(const ConfigLocation& location, std::string new_value) + void Set(const Location& location, std::string new_value) { const auto iter = m_map.find(location); if (iter != m_map.end() && iter->second == new_value) diff --git a/Source/Core/Common/Logging/LogManager.cpp b/Source/Core/Common/Logging/LogManager.cpp index 729e5cb3a8..a847b2402f 100644 --- a/Source/Core/Common/Logging/LogManager.cpp +++ b/Source/Core/Common/Logging/LogManager.cpp @@ -26,13 +26,13 @@ namespace Common::Log { constexpr size_t MAX_MSGLEN = 1024; -const Config::ConfigInfo LOGGER_WRITE_TO_FILE{ - {Config::System::Logger, "Options", "WriteToFile"}, false}; -const Config::ConfigInfo LOGGER_WRITE_TO_CONSOLE{ +const Config::Info LOGGER_WRITE_TO_FILE{{Config::System::Logger, "Options", "WriteToFile"}, + false}; +const Config::Info LOGGER_WRITE_TO_CONSOLE{ {Config::System::Logger, "Options", "WriteToConsole"}, true}; -const Config::ConfigInfo LOGGER_WRITE_TO_WINDOW{ +const Config::Info LOGGER_WRITE_TO_WINDOW{ {Config::System::Logger, "Options", "WriteToWindow"}, true}; -const Config::ConfigInfo LOGGER_VERBOSITY{{Config::System::Logger, "Options", "Verbosity"}, 0}; +const Config::Info LOGGER_VERBOSITY{{Config::System::Logger, "Options", "Verbosity"}, 0}; class FileLogListener : public LogListener { @@ -163,7 +163,7 @@ LogManager::LogManager() for (LogContainer& container : m_log) container.m_enable = Config::Get( - Config::ConfigInfo{{Config::System::Logger, "Logs", container.m_short_name}, false}); + Config::Info{{Config::System::Logger, "Logs", container.m_short_name}, false}); m_path_cutoff_point = DeterminePathCutOffPoint(); } @@ -188,8 +188,7 @@ void LogManager::SaveSettings() for (const auto& container : m_log) { - const Config::ConfigInfo info{{Config::System::Logger, "Logs", container.m_short_name}, - false}; + const Config::Info info{{Config::System::Logger, "Logs", container.m_short_name}, false}; Config::SetBaseOrCurrent(info, container.m_enable); } -- cgit v1.2.3