comparison engine/core/util/time/timeevent.h @ 0:4a0efb7baf70

* Datasets becomes the new trunk and retires after that :-)
author mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
date Sun, 29 Jun 2008 18:44:17 +0000
parents
children 90005975cdbb
comparison
equal deleted inserted replaced
-1:000000000000 0:4a0efb7baf70
1 /***************************************************************************
2 * Copyright (C) 2005-2008 by the FIFE team *
3 * http://www.fifengine.de *
4 * This file is part of FIFE. *
5 * *
6 * FIFE is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
20 ***************************************************************************/
21
22 #ifndef FIFE_TIMEVENT_H
23 #define FIFE_TIMEVENT_H
24
25 // Standard C++ library includes
26
27 // 3rd party library includes
28
29 // FIFE includes
30 // These includes are split up in two parts, separated by one empty line
31 // First block: files included from the FIFE root src directory
32 // Second block: files included from the same folder
33
34 namespace FIFE {
35
36 /** Interface for events to be registered with TimeManager.
37 *
38 * To register a class with TimeManager firstly derive a class
39 * from this and override the updateEvent() function. updateEvent()
40 * will be called periodically depending on the value of getPeriod()
41 * which can be set using the constructor or setPeriod(). A value
42 * of -1 will never be updated, 0 will updated every frame and a value
43 * over 0 defines the number of milliseconds between updates.
44 *
45 * @see TimeManager
46 */
47 class TimeEvent {
48 public:
49 /** Default constructor.
50 *
51 * @param period The period of the event. See class description.
52 */
53 TimeEvent(int period = -1);
54
55 /** Destructor.
56 *
57 */
58 virtual ~TimeEvent();
59
60 /** Update function to be overridden by client.
61 *
62 * @param time_delta Time.
63 */
64 virtual void updateEvent(unsigned long time) = 0;
65
66 /** Called by TimeManager to update the event.
67 *
68 * @param time Current time. Used To check if its time to update.
69 */
70 void managerUpdateEvent(unsigned long time);
71
72 /** Set the period of the event.
73 *
74 * @param period The period of the event. See class description.
75 */
76 void setPeriod(int period);
77
78 /** Get the period of the event.
79 *
80 * @return The period of the event. See class description.
81 */
82 int getPeriod();
83
84 /** Get the last time the event was updated.
85 *
86 * @return Time of last update.
87 */
88 unsigned long getLastUpdateTime();
89
90 /** Set the last time the event was updated.
91 *
92 * @param Time of last update.
93 */
94 void setLastUpdateTime(unsigned long);
95
96 private:
97 // The period of the event. See the class description.
98 int m_period;
99
100 // The last time the class was updated.
101 unsigned long m_last_updated;
102 };
103
104 }//FIFE
105
106 #endif