Adonthell
0.4
|
Base class for objects that want to register events. More...
#include <event_list.h>
Public Member Functions | |
event_list () | |
Constructor - creates an empty, unpaused event_list. More... | |
virtual | ~event_list () |
Destructor - unregisters and deletes all events owned by this list. More... | |
void | clear () |
Unregisters and deletes all events owned by this list. More... | |
List Operations | |
void | add_event (event *ev) |
Adds an event to this list. More... | |
void | remove_event (event *ev) |
Removes an event from the list. More... | |
event * | get_event (const string &id) |
Try to retrieve the event with given id from the list. More... | |
Pausing / Resuming execution | |
void | pause () |
Disable any events associated with this event_list. More... | |
void | resume () |
Re-enable the events associated with the event_list, thus 'awaking' the object to life again. More... | |
bool | is_paused () const |
Check whether the event list is temporarily disabled or not. More... | |
Loading / Saving | |
void | put_state (ogzstream &out) const |
Save the event_list to a file. More... | |
bool | get_state (igzstream &in) |
Loads the event_list from a file and registers all loaded events. More... | |
Static Public Member Functions | |
static void | register_event (u_int8 type, new_event e) |
Register an event for loading. More... | |
Protected Attributes | |
std::vector< event * > | Events |
List of events. More... | |
Base class for objects that want to register events.
It keeps track of all the events an object has registered with the event_handler and can automatically unregister them when the object is deallocated.
It also provides the functionality to load and save the states of events in its list.
Objects making use of events should use the event_list instead of handling events themselves.
Definition at line 52 of file event_list.h.
event_list::event_list | ( | ) |
Constructor - creates an empty, unpaused event_list.
Definition at line 32 of file event_list.cc.
|
virtual |
Destructor - unregisters and deletes all events owned by this list.
Definition at line 38 of file event_list.cc.
void event_list::clear | ( | ) |
Unregisters and deletes all events owned by this list.
Definition at line 44 of file event_list.cc.
void event_list::add_event | ( | event * | ev) |
Adds an event to this list.
The event will be registered with the event_handler and the list will then take care of it's deletion.
ev | pointer to the event to add. |
Definition at line 58 of file event_list.cc.
void event_list::remove_event | ( | event * | ev) |
Removes an event from the list.
This is usually called when an event is destroyed.
ev | pointer to the event to remove. |
Definition at line 71 of file event_list.cc.
event * event_list::get_event | ( | const string & | id) |
Try to retrieve the event with given id from the list.
Definition at line 83 of file event_list.cc.
void event_list::pause | ( | ) |
Disable any events associated with this event_list.
This will effectively stop all actions of the object the event_list belongs to, e.g. a NPC.
Definition at line 94 of file event_list.cc.
void event_list::resume | ( | ) |
Re-enable the events associated with the event_list, thus 'awaking' the object to life again.
Definition at line 102 of file event_list.cc.
|
inline |
Check whether the event list is temporarily disabled or not.
Definition at line 120 of file event_list.h.
Register an event for loading.
Before the event_list can load an event from file, it needs a callback function that returns a new instance of the event of the given type.
type | the type of the event to register |
e | a callback returning a new instance of an event of the given type. |
Definition at line 110 of file event_list.cc.
void event_list::put_state | ( | ogzstream & | out) | const |
Save the event_list to a file.
out | file where to save the event_list. |
Definition at line 117 of file event_list.cc.
bool event_list::get_state | ( | igzstream & | in) |
Loads the event_list from a file and registers all loaded events.
in | file to load the event_list from. |
Definition at line 129 of file event_list.cc.
|
mutableprotected |
List of events.
Definition at line 171 of file event_list.h.