37class EXPCL_PANDA_EVENT EventHandler :
public TypedObject {
40 typedef void EventFunction(
const Event *);
41 typedef void EventCallbackFunction(
const Event *,
void *);
53 void write(std::ostream &out)
const;
58 bool add_hook(
const std::string &event_name, EventFunction *function);
59 bool add_hook(
const std::string &event_name, EventCallbackFunction *function,
61 bool has_hook(
const std::string &event_name)
const;
62 bool has_hook(
const std::string &event_name, EventFunction *function)
const;
63 bool has_hook(
const std::string &event_name, EventCallbackFunction *function,
65 bool remove_hook(
const std::string &event_name, EventFunction *function);
66 bool remove_hook(
const std::string &event_name, EventCallbackFunction *function,
76 typedef pset<EventFunction *> Functions;
77 typedef pmap<std::string, Functions> Hooks;
78 typedef std::pair<EventCallbackFunction*, void*> CallbackFunction;
79 typedef pset<CallbackFunction> CallbackFunctions;
80 typedef pmap<std::string, CallbackFunctions> CallbackHooks;
84 CallbackHooks _cbhooks;
88 static EventHandler *_global_event_handler;
89 static void make_global_event_handler();
92 void write_hook(std::ostream &out,
const Hooks::value_type &hook)
const;
93 void write_cbhook(std::ostream &out,
const CallbackHooks::value_type &hook)
const;
103 TypedObject::get_class_type());
106 return get_class_type();
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This class represents a thread-safe handle to a promised future result of an asynchronous operation,...
void process_events()
The main processing loop of the EventHandler.
bool remove_hooks_with(void *data)
Removes all CallbackFunction hooks that have the indicated pointer as the associated data pointer.
virtual void dispatch_event(const Event *event)
Calls the hooks assigned to the indicated single event.
bool remove_hooks(const std::string &event_name)
Removes all functions from the named event hook.
void remove_all_hooks()
Removes all hooks assigned to all events.
AsyncFuture * get_future(const std::string &event_name)
Returns a pending future that will be marked as done when the event is next fired.
bool remove_hook(const std::string &event_name, EventFunction *function)
Removes the indicated function from the named event hook.
bool has_hook(const std::string &event_name) const
Returns true if there is any hook added on the indicated event name, false otherwise.
bool add_hook(const std::string &event_name, EventFunction *function)
Adds the indicated function to the list of those that will be called when the named event is thrown.
static EventHandler * get_global_event_handler(EventQueue *queue=nullptr)
Returns a pointer to the one global EventHandler object.
A queue of pending events.
A named event, possibly with parameters.
TypeHandle is the identifier used to differentiate C++ class types.
static void init_type()
This function is declared non-inline to work around a compiler bug in g++ 2.96.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...