#define DALI_ALPHA_FUNCTION_ENTRY(x) { #x, AlphaFunction::x }
// clang-format on
-std::unordered_map<std::string, AlphaFunction> sFunctions{
- DALI_ALPHA_FUNCTION_ENTRY(DEFAULT),
- DALI_ALPHA_FUNCTION_ENTRY(LINEAR),
- DALI_ALPHA_FUNCTION_ENTRY(REVERSE),
- DALI_ALPHA_FUNCTION_ENTRY(EASE_IN_SQUARE),
- DALI_ALPHA_FUNCTION_ENTRY(EASE_OUT_SQUARE),
- DALI_ALPHA_FUNCTION_ENTRY(EASE_IN),
- DALI_ALPHA_FUNCTION_ENTRY(EASE_OUT),
- DALI_ALPHA_FUNCTION_ENTRY(EASE_IN_OUT),
- DALI_ALPHA_FUNCTION_ENTRY(EASE_IN_SINE),
- DALI_ALPHA_FUNCTION_ENTRY(EASE_OUT_SINE),
- DALI_ALPHA_FUNCTION_ENTRY(EASE_IN_OUT_SINE),
- DALI_ALPHA_FUNCTION_ENTRY(BOUNCE),
- DALI_ALPHA_FUNCTION_ENTRY(SIN),
- DALI_ALPHA_FUNCTION_ENTRY(EASE_OUT_BACK),
-};
+std::unordered_map<std::string, AlphaFunction>& GetFunctions()
+{
+ static std::unordered_map<std::string, AlphaFunction> sFunctions{
+ DALI_ALPHA_FUNCTION_ENTRY(DEFAULT),
+ DALI_ALPHA_FUNCTION_ENTRY(LINEAR),
+ DALI_ALPHA_FUNCTION_ENTRY(REVERSE),
+ DALI_ALPHA_FUNCTION_ENTRY(EASE_IN_SQUARE),
+ DALI_ALPHA_FUNCTION_ENTRY(EASE_OUT_SQUARE),
+ DALI_ALPHA_FUNCTION_ENTRY(EASE_IN),
+ DALI_ALPHA_FUNCTION_ENTRY(EASE_OUT),
+ DALI_ALPHA_FUNCTION_ENTRY(EASE_IN_OUT),
+ DALI_ALPHA_FUNCTION_ENTRY(EASE_IN_SINE),
+ DALI_ALPHA_FUNCTION_ENTRY(EASE_OUT_SINE),
+ DALI_ALPHA_FUNCTION_ENTRY(EASE_IN_OUT_SINE),
+ DALI_ALPHA_FUNCTION_ENTRY(BOUNCE),
+ DALI_ALPHA_FUNCTION_ENTRY(SIN),
+ DALI_ALPHA_FUNCTION_ENTRY(EASE_OUT_BACK),
+ };
+ return sFunctions;
+}
#undef DALI_ALPHA_FUNCTION_ENTRY
AlphaFunction GetAlphaFunction(const std::string& name, bool* found)
{
- auto iFind = sFunctions.find(name);
- bool success = iFind != sFunctions.end();
+ auto iFind = GetFunctions().find(name);
+ bool success = iFind != GetFunctions().end();
if(found)
{
*found = success;
void RegisterAlphaFunction(const std::string& name, AlphaFunction alphaFn)
{
- DALI_ASSERT_ALWAYS(sFunctions.insert({name, alphaFn}).second &&
+ DALI_ASSERT_ALWAYS(GetFunctions().insert({name, alphaFn}).second &&
"Function with given key already exists.");
}