#include <undo_action.hpp>
Classes | |
struct | subaction_factory |
Public Types | |
using | t_factory = std::function< t_step_ptr(const config &)> |
using | t_factory_map = std::map< std::string, t_factory > |
Public Member Functions | |
undo_action_container () | |
bool | empty () const |
t_steps & | steps () |
bool | undo (int side) |
void | write (config &cfg) |
void | read (const config &cfg) |
Creates the list of undo steps based on a config. More... | |
void | add (t_step_ptr &&action) |
void | set_unit_id_diff (int id_diff) |
Static Public Member Functions | |
static t_factory_map & | get_factories () |
Private Types | |
using | t_step_ptr = std::unique_ptr< undo_action > |
using | t_steps = std::vector< t_step_ptr > |
Private Attributes | |
t_steps | steps_ |
int | unit_id_diff_ |
Definition at line 30 of file undo_action.hpp.
using actions::undo_action_container::t_factory = std::function<t_step_ptr(const config&)> |
Definition at line 57 of file undo_action.hpp.
using actions::undo_action_container::t_factory_map = std::map<std::string, t_factory> |
Definition at line 58 of file undo_action.hpp.
|
private |
Definition at line 32 of file undo_action.hpp.
|
private |
Definition at line 33 of file undo_action.hpp.
actions::undo_action_container::undo_action_container | ( | ) |
Definition at line 40 of file undo_action.cpp.
void actions::undo_action_container::add | ( | t_step_ptr && | action | ) |
|
inline |
Definition at line 42 of file undo_action.hpp.
References steps_.
|
static |
Definition at line 79 of file undo_action.cpp.
Referenced by read(), and actions::undo_action_container::subaction_factory< T >::subaction_factory().
void actions::undo_action_container::read | ( | const config & | cfg | ) |
Creates the list of undo steps based on a config.
Throws bad_lexical_cast or config::error if it cannot parse the config properly.
Definition at line 65 of file undo_action.cpp.
References add(), config::child_range(), and get_factories().
|
inline |
Definition at line 52 of file undo_action.hpp.
References unit_id_diff_.
|
inline |
Definition at line 43 of file undo_action.hpp.
References steps_.
bool actions::undo_action_container::undo | ( | int | side | ) |
Definition at line 46 of file undo_action.cpp.
References ERR_NG, resources::gameboard, n_unit::id_manager::get_save_id(), utils::reversed_view(), n_unit::id_manager::set_save_id(), steps_, unit_id_diff_, and game_board::unit_id_manager().
void actions::undo_action_container::write | ( | config & | cfg | ) |
Definition at line 72 of file undo_action.cpp.
References config::add_child(), and steps_.
|
private |
|
private |
Definition at line 36 of file undo_action.hpp.
Referenced by set_unit_id_diff(), and undo().