Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
return Value();
}
-protected:
- Knob(T const &defaultValue) :
- m_Value(expandEnvironmentVariables(defaultValue))
- {
- }
-
private:
T m_Value;
};
{ \\
- Knob_##_name() : Knob<_type>(_default) { } \\
-
static const char* Name() { return "KNOB_" #_name; } \\
+ static _type DefaultValue() { return (_default); } \\
+
} _name;
#define GET_KNOB(_name) g_GlobalKnobs._name.Value()
% endif
% endfor
- GlobalKnobs();
+
std::string ToString(const char* optPerLinePrefix="");
+ GlobalKnobs();
};
extern GlobalKnobs g_GlobalKnobs;
template <typename T>
static inline void InitKnob(T& knob)
{
-
- // TODO, read registry first
-
- // Second, read environment variables
+ // Read environment variables
const char* pOverride = getenv(knob.Name());
if (pOverride)
{
- auto knobValue = knob.Value();
+ auto knobValue = knob.DefaultValue();
ConvertEnvToKnob(pOverride, knobValue);
knob.Value(knobValue);
}
+ else
+ {
+ // Set default value
+ knob.Value(knob.DefaultValue());
+ }
}