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.
|
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 {
|
|
|
|
|
2007-03-17 10:36:14 +00:00
|
|
|
class TimerManager : NonCopyable {
|
2004-08-22 13:27:34 +00:00
|
|
|
public:
|
|
|
|
typedef void (*TimerProc)(void *refCon);
|
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
|
|
|
/**
|
|
|
|
* Install a new timer callback. It will from now be called every interval microseconds.
|
2003-11-07 02:43:47 +00:00
|
|
|
* The timer may 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
|
|
|
|
* may be lower. In particular, with the SDL backend the timer resolution is 10ms.
|
|
|
|
* @param proc the callback
|
|
|
|
* @param interval the interval in which the timer shall be invoked (in microseconds)
|
|
|
|
* @param refCon an arbitrary void pointer; will be passed to the timer callback
|
2011-08-05 09:15:20 +00:00
|
|
|
* @param id unique string id of the installed timer. Used by the event recorder
|
2003-11-01 21:23:48 +00:00
|
|
|
* @return true if the timer was installed successfully, false otherwise
|
|
|
|
*/
|
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
|
|
|
/**
|
2009-02-27 22:19:33 +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
|
|
|
};
|
|
|
|
|
2005-05-10 23:17:38 +00:00
|
|
|
} // End of namespace Common
|
|
|
|
|
2002-08-04 16:30:59 +00:00
|
|
|
#endif
|