22 #include <unordered_map>
59 using map_t = std::unordered_map<std::string, handler_list>;
60 using id_map_t = std::unordered_map<std::string, weak_handler_ptr>;
map_t by_name_
Active event handlers with fixed event names, organized by event name.
void finish_adding_event_handler(const handler_ptr &new_handler)
void clean_up_expired_handlers(const std::string &event_name)
Removes all expired event handlers and any weak_ptrs to them.
static bool cmp(const handler_ptr &lhs, const handler_ptr &rhs)
Compare function to sort event handlers by priority.
friend pending_event_handler
handler_list & get_dynamic()
Access to the handlers with varying event names.
const handler_queue_t & get_active() const
Read-only access to the active event handlers.
std::size_t size() const
The number of active event handlers.
handler_queue_t & get_active()
void remove_event_handler(const std::string &id)
Removes an event handler, identified by its ID.
pending_event_handler add_event_handler(const std::string &name, const std::string &id, bool repeat, double priority=0., bool is_menu_item=false)
Adds an event handler.
std::deque< handler_ptr > handler_queue_t
std::unordered_map< std::string, weak_handler_ptr > id_map_t
std::unordered_map< std::string, handler_list > map_t
handler_list dynamic_
Active event handlers with variables in their event names.
id_map_t id_map_
Allows quick locating of handlers by id.
const handler_ptr get_event_handler_by_id(const std::string &id)
Gets an event handler, identified by its ID.
handler_queue_t active_
Active event handlers.
static std::string standardize_name(const std::string &name)
Utility to standardize the event names used in by_name_.
Represents a handler that is about to be added to the events manager but is still waiting for some da...
pending_event_handler & operator=(pending_event_handler &&)=delete
pending_event_handler & operator=(const pending_event_handler &)=delete
pending_event_handler(pending_event_handler &&)=default
pending_event_handler(const pending_event_handler &)=delete
pending_event_handler(event_handlers &list, handler_ptr handler)
event_handler & operator*()
bool valid() const
Check if this handler is valid.
event_handler * operator->()
Access the event handler.
Definitions for the interface to Wesnoth Markup Language (WML).
std::list< weak_handler_ptr > handler_list
std::shared_ptr< event_handler > handler_ptr