From 9ef75fe91837394620edb91f332065a4f34a0281 Mon Sep 17 00:00:00 2001 From: crupest Date: Fri, 9 Nov 2018 20:57:29 +0800 Subject: Add singleton system. --- src/ui/animations/animation.cpp | 10 ++++++++++ src/ui/animations/animation.hpp | 10 +++------- 2 files changed, 13 insertions(+), 7 deletions(-) (limited to 'src/ui/animations') diff --git a/src/ui/animations/animation.cpp b/src/ui/animations/animation.cpp index 33c743cf..b1f92a3e 100644 --- a/src/ui/animations/animation.cpp +++ b/src/ui/animations/animation.cpp @@ -2,6 +2,8 @@ #include +#include "application.hpp" + namespace cru::ui::animations { namespace details @@ -66,6 +68,14 @@ namespace cru::ui::animations AnimationTimeUnit current_time_ = AnimationTimeUnit::zero(); }; + AnimationManager* AnimationManager::GetInstance() + { + return Application::GetInstance()->ResolveSingleton([](auto) + { + return new AnimationManager{}; + }); + } + AnimationManager::AnimationManager() { diff --git a/src/ui/animations/animation.hpp b/src/ui/animations/animation.hpp index 99389f33..f25e4699 100644 --- a/src/ui/animations/animation.hpp +++ b/src/ui/animations/animation.hpp @@ -3,7 +3,6 @@ #include #include "base.hpp" -#include "application.hpp" #include "timer.hpp" namespace cru::ui::animations @@ -53,13 +52,10 @@ namespace cru::ui::animations class AnimationManager : public Object { public: - static AnimationManager* GetInstance() - { - return Application::GetInstance()->GetAnimationManager(); - } - - public: + static AnimationManager* GetInstance(); + private: AnimationManager(); + public: AnimationManager(const AnimationManager& other) = delete; AnimationManager(AnimationManager&& other) = delete; AnimationManager& operator=(const AnimationManager& other) = delete; -- cgit v1.2.3