]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/timer.h
Removed unused check for valid channel name - if it's invalid, it won't exist in...
[user/henk/code/inspircd.git] / include / timer.h
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
6  *                       E-mail:
7  *                <brain@chatspike.net>
8  *                <Craig@chatspike.net>
9  *
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *            the file COPYING for details.
13  *
14  * ---------------------------------------------------
15  */
16
17 /** Timer class for one-second resolution timers
18  * InspTimer provides a facility which allows module
19  * developers to create one-shot timers. The timer
20  * can be made to trigger at any time up to a one-second
21  * resolution. To use InspTimer, inherit a class from
22  * InspTimer, then insert your inherited class into the
23  * queue using Server::AddTimer(). The Tick() method of
24  * your object (which you should override) will be called
25  * at the given time.
26  */
27 class InspTimer
28 {
29  private:
30         /** The triggering time
31          */
32         time_t trigger;
33  public:
34         /** Default constructor, initializes the triggering time
35          */
36         InspTimer(long secs_from_now,time_t now)
37         {
38                 trigger = now + secs_from_now;
39         }
40         /** Default destructor, does nothing.
41          */
42         virtual ~InspTimer() { }
43         /** Retrieve the current triggering time
44          */
45         virtual time_t GetTimer()
46         {
47                 return trigger;
48         }
49         /** Called when the timer ticks.
50          */
51         virtual void Tick(time_t TIME) = 0;
52 };
53
54 void TickTimers(time_t TIME);
55 void AddTimer(InspTimer* T);
56 void TickMissedTimers(time_t TIME);
57