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 /** 33 * @defgroup common_timer Timer 34 * @ingroup common 35 * 36 * @brief API for managing the timer. 37 * 38 * @{ 39 */ 40 41 class TimerManager : NonCopyable { 42 public: 43 typedef void (*TimerProc)(void *refCon); /*!< Type definition of a timer instance. */ 44 ~TimerManager()45 virtual ~TimerManager() {} 46 47 /** 48 * Install a new timer callback. 49 * 50 * After it has been created, the timer is called every @p interval microseconds. 51 * The timer can be invoked from a separate thread. Hence any timer code should be 52 * written following the same safety guidelines as any other threaded code. 53 * 54 * @note Although the interval is specified in microseconds, the actual timer resolution 55 * may be lower. In particular, with the SDL backend the timer resolution is 10 ms. 56 * 57 * @param proc Callback. 58 * @param interval Interval in which the timer shall be invoked (in microseconds). 59 * @param refCon Arbitrary void pointer passed to the timer callback. 60 * @param id Unique string ID of the installed timer. Used by the event recorder. 61 * 62 * @return True if the timer was installed successfully, false otherwise. 63 */ 64 virtual bool installTimerProc(TimerProc proc, int32 interval, void *refCon, const Common::String &id) = 0; 65 66 /** 67 * Remove the given timer callback. 68 * 69 * It will not be invoked anymore, and no instance 70 * of this callback will be running anymore. 71 */ 72 virtual void removeTimerProc(TimerProc proc) = 0; 73 }; 74 75 /** @} */ 76 77 } // End of namespace Common 78 79 #endif 80