From 7fa3865f0b3f458827c0777e336cc1ebba6da700 Mon Sep 17 00:00:00 2001 From: "Koska, Andrzej" Date: Wed, 25 Sep 2019 12:17:04 +0200 Subject: [PATCH] Simplifying debug settings classes Change-Id: Ie7039b5ee7f5979564c4697c5d51c2b0a29e5bc2 Signed-off-by: Andrzej Koska Related-To: NEO-3239 --- runtime/os_interface/debug_settings_manager.h | 39 ++++++++----------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/runtime/os_interface/debug_settings_manager.h b/runtime/os_interface/debug_settings_manager.h index ce6d7c1685..9c80aa3133 100644 --- a/runtime/os_interface/debug_settings_manager.h +++ b/runtime/os_interface/debug_settings_manager.h @@ -46,33 +46,26 @@ class GraphicsAllocation; struct MultiDispatchInfo; class SettingsReader; -// clang-format off -#define DECLARE_DEBUG_VARIABLE(dataType, variableName, defaultValue, description) \ -struct DebugVar##variableName \ -{ \ - DebugVar##variableName() { \ - value = (dataType)defaultValue; \ - } \ - dataType get() const { \ - return value; \ - } \ - void set(dataType data) { \ - value = data; \ - } \ - dataType &getRef() { \ - return value; \ - } \ - private: \ - dataType value; \ -}; +template +struct DebugVarBase { + DebugVarBase(const T &defaultValue) : value(defaultValue) {} + T get() const { + return value; + } + void set(T data) { + value = std::move(data); + } + T &getRef() { + return value; + } -#include "debug_variables.inl" -#undef DECLARE_DEBUG_VARIABLE -// clang-format on + private: + T value; +}; struct DebugVariables { #define DECLARE_DEBUG_VARIABLE(dataType, variableName, defaultValue, description) \ - DebugVar##variableName variableName; + DebugVarBase variableName{defaultValue}; #include "debug_variables.inl" #undef DECLARE_DEBUG_VARIABLE };