Adonthell  0.4
map_event_handler.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002 Kai Sterker <kai.sterker@gmail.com>
3  Part of the Adonthell Project <http://adonthell.nongnu.org>
4 
5  Adonthell is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  Adonthell is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with Adonthell. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 /**
20  * @file map_event_handler.h
21  *
22  * @author Kai Sterker
23  * @brief Declares the map_event_handler class.
24  */
25 
26 #ifndef MAP_EVENT_HANDLER_H__
27 #define MAP_EVENT_HANDLER_H__
28 
29 #include <vector>
30 #include "event_handler_base.h"
31 
32 using std::vector;
33 
34 /**
35  * This class keeps track of map events, i.e. events that are raised
36  * when a character enters or leaves a tile, or initiates an action.
37  */
39 {
40 public:
41  /**
42  * Register a map %event with the %event handler. The %event
43  * needs to be removed before it can be safely 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 'trigger' matches.
59  * Unless they need to be repeated, they are removed from the
60  * %event-vector.
61  *
62  * @param evnt A map_event structure.
63  */
64  void raise_event (const event *evnt);
65 
66 private:
67  // storage for registered time events.
68  vector<event*> Events;
69 };
70 
71 #endif // MAP_EVENT_HANDLER_H__
This is the base class for actual event handlers.
Base class for events.
Definition: event.h:75
This class keeps track of map events, i.e.
Declares the base class for event handlers.
void register_event(event *evnt)
Register a map event with the event handler.
void raise_event(const event *evnt)
Raise one or more events in case the given &#39;trigger&#39; matches.
void remove_event(event *evnt)
Removes the given event from the event handler.