From 7351020a582d70a1495249fba87d342c8a1fb634 Mon Sep 17 00:00:00 2001 From: crupest Date: Wed, 10 Apr 2019 19:42:46 +0800 Subject: Refactor. --- src/win/native/timer.hpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/win/native/timer.hpp (limited to 'src/win/native/timer.hpp') diff --git a/src/win/native/timer.hpp b/src/win/native/timer.hpp new file mode 100644 index 00000000..f30d9b91 --- /dev/null +++ b/src/win/native/timer.hpp @@ -0,0 +1,34 @@ +#pragma once +#include "cru/win/win_pre_config.hpp" + +#include "cru/common/base.hpp" +#include "cru/win/native/god_window.hpp" + +#include +#include +#include +#include + +namespace cru::win::native { +using TimerAction = std::function; + +class TimerManager : public Object { + public: + TimerManager(GodWindow* god_window); + TimerManager(const TimerManager& other) = delete; + TimerManager(TimerManager&& other) = delete; + TimerManager& operator=(const TimerManager& other) = delete; + TimerManager& operator=(TimerManager&& other) = delete; + ~TimerManager() override = default; + + UINT_PTR CreateTimer(UINT milliseconds, bool loop, const TimerAction& action); + void KillTimer(UINT_PTR id); + std::optional> GetAction(UINT_PTR id); + + private: + GodWindow* god_window_; + + std::map> map_{}; + UINT_PTR current_count_ = 0; +}; +} // namespace cru::win::native -- cgit v1.2.3