aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/Time/Timer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libjin/Time/Timer.cpp')
-rw-r--r--src/libjin/Time/Timer.cpp100
1 files changed, 0 insertions, 100 deletions
diff --git a/src/libjin/Time/Timer.cpp b/src/libjin/Time/Timer.cpp
deleted file mode 100644
index cfdb4bd..0000000
--- a/src/libjin/Time/Timer.cpp
+++ /dev/null
@@ -1,100 +0,0 @@
-#include "../modules.h"
-#if JIN_MODULES_TIME
-
-#include "Timer.h"
-
-namespace jin
-{
-namespace time
-{
-
-
- Timers::Timers()
- : timers()
- {
- }
-
- Timers::~Timers()
- {
- for (int i = 0; i < timers.size(); ++i)
- delete timers[i];
- }
-
- void Timers::update(int ms)
- {
- std::vector<Timer*>::iterator it = timers.begin();
- for (; it != timers.end(); )
- {
- if (!(*it)->process(ms))
- {
- Timer* t = *it;
- timers.erase(it);
- delete t;
- return;
- }
- ++it;
- }
- }
-
- void Timers::every(int ms, timer_callback callback, void* p)
- {
- Timer* t = new Timer(Timer::EVERY, ms, 0, callback, p);
- timers.push_back(t);
- }
-
- void Timers::after(int ms, timer_callback callback, void* p)
- {
- Timer* t = new Timer(Timer::AFTER, ms, 0, callback, p);
- timers.push_back(t);
- }
-
- void Timers::repeat(int ms, int count, timer_callback callback, void* p)
- {
- Timer* t = new Timer(Timer::REPEAT, ms, count, callback, p);
- timers.push_back(t);
- }
-
- Timers::Timer::Timer(Type t, int d, int c, timer_callback f, void* p)
- : type(t)
- , duration(d)
- , count(c)
- , tickdown(d)
- , countdown(c)
- , callback(f)
- , paramters(p)
- {
- }
-
- Timers::Timer::~Timer()
- {
- }
-
- bool Timers::Timer::process(int ms)
- {
- tickdown -= ms;
- if (tickdown <= 0)
- {
- tickdown = duration;
- if (callback != nullptr)
- callback(paramters);
- if (type == EVERY)
- {
- }
- else if (type == AFTER)
- {
- return false;
- }
- else if (type == REPEAT)
- {
- --countdown;
- if (countdown <= 0)
- return false;
- }
- }
- return true;
- }
-
-}
-}
-
-#endif // JIN_MODULES_TIME \ No newline at end of file