#include <eventHandler.h>
Inheritance diagram for EventHandler:
Public Types | |
typedef void | EventFunction (CPT_Event) |
typedef void | EventCallbackFunction (ConstPointerTo< Event >, void *) |
Public Member Functions | |
EventHandler (EventQueue *queue) | |
void | process_events () |
The main processing loop of the EventHandler. | |
virtual void | dispatch_event (const CPT_Event &event) |
Calls the hooks assigned to the indicated single event. | |
void | write (ostream &out) const |
bool | add_hook (const string &event_name, EventFunction *function) |
Adds the indicated function to the list of those that will be called when the named event is thrown. | |
bool | add_hook (const string &event_name, EventCallbackFunction *function, void *) |
Adds the indicated function to the list of those that will be called when the named event is thrown. | |
bool | remove_hook (const string &event_name, EventFunction *function) |
Removes the indicated function from the named event hook. | |
bool | remove_hook (const string &event_name, EventCallbackFunction *function, void *) |
Removes the indicated function from the named event hook. | |
void | remove_all_hooks () |
Removes all hooks assigned to all events. | |
virtual TypeHandle | get_type () const |
virtual TypeHandle | force_init_type () |
int | get_type_index () const |
Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. | |
bool | is_of_type (TypeHandle handle) const |
Returns true if the current object is or derives from the indicated type. | |
bool | is_exact_type (TypeHandle handle) const |
Returns true if the current object is the indicated type exactly. | |
Static Public Member Functions | |
TypeHandle | get_class_type () |
void | init_type () |
This function is declared non-inline to work around a compiler bug in g++ 2.96. | |
Protected Types | |
typedef pset< EventFunction * > | Functions |
typedef pmap< string, Functions > | Hooks |
typedef pair< EventCallbackFunction *, void * > | CallbackFunction |
typedef pset< CallbackFunction > | CallbackFunctions |
typedef pmap< string, CallbackFunctions > | CallbackHooks |
Protected Attributes | |
Hooks | _hooks |
CallbackHooks | _cbhooks |
EventQueue & | _queue |
Private Member Functions | |
void | write_hook (ostream &out, const Hooks::value_type &hook) const |
void | write_cbhook (ostream &out, const CallbackHooks::value_type &hook) const |
Static Private Attributes | |
TypeHandle | _type_handle |
It maintains a set of "hooks", function pointers assigned to event names, and calls the appropriate hooks when the matching event is detected.
This class is not necessary when the hooks are detected and processed entirely by the scripting language, e.g. via Scheme hooks.
Definition at line 58 of file eventHandler.h.
|
Definition at line 87 of file eventHandler.h. |
|
Definition at line 88 of file eventHandler.h. |
|
Definition at line 89 of file eventHandler.h. |
|
Definition at line 62 of file eventHandler.h. |
|
Definition at line 61 of file eventHandler.h. |
|
Definition at line 85 of file eventHandler.h. |
|
Definition at line 86 of file eventHandler.h. |
|
Definition at line 36 of file eventHandler.cxx. References _queue, EventQueue::dequeue_event(), dispatch_event(), and EventQueue::is_queue_empty(). |
|
Adds the indicated function to the list of those that will be called when the named event is thrown. Returns true if the function was successfully added, false if it was already defined on the indicated event name. This version records an untyped pointer to user callback data. Definition at line 197 of file eventHandler.cxx. |
|
Adds the indicated function to the list of those that will be called when the named event is thrown. Returns true if the function was successfully added, false if it was already defined on the indicated event name. Definition at line 170 of file eventHandler.cxx. References _hooks. Referenced by event_la(), and AutonomousLerp::stop(). |
|
Calls the hooks assigned to the indicated single event.
Definition at line 71 of file eventHandler.cxx. Referenced by EventHandler(), and throw_event_directly(). |
|
Implements TypedObject. Definition at line 112 of file eventHandler.h. |
|
Reimplemented from TypedObject. Definition at line 101 of file eventHandler.h. |
|
Implements TypedObject. Definition at line 109 of file eventHandler.h. |
|
Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. This is equivalent to get_type().get_index(). Definition at line 71 of file typedObject.I. References TypeHandle::get_name(), TypedObject::get_type(), and INLINE. |
|
This function is declared non-inline to work around a compiler bug in g++ 2.96. Making it inline seems to cause problems in the optimizer. Reimplemented from TypedObject. Definition at line 104 of file eventHandler.h. |
|
Returns true if the current object is the indicated type exactly.
Definition at line 101 of file typedObject.I. Referenced by PT(), and CollisionNode::xform(). |
|
|
The main processing loop of the EventHandler. This function must be called periodically to service events. Walks through each pending event and calls its assigned hooks. Definition at line 54 of file eventHandler.cxx. References _hooks. |
|
Removes all hooks assigned to all events.
Definition at line 251 of file eventHandler.cxx. Referenced by PandaFramework::open_framework(). |
|
Removes the indicated function from the named event hook. Returns true if the hook was removed, false if it wasn't there in the first place. This version takes an untyped pointer to user callback data. Definition at line 236 of file eventHandler.cxx. |
|
Removes the indicated function from the named event hook. Returns true if the hook was removed, false if it wasn't there in the first place. Definition at line 216 of file eventHandler.cxx. |
|
Definition at line 116 of file eventHandler.cxx. |
|
Definition at line 279 of file eventHandler.cxx. |
|
Definition at line 265 of file eventHandler.cxx. |
|
Definition at line 92 of file eventHandler.h. Referenced by add_hook(). |
|
Definition at line 91 of file eventHandler.h. Referenced by add_hook(), and process_events(). |
|
Definition at line 93 of file eventHandler.h. Referenced by EventHandler(). |
|
Reimplemented from TypedObject. Definition at line 26 of file eventHandler.cxx. |