Config: Add Get/Set on Layer

For convenience, when getting/setting from ConfigInfos.
This commit is contained in:
Léo Lam
2017-08-03 01:20:52 +08:00
parent e86f5ac04b
commit c900e77ac5
2 changed files with 19 additions and 6 deletions

View File

@ -66,9 +66,7 @@ LayerType GetActiveLayerForConfig(const ConfigLocation&);
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);
return GetLayer(layer)->Get(info);
}
template <typename T>
@ -92,9 +90,7 @@ LayerType GetActiveLayerForConfig(const ConfigInfo<T>& info)
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);
GetLayer(layer)->Set(info, value);
InvokeConfigChangedCallbacks();
}