1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef COMMON_TIMER_H 24 #define COMMON_TIMER_H 25 26 #include "common/scummsys.h" 27 #include "common/str.h" 28 #include "common/noncopyable.h" 29 30 namespace Common { 31 32 class TimerManager : NonCopyable { 33 public: 34 typedef void (*TimerProc)(void *refCon); 35 ~TimerManager()36 virtual ~TimerManager() {} 37 38 /** 39 * Install a new timer callback. It will from now be called every interval microseconds. 40 * The timer may be invoked from a separate thread. Hence any timer code should be 41 * written following the same safety guidelines as any other threaded code. 42 * 43 * @note Although the interval is specified in microseconds, the actual timer resolution 44 * may be lower. In particular, with the SDL backend the timer resolution is 10ms. 45 * @param proc the callback 46 * @param interval the interval in which the timer shall be invoked (in microseconds) 47 * @param refCon an arbitrary void pointer; will be passed to the timer callback 48 * @param id unique string id of the installed timer. Used by the event recorder 49 * @return true if the timer was installed successfully, false otherwise 50 */ 51 virtual bool installTimerProc(TimerProc proc, int32 interval, void *refCon, const Common::String &id) = 0; 52 53 /** 54 * Remove the given timer callback. It will not be invoked anymore, 55 * and no instance of this callback will be running anymore. 56 */ 57 virtual void removeTimerProc(TimerProc proc) = 0; 58 }; 59 60 } // End of namespace Common 61 62 #endif 63