32 #include <boost/unordered_map.hpp>
37 #define DBG_NG LOG_STREAM(debug, log_engine)
38 #define LOG_NG LOG_STREAM(info, log_engine)
39 #define WRN_NG LOG_STREAM(warn, log_engine)
42 #define DBG_EH LOG_STREAM(debug, log_event_handler)
48 if(
lg::debug().dont_log(
"event_handler"))
return;
55 const config& cfg =
h->get_config();
56 ss <<
"name=" << cfg[
"name"] <<
", with id=" << cfg[
"id"] <<
"; ";
58 DBG_EH <<
"active handlers are now " << ss.str() <<
"\n";
69 size_t name_index = 0;
70 size_t name_size = name.size();
73 while ( name_size > 0 && name[name_size-1] ==
' ' )
77 while ( name_index < name_size && name[name_index] ==
' ' )
81 retval.reserve(name_size - name_index);
82 while ( name_index < name_size ) {
83 char c = name[name_index++];
84 retval.push_back(c ==
' ' ?
'_' : c);
100 return find_it ==
by_name_.end() ? empty_list : find_it->second;
116 if ( find_it !=
id_map_.end() && !find_it->second.expired() ) {
117 DBG_EH <<
"ignoring event handler for name='" << name
118 <<
"' with id '" <<
id <<
"'\n";
124 DBG_EH <<
"inserting event handler for name=" << name <<
125 " with id=" <<
id <<
"\n";
127 active_.push_back(new_handler);
133 std::vector<std::string> name_list =
utils::split(name);
153 DBG_EH <<
"removing event handler with id " <<
id <<
"\n";
157 if ( find_it !=
id_map_.end() ) {
void push_back(const handler_ptr &p)
static thandler * handler
static std::string standardize_name(const std::string &name)
Utility to standardize the event names used in by_name_.
const handler_list & get() const
Read-only access to the handlers with varying event names.
id_map_t id_map_
Active event handlers with variables in their event names.
void add_event_handler(const config &cfg, manager &man, bool is_menu_item=false)
Adds an event handler.
handler_list dynamic_
Active event handlers with fixed event names, organized by event name.
map_t by_name_
Active event handlers. Will not have elements removed unless the t_event_handlers is clear()ed...
This is a wrapper for a list of weak pointers to handlers.
void remove_event_handler(std::string const &id)
Removes an event handler, identified by its ID.
static lg::log_domain log_engine("engine")
Templates and utility-routines for strings and numbers.
void log_handlers()
Allows quick locating of handlers by id.
Define the game's event mechanism.
GLfloat GLfloat GLfloat GLfloat h
The game event manager loads the scenario configuration object, and ensures that events are handled a...
GLuint const GLchar * name
bool might_contain_variables(const std::string &str)
Determines if a string might contain variables to interpolate.
Define the handlers for the game's events mechanism.
Standard logging facilities (interface).
static lg::log_domain log_event_handler("event_handler")
std::vector< std::string > split(std::string const &val, const char c, const int flags)
Splits a (comma-)separated string into a vector of pieces.
A config object defines a single node in a WML file, with access to child nodes.
GLsizei const GLcharARB ** string