summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Config/Config.cpp
diff options
context:
space:
mode:
authorAnthony <Helios747@users.noreply.github.com>2017-07-27 11:58:57 -0700
committerGitHub <noreply@github.com>2017-07-27 11:58:57 -0700
commit6fe33f844f1ad9ca02965f9fb75e752430e2744a (patch)
tree56eadb83bc111a39292a4541dcad233b7e021684 /Source/Core/Common/Config/Config.cpp
parent7a51b0bcec891b95b3ea98b03e239ec7937ceb13 (diff)
parent28d6c61e34aeb478d73d440d1aa3faa48b765fa8 (diff)
Merge pull request #5770 from ligfx/lognewconfig
LogManager: use layered config
Diffstat (limited to 'Source/Core/Common/Config/Config.cpp')
-rw-r--r--Source/Core/Common/Config/Config.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/Source/Core/Common/Config/Config.cpp b/Source/Core/Common/Config/Config.cpp
index 27f0389ea8..285db95f28 100644
--- a/Source/Core/Common/Config/Config.cpp
+++ b/Source/Core/Common/Config/Config.cpp
@@ -5,6 +5,7 @@
#include <algorithm>
#include <list>
#include <map>
+#include <tuple>
#include "Common/Assert.h"
#include "Common/Config/Config.h"
@@ -144,4 +145,34 @@ const std::string& GetLayerName(LayerType layer)
};
return layer_to_name.at(layer);
}
+
+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;
+}
}