Adonthell
0.4
Main Page
Related Pages
Classes
Files
File List
File Members
time_event_handler.h
Go to the documentation of this file.
1
/*
2
$Id: time_event_handler.h,v 1.4 2002/08/18 19:53:17 ksterker Exp $
3
4
Copyright (C) 2002 Kai Sterker <kaisterker@linuxgames.com>
5
Part of the Adonthell Project http://adonthell.linuxgames.com
6
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY.
11
12
See the COPYING file for more details.
13
*/
14
15
/**
16
* @file time_event_handler.h
17
*
18
* @author Kai Sterker
19
* @brief Declares the time_event_handler class.
20
*/
21
22
#ifndef TIME_EVENT_HANDLER_H__
23
#define TIME_EVENT_HANDLER_H__
24
25
#include <vector>
26
#include "
event_handler_base.h
"
27
28
using
std::vector;
29
30
/**
31
* This class keeps track of time events, i.e. events that are raised
32
* at a certain point in (%game) time. All registered events are
33
* sorted by the time they need to be raised, so that only one
34
* comparison decides upon whether an %event is to be raised.
35
*/
36
class
time_event_handler
:
public
event_handler_base
37
{
38
public
:
39
/**
40
* Register a time %event with the %event handler. It is inserted
41
* into the vector of registered events depending on its "alarm"
42
* time. The %event needs to be removed before it can be safely
43
* deleted.
44
*
45
* @param evnt Pointer to the %event to be registered.
46
*/
47
void
register_event
(
event
*evnt);
48
49
/**
50
* Removes the given %event from the %event handler. Once it is
51
* no longer needed, it can be freed.
52
*
53
* @param evnt Pointer to the %event to be removed.
54
*/
55
void
remove_event
(
event
*evnt);
56
57
/**
58
* Raise one or more events in case the given time matches their
59
* "alarm" time. When they need to be repeated, they are
60
* re-inserted into the %event-vector.
61
*
62
* @param evnt An %event structure with the current %game time in
63
* minutes.
64
*/
65
void
raise_event
(
const
event
*evnt);
66
67
private
:
68
// storage for registered time events.
69
vector<event*> Events;
70
};
71
72
#endif // TIME_EVENT_HANDLER_H__
src
time_event_handler.h
Generated by
1.8.1.1