/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* limitations under the License.
*
*/
-#include "dali-scene3d/public-api/loader/alpha-function-helper.h"
+
+// CLASS HEADER
+#include <dali-scene3d/public-api/loader/alpha-function-helper.h>
+
+// EXTERNAL INCLUDES
#include <unordered_map>
-namespace Dali
-{
-namespace Scene3D
-{
-namespace Loader
+namespace Dali::Scene3D::Loader
{
namespace
{
#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.");
}
-} // namespace Loader
-} // namespace Scene3D
-} // namespace Dali
+} // namespace Dali::Scene3D::Loader