2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
2002-08-04 16:30:59 +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.
|
|
|
|
*
|
|
|
|
* 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
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2014-02-18 01:34:18 +00:00
|
|
|
*
|
2002-08-04 16:30:59 +00:00
|
|
|
*/
|
|
|
|
|
2003-08-01 12:21:04 +00:00
|
|
|
#ifndef COMMON_TIMER_H
|
|
|
|
#define COMMON_TIMER_H
|
2002-08-04 16:30:59 +00:00
|
|
|
|
2003-08-01 12:21:04 +00:00
|
|
|
#include "common/scummsys.h"
|
2011-08-06 14:52:36 +00:00
|
|
|
#include "common/str.h"
|
2007-03-17 10:36:14 +00:00
|
|
|
#include "common/noncopyable.h"
|
2005-01-10 22:06:49 +00:00
|
|
|
|
2005-05-10 23:17:38 +00:00
|
|
|
namespace Common {
|
|
|
|
|
2020-07-08 21:30:36 +00:00
|
|
|
/**
|
|
|
|
* @defgroup common_timer Timer
|
|
|
|
* @ingroup common
|
|
|
|
*
|
|
|
|
* @brief API for managing the timer.
|
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2007-03-17 10:36:14 +00:00
|
|
|
class TimerManager : NonCopyable {
|
2004-08-22 13:27:34 +00:00
|
|
|
public:
|
2020-11-11 18:48:06 +00:00
|
|
|
typedef void (*TimerProc)(void *refCon); /*!< Type definition of a timer instance. */
|
2002-08-04 16:30:59 +00:00
|
|
|
|
2006-06-24 09:53:45 +00:00
|
|
|
virtual ~TimerManager() {}
|
2002-08-04 16:30:59 +00:00
|
|
|
|
2003-11-01 21:23:48 +00:00
|
|
|
/**
|
2020-11-11 18:48:06 +00:00
|
|
|
* Install a new timer callback.
|
|
|
|
*
|
|
|
|
* After it has been created, the timer is called every @p interval microseconds.
|
|
|
|
* The timer can be invoked from a separate thread. Hence any timer code should be
|
2003-11-01 21:23:48 +00:00
|
|
|
* written following the same safety guidelines as any other threaded code.
|
|
|
|
*
|
|
|
|
* @note Although the interval is specified in microseconds, the actual timer resolution
|
2020-11-11 18:48:06 +00:00
|
|
|
* may be lower. In particular, with the SDL backend the timer resolution is 10 ms.
|
|
|
|
*
|
|
|
|
* @param proc Callback.
|
|
|
|
* @param interval Interval in which the timer shall be invoked (in microseconds).
|
|
|
|
* @param refCon Arbitrary void pointer passed to the timer callback.
|
|
|
|
* @param id Unique string ID of the installed timer. Used by the event recorder.
|
|
|
|
*
|
|
|
|
* @return True if the timer was installed successfully, false otherwise.
|
2003-11-01 21:23:48 +00:00
|
|
|
*/
|
2011-08-05 09:15:20 +00:00
|
|
|
virtual bool installTimerProc(TimerProc proc, int32 interval, void *refCon, const Common::String &id) = 0;
|
2003-11-08 22:43:46 +00:00
|
|
|
|
2003-11-01 21:23:48 +00:00
|
|
|
/**
|
2020-11-11 18:48:06 +00:00
|
|
|
* Remove the given timer callback.
|
|
|
|
*
|
|
|
|
* It will not be invoked anymore, and no instance
|
|
|
|
* of this callback will be running anymore.
|
2003-11-01 21:23:48 +00:00
|
|
|
*/
|
2006-06-24 09:53:45 +00:00
|
|
|
virtual void removeTimerProc(TimerProc proc) = 0;
|
2002-08-04 16:30:59 +00:00
|
|
|
};
|
|
|
|
|
2020-07-08 21:30:36 +00:00
|
|
|
/** @} */
|
|
|
|
|
2005-05-10 23:17:38 +00:00
|
|
|
} // End of namespace Common
|
|
|
|
|
2002-08-04 16:30:59 +00:00
|
|
|
#endif
|