The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Types | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
game_events::t_event_handlers Class Reference

#include <manager_impl.hpp>

Public Types

typedef handler_vec::iterator iterator
 
typedef handler_vec::const_iterator const_iterator
 
typedef handler_vec::size_type size_type
 

Public Member Functions

 t_event_handlers ()
 
const handler_listget () const
 Read-only access to the handlers with varying event names. More...
 
const handler_listget (const std::string &name) const
 Read-only access to the handlers with fixed event names, by event name. More...
 
void add_event_handler (const config &cfg, manager &man, bool is_menu_item=false)
 Adds an event handler. More...
 
void remove_event_handler (std::string const &id)
 Removes an event handler, identified by its ID. More...
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
size_type size () const
 The number of active event handlers. More...
 
handler_ptroperator[] (size_type index)
 Access to active event handlers by index. More...
 

Private Types

typedef boost::unordered_map
< std::string, handler_list
map_t
 
typedef boost::unordered_map
< std::string, boost::weak_ptr
< event_handler > > 
id_map_t
 

Private Member Functions

void log_handlers ()
 Allows quick locating of handlers by id. More...
 

Static Private Member Functions

static std::string standardize_name (const std::string &name)
 Utility to standardize the event names used in by_name_. More...
 

Private Attributes

handler_vec active_
 
map_t by_name_
 Active event handlers. Will not have elements removed unless the t_event_handlers is clear()ed. More...
 
handler_list dynamic_
 Active event handlers with fixed event names, organized by event name. More...
 
id_map_t id_map_
 Active event handlers with variables in their event names. More...
 

Detailed Description

Definition at line 29 of file manager_impl.hpp.

Member Typedef Documentation

typedef handler_vec::const_iterator game_events::t_event_handlers::const_iterator

Definition at line 35 of file manager_impl.hpp.

typedef boost::unordered_map<std::string, boost::weak_ptr<event_handler> > game_events::t_event_handlers::id_map_t
private

Definition at line 31 of file manager_impl.hpp.

typedef handler_vec::iterator game_events::t_event_handlers::iterator

Definition at line 34 of file manager_impl.hpp.

typedef boost::unordered_map<std::string, handler_list> game_events::t_event_handlers::map_t
private

Definition at line 30 of file manager_impl.hpp.

typedef handler_vec::size_type game_events::t_event_handlers::size_type

Definition at line 49 of file manager_impl.hpp.

Constructor & Destructor Documentation

game_events::t_event_handlers::t_event_handlers ( )
inline

Definition at line 51 of file manager_impl.hpp.

Member Function Documentation

void game_events::t_event_handlers::add_event_handler ( const config cfg,
manager man,
bool  is_menu_item = false 
)

Adds an event handler.

An event with a nonempty ID will not be added if an event with that ID already exists.

Definition at line 108 of file manager_impl.cpp.

References active_, by_name_, DBG_EH, dynamic_, id_map_, log_handlers(), utils::might_contain_variables(), game_events::handler_list::push_back(), utils::split(), and standardize_name().

iterator game_events::t_event_handlers::begin ( )
inline

Definition at line 68 of file manager_impl.hpp.

const_iterator game_events::t_event_handlers::begin ( ) const
inline

Definition at line 69 of file manager_impl.hpp.

iterator game_events::t_event_handlers::end ( )
inline

Definition at line 71 of file manager_impl.hpp.

const_iterator game_events::t_event_handlers::end ( ) const
inline

Definition at line 72 of file manager_impl.hpp.

const handler_list& game_events::t_event_handlers::get ( ) const
inline

Read-only access to the handlers with varying event names.

Definition at line 59 of file manager_impl.hpp.

References dynamic_.

const handler_list & game_events::t_event_handlers::get ( const std::string name) const

Read-only access to the handlers with fixed event names, by event name.

Definition at line 93 of file manager_impl.cpp.

References by_name_, and standardize_name().

void game_events::t_event_handlers::log_handlers ( )
private

Allows quick locating of handlers by id.

Definition at line 46 of file manager_impl.cpp.

References active_, DBG_EH, and lg::debug().

Referenced by add_event_handler(), and remove_event_handler().

handler_ptr& game_events::t_event_handlers::operator[] ( size_type  index)
inline

Access to active event handlers by index.

Definition at line 77 of file manager_impl.hpp.

void game_events::t_event_handlers::remove_event_handler ( std::string const &  id)

Removes an event handler, identified by its ID.

Events with empty IDs cannot be removed.

Definition at line 148 of file manager_impl.cpp.

References DBG_EH, gui2::event::handler, id_map_, and log_handlers().

size_type game_events::t_event_handlers::size ( ) const
inline

The number of active event handlers.

Definition at line 75 of file manager_impl.hpp.

std::string game_events::t_event_handlers::standardize_name ( const std::string name)
staticprivate

Utility to standardize the event names used in by_name_.

This means stripping leading and trailing spaces, and converting internal spaces to underscores.

Definition at line 66 of file manager_impl.cpp.

Referenced by add_event_handler(), and get().

Member Data Documentation

handler_vec game_events::t_event_handlers::active_
private

Definition at line 38 of file manager_impl.hpp.

Referenced by add_event_handler(), and log_handlers().

map_t game_events::t_event_handlers::by_name_
private

Active event handlers. Will not have elements removed unless the t_event_handlers is clear()ed.

Definition at line 39 of file manager_impl.hpp.

Referenced by add_event_handler(), and get().

handler_list game_events::t_event_handlers::dynamic_
private

Active event handlers with fixed event names, organized by event name.

Definition at line 40 of file manager_impl.hpp.

Referenced by add_event_handler(), and get().

id_map_t game_events::t_event_handlers::id_map_
private

Active event handlers with variables in their event names.

Definition at line 41 of file manager_impl.hpp.

Referenced by add_event_handler(), and remove_event_handler().


The documentation for this class was generated from the following files: