Files
test/intern/ghost/intern/GHOST_TimerTask.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

181 lines
3.9 KiB
C
Raw Normal View History

2011-02-25 11:28:33 +00:00
/*
2002-10-12 11:37:38 +00:00
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
2002-10-12 11:37:38 +00:00
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
2010-02-12 13:34:04 +00:00
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2002-10-12 11:37:38 +00:00
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
*/
2011-02-25 11:28:33 +00:00
/** \file
* \ingroup GHOST
* Declaration of GHOST_TimerTask class.
2002-10-12 11:37:38 +00:00
*/
#pragma once
2002-10-12 11:37:38 +00:00
#include "GHOST_ITimerTask.h"
/**
* Implementation of a timer task.
*/
class GHOST_TimerTask : public GHOST_ITimerTask {
public:
/**
* Constructor.
* \param start: The timer start time.
* \param interval: The interval between calls to the #timerProc.
* \param timerProc: The callback invoked when the interval expires.
2015-07-01 16:30:26 +10:00
* \param userData: The timer user data.
2002-10-12 11:37:38 +00:00
*/
GHOST_TimerTask(uint64_t start,
uint64_t interval,
2011-12-24 02:32:08 +00:00
GHOST_TimerProcPtr timerProc,
2013-03-08 06:32:00 +00:00
GHOST_TUserDataPtr userData = NULL)
2011-12-24 02:32:08 +00:00
: m_start(start),
2012-05-19 09:23:08 +00:00
m_interval(interval),
m_next(start),
m_timerProc(timerProc),
m_userData(userData),
m_auxData(0)
2002-10-12 11:37:38 +00:00
{
}
2002-10-12 11:37:38 +00:00
/**
* Returns the timer start time.
* \return The timer start time.
2002-10-12 11:37:38 +00:00
*/
inline uint64_t getStart() const
2002-10-12 11:37:38 +00:00
{
return m_start;
}
2002-10-12 11:37:38 +00:00
/**
* Changes the timer start time.
* \param start: The timer start time.
2002-10-12 11:37:38 +00:00
*/
void setStart(uint64_t start)
2018-06-04 18:47:57 +02:00
{
2002-10-12 11:37:38 +00:00
m_start = start;
}
2002-10-12 11:37:38 +00:00
/**
* Returns the timer interval.
* \return The timer interval.
2002-10-12 11:37:38 +00:00
*/
inline uint64_t getInterval() const
2002-10-12 11:37:38 +00:00
{
return m_interval;
}
2002-10-12 11:37:38 +00:00
/**
* Changes the timer interval.
* \param interval: The timer interval.
2002-10-12 11:37:38 +00:00
*/
void setInterval(uint64_t interval)
2018-06-04 18:47:57 +02:00
{
2002-10-12 11:37:38 +00:00
m_interval = interval;
}
2002-10-12 11:37:38 +00:00
/**
* Returns the time the timerProc will be called.
* \return The time the timerProc will be called.
2002-10-12 11:37:38 +00:00
*/
inline uint64_t getNext() const
2002-10-12 11:37:38 +00:00
{
return m_next;
}
2002-10-12 11:37:38 +00:00
/**
* Changes the time the timerProc will be called.
* \param next: The time the timerProc will be called.
2002-10-12 11:37:38 +00:00
*/
void setNext(uint64_t next)
2018-06-04 18:47:57 +02:00
{
2002-10-12 11:37:38 +00:00
m_next = next;
}
2002-10-12 11:37:38 +00:00
/**
* Returns the timer callback.
* \return the timer callback.
2002-10-12 11:37:38 +00:00
*/
inline GHOST_TimerProcPtr getTimerProc() const
2002-10-12 11:37:38 +00:00
{
return m_timerProc;
}
2002-10-12 11:37:38 +00:00
/**
* Changes the timer callback.
2015-07-01 16:30:26 +10:00
* \param timerProc: The timer callback.
2002-10-12 11:37:38 +00:00
*/
inline void setTimerProc(const GHOST_TimerProcPtr timerProc)
2002-10-12 11:37:38 +00:00
{
m_timerProc = timerProc;
}
2002-10-12 11:37:38 +00:00
/**
* Returns the timer user data.
* \return The timer user data.
2002-10-12 11:37:38 +00:00
*/
inline GHOST_TUserDataPtr getUserData() const
2002-10-12 11:37:38 +00:00
{
return m_userData;
}
2002-10-12 11:37:38 +00:00
/**
* Changes the time user data.
2015-07-01 16:30:26 +10:00
* \param userData: The timer user data.
2002-10-12 11:37:38 +00:00
*/
void setUserData(const GHOST_TUserDataPtr userData)
2002-10-12 11:37:38 +00:00
{
m_userData = userData;
}
2002-10-12 11:37:38 +00:00
/**
* Returns the auxiliary storage room.
* \return The auxiliary storage room.
2002-10-12 11:37:38 +00:00
*/
inline uint32_t getAuxData() const
2002-10-12 11:37:38 +00:00
{
return m_auxData;
}
2002-10-12 11:37:38 +00:00
/**
* Changes the auxiliary storage room.
* \param auxData: The auxiliary storage room.
2002-10-12 11:37:38 +00:00
*/
void setAuxData(uint32_t auxData)
2018-06-04 18:47:57 +02:00
{
2002-10-12 11:37:38 +00:00
m_auxData = auxData;
}
2002-10-12 11:37:38 +00:00
protected:
/** The time the timer task was started. */
uint64_t m_start;
2002-10-12 11:37:38 +00:00
/** The interval between calls. */
uint64_t m_interval;
2002-10-12 11:37:38 +00:00
/** The time the timerProc will be called. */
uint64_t m_next;
2002-10-12 11:37:38 +00:00
/** The callback invoked when the timer expires. */
GHOST_TimerProcPtr m_timerProc;
2002-10-12 11:37:38 +00:00
/** The timer task user data. */
GHOST_TUserDataPtr m_userData;
2002-10-12 11:37:38 +00:00
/** Auxiliary storage room. */
uint32_t m_auxData;
2002-10-12 11:37:38 +00:00
};