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

This class is similar to an input iterator through event handlers, except each instance knows its own end (determined when constructed). More...

#include <manager.hpp>

Public Member Functions

 iteration (const std::string &event_name, manager &)
 Event-specific constructor. More...
 
iterationoperator++ ()
 Increment Incrementing guarantees that the next dereference will differ from the previous derference (unless the iteration is exhausted). More...
 
handler_ptr operator* ()
 Dereference Will return a null pointer when the end of the iteration is reached. More...
 

Private Member Functions

handler_vec::size_type ptr_index (const handler_ptr &ptr) const
 Gets the index from a pointer, capped at end_. More...
 

Private Attributes

const handler_listmain_list_
 The fixed-name event handlers for this iteration. More...
 
const handler_listvar_list_
 The varying-name event handlers for this iteration. More...
 
const std::string event_name_
 The event name for this iteration. More...
 
const handler_vec::size_type end_
 The end of this iteration. More...
 
bool current_is_known_
 Set to true upon dereferencing. More...
 
bool main_is_current_
 true if the most recent dereference was taken from main_list_. More...
 
handler_list::iterator main_it_
 The current (or next) element from main_list_. More...
 
handler_list::iterator var_it_
 The current (or next) element from var_list_. More...
 
game_datagamedata_
 

Detailed Description

This class is similar to an input iterator through event handlers, except each instance knows its own end (determined when constructed).

Subsequent dereferences are not guaranteed to return the same element, so it is important to assign a dereference to a variable if you want to use it more than once. On the other hand, a dereference will not return a null pointer until the end of the iteration is reached (and this is how to detect the end of the iteration).

For simplicity, this class is neither assignable nor equality comparable nor default constructable, and there is no postincrement. Typedefs are also skipped.

Definition at line 60 of file manager.hpp.

Constructor & Destructor Documentation

game_events::manager::iteration::iteration ( const std::string event_name,
manager man 
)
explicit

Event-specific constructor.

This iteration will go through all event handlers matching the given name (including those defined via menu items). An empty event_name will automatically match nothing.

Definition at line 96 of file manager.cpp.

Member Function Documentation

handler_ptr game_events::manager::iteration::operator* ( )

Dereference Will return a null pointer when the end of the iteration is reached.

Definition at line 140 of file manager.cpp.

manager::iteration & game_events::manager::iteration::operator++ ( )

Increment Incrementing guarantees that the next dereference will differ from the previous derference (unless the iteration is exhausted).

However, multiple increments between dereferences are allowed to have the same effect as a single increment.

Definition at line 116 of file manager.cpp.

handler_vec::size_type game_events::manager::iteration::ptr_index ( const handler_ptr ptr) const
inlineprivate

Gets the index from a pointer, capped at end_.

Definition at line 73 of file manager.hpp.

References end_.

Member Data Documentation

bool game_events::manager::iteration::current_is_known_
private

Set to true upon dereferencing.

Definition at line 88 of file manager.hpp.

const handler_vec::size_type game_events::manager::iteration::end_
private

The end of this iteration.

We intentionally exclude handlers added after *this is constructed.

Definition at line 85 of file manager.hpp.

Referenced by ptr_index().

const std::string game_events::manager::iteration::event_name_
private

The event name for this iteration.

Definition at line 82 of file manager.hpp.

game_data* game_events::manager::iteration::gamedata_
private

Definition at line 96 of file manager.hpp.

bool game_events::manager::iteration::main_is_current_
private

true if the most recent dereference was taken from main_list_.

Definition at line 90 of file manager.hpp.

handler_list::iterator game_events::manager::iteration::main_it_
private

The current (or next) element from main_list_.

Definition at line 92 of file manager.hpp.

const handler_list& game_events::manager::iteration::main_list_
private

The fixed-name event handlers for this iteration.

Definition at line 78 of file manager.hpp.

handler_list::iterator game_events::manager::iteration::var_it_
private

The current (or next) element from var_list_.

Definition at line 94 of file manager.hpp.

const handler_list& game_events::manager::iteration::var_list_
private

The varying-name event handlers for this iteration.

Definition at line 80 of file manager.hpp.


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