Merge pull request #5770 from ligfx/lognewconfig

LogManager: use layered config
This commit is contained in:
Anthony
2017-07-27 11:58:57 -07:00
committed by GitHub
20 changed files with 147 additions and 183 deletions

View File

@ -31,8 +31,8 @@
#include "Common/MsgHandler.h"
#include "Common/StringUtil.h"
#include "Common/Config/Config.h"
#include "Core/Boot/Boot.h"
#include "Core/Config/Config.h"
#include "Core/ConfigLoaders/GameConfigLoader.h"
#include "Core/ConfigLoaders/NetPlayConfigLoader.h"
#include "Core/ConfigManager.h"

View File

@ -25,7 +25,6 @@ set(SRCS
Boot/Boot_WiiWAD.cpp
Boot/DolReader.cpp
Boot/ElfReader.cpp
Config/Config.cpp
Config/GraphicsSettings.cpp
ConfigLoaders/BaseConfigLoader.cpp
ConfigLoaders/GameConfigLoader.cpp

View File

@ -1,41 +0,0 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "Core/Config/Config.h"
#include <tuple>
namespace Config
{
bool ConfigLocation::operator==(const ConfigLocation& other) const
{
return std::tie(system, section, key) == std::tie(other.system, other.section, other.key);
}
bool ConfigLocation::operator!=(const ConfigLocation& other) const
{
return !(*this == other);
}
bool ConfigLocation::operator<(const ConfigLocation& other) const
{
return std::tie(system, section, key) < std::tie(other.system, other.section, other.key);
}
LayerType GetActiveLayerForConfig(const ConfigLocation& config)
{
for (auto layer : SEARCH_ORDER)
{
if (!LayerExists(layer))
continue;
if (GetLayer(layer)->Exists(config.system, config.section, config.key))
return layer;
}
// If config is not present in any layer, base layer is considered active.
return LayerType::Base;
}
} // namespace Config

View File

@ -1,90 +0,0 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <string>
#include "Common/Config/Config.h"
#include "Common/Config/Enums.h"
namespace Config
{
struct ConfigLocation
{
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;
};
template <typename T>
struct ConfigInfo
{
ConfigLocation location;
T default_value;
};
template <typename T>
T Get(LayerType layer, const ConfigInfo<T>& info)
{
return GetLayer(layer)
->GetOrCreateSection(info.location.system, info.location.section)
->template Get<T>(info.location.key, info.default_value);
}
template <typename T>
T Get(const ConfigInfo<T>& info)
{
return Get(LayerType::Meta, info);
}
template <typename T>
T GetBase(const ConfigInfo<T>& info)
{
return Get(LayerType::Base, info);
}
LayerType GetActiveLayerForConfig(const ConfigLocation&);
template <typename T>
LayerType GetActiveLayerForConfig(const ConfigInfo<T>& info)
{
return GetActiveLayerForConfig(info.location);
}
template <typename T>
void Set(LayerType layer, const ConfigInfo<T>& info, const T& value)
{
GetLayer(layer)
->GetOrCreateSection(info.location.system, info.location.section)
->Set(info.location.key, value);
InvokeConfigChangedCallbacks();
}
template <typename T>
void SetBase(const ConfigInfo<T>& info, const T& value)
{
Set<T>(LayerType::Base, info, value);
}
template <typename T>
void SetCurrent(const ConfigInfo<T>& info, const T& value)
{
Set<T>(LayerType::CurrentRun, info, value);
}
template <typename T>
void SetBaseOrCurrent(const ConfigInfo<T>& info, const T& value)
{
if (GetActiveLayerForConfig(info) == LayerType::Base)
Set<T>(LayerType::Base, info, value);
else
Set<T>(LayerType::CurrentRun, info, value);
}
} // namespace Config

View File

@ -6,7 +6,7 @@
#include <string>
#include "Core/Config/Config.h"
#include "Common/Config/Config.h"
#include "VideoCommon/VideoConfig.h"
namespace Config

View File

@ -6,7 +6,7 @@
#include <string>
#include "Core/Config/Config.h"
#include "Common/Config/Config.h"
namespace Config
{

View File

@ -16,7 +16,7 @@
#include "Common/IniFile.h"
#include "Common/Logging/Log.h"
#include "Core/Config/Config.h"
#include "Common/Config/Config.h"
#include "Core/ConfigLoaders/IsSettingSaveable.h"
namespace ConfigLoaders

View File

@ -23,7 +23,7 @@
#include "Common/MsgHandler.h"
#include "Common/StringUtil.h"
#include "Core/Config/Config.h"
#include "Common/Config/Config.h"
#include "Core/Config/GraphicsSettings.h"
#include "Core/ConfigLoaders/IsSettingSaveable.h"

View File

@ -7,13 +7,16 @@
#include <algorithm>
#include <vector>
#include "Core/Config/Config.h"
#include "Common/Config/Config.h"
#include "Core/Config/GraphicsSettings.h"
namespace ConfigLoaders
{
bool IsSettingSaveable(const Config::ConfigLocation& config_location)
{
if (config_location.system == Config::System::Logger)
return true;
const static std::vector<Config::ConfigLocation> s_setting_saveable{
// Graphics.Hardware

View File

@ -45,7 +45,6 @@
<ClCompile Include="Boot\Boot_WiiWAD.cpp" />
<ClCompile Include="Boot\DolReader.cpp" />
<ClCompile Include="Boot\ElfReader.cpp" />
<ClCompile Include="Config\Config.cpp" />
<ClCompile Include="Config\GraphicsSettings.cpp" />
<ClCompile Include="ConfigLoaders\BaseConfigLoader.cpp" />
<ClCompile Include="ConfigLoaders\GameConfigLoader.cpp" />
@ -301,7 +300,6 @@
<ClInclude Include="Boot\DolReader.h" />
<ClInclude Include="Boot\ElfReader.h" />
<ClInclude Include="Boot\ElfTypes.h" />
<ClInclude Include="Config\Config.h" />
<ClInclude Include="Config\GraphicsSettings.h" />
<ClInclude Include="ConfigLoaders\BaseConfigLoader.h" />
<ClInclude Include="ConfigLoaders\GameConfigLoader.h" />

View File

@ -871,9 +871,6 @@
<ClCompile Include="ConfigLoaders\IsSettingSaveable.cpp">
<Filter>ConfigLoader</Filter>
</ClCompile>
<ClCompile Include="Config\Config.cpp">
<Filter>Config</Filter>
</ClCompile>
<ClCompile Include="Config\GraphicsSettings.cpp">
<Filter>Config</Filter>
</ClCompile>
@ -1523,9 +1520,6 @@
<ClInclude Include="ConfigLoaders\IsSettingSaveable.h">
<Filter>ConfigLoader</Filter>
</ClInclude>
<ClInclude Include="Config\Config.h">
<Filter>Config</Filter>
</ClInclude>
<ClInclude Include="Config\GraphicsSettings.h">
<Filter>Config</Filter>
</ClInclude>