2019-04-11 22:09:45 +00:00
|
|
|
#include <LibCore/CTimer.h>
|
2019-03-30 20:40:27 +00:00
|
|
|
|
2019-04-11 22:09:45 +00:00
|
|
|
CTimer::CTimer(CObject* parent)
|
2019-04-10 15:01:54 +00:00
|
|
|
: CObject(parent)
|
2019-03-30 20:40:27 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-04-11 22:09:45 +00:00
|
|
|
CTimer::~CTimer()
|
2019-03-30 20:40:27 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-04-11 22:09:45 +00:00
|
|
|
void CTimer::start()
|
2019-03-30 20:40:27 +00:00
|
|
|
{
|
|
|
|
start(m_interval);
|
|
|
|
}
|
|
|
|
|
2019-04-11 22:09:45 +00:00
|
|
|
void CTimer::start(int interval)
|
2019-03-30 20:40:27 +00:00
|
|
|
{
|
|
|
|
if (m_active)
|
|
|
|
return;
|
|
|
|
start_timer(interval);
|
|
|
|
m_active = true;
|
|
|
|
}
|
|
|
|
|
2019-04-11 22:09:45 +00:00
|
|
|
void CTimer::stop()
|
2019-03-30 20:40:27 +00:00
|
|
|
{
|
|
|
|
if (!m_active)
|
|
|
|
return;
|
|
|
|
stop_timer();
|
|
|
|
m_active = false;
|
|
|
|
}
|
|
|
|
|
2019-04-11 22:09:45 +00:00
|
|
|
void CTimer::timer_event(CTimerEvent&)
|
2019-03-30 20:40:27 +00:00
|
|
|
{
|
|
|
|
if (m_single_shot)
|
|
|
|
stop();
|
|
|
|
if (on_timeout)
|
|
|
|
on_timeout();
|
|
|
|
}
|