Container action wrapping several actions into one. More...
#include <action.hpp>
Public Member Functions | |
editor_action_chain () | |
Create an empty action chain. More... | |
editor_action_chain (const editor_action_chain &other) | |
editor_action_chain & | operator= (const editor_action_chain &other) |
std::unique_ptr< editor_action > | clone () const override |
Inherited from editor_action, implemented by IMPLEMENT_ACTION. More... | |
editor_action_chain (std::deque< std::unique_ptr< editor_action >> actions) | |
Create an action chain from a deque of action pointers. More... | |
~editor_action_chain () override=default | |
The destructor deletes all the owned action pointers. More... | |
int | action_count () const override |
Go through the chain and add up all the action counts. More... | |
void | append_action (std::unique_ptr< editor_action > a) |
Add an action at the end of the chain. More... | |
void | prepend_action (std::unique_ptr< editor_action > a) |
Add an action at the beginning of the chain. More... | |
bool | empty () const |
std::unique_ptr< editor_action > | pop_last_action () |
Remove the last added action and return it, transferring ownership to the caller. More... | |
std::unique_ptr< editor_action > | pop_first_action () |
Remove the first added action and return it, transferring ownership to the caller. More... | |
std::unique_ptr< editor_action > | perform (map_context &m) const override |
Perform all the actions in order and create a undo action chain. More... | |
void | perform_without_undo (map_context &m) const override |
Perform all the actions in order. More... | |
const std::string & | get_name () const override |
Public Member Functions inherited from editor::editor_action | |
editor_action () | |
virtual | ~editor_action () |
virtual std::string | get_description () const |
A textual description of the action. More... | |
int | get_id () const |
Debugging aid. More... | |
Protected Attributes | |
std::deque< std::unique_ptr< editor_action > > | actions_ |
The action pointers owned by this action chain. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from editor::editor_action | |
static int | get_instance_count () |
Debugging aid. More... | |
Container action wrapping several actions into one.
The actions are performed in the order they are added, i.e. in the usual iteration order through the container.
Definition at line 87 of file action.hpp.
|
inline |
Create an empty action chain.
Definition at line 93 of file action.hpp.
editor::editor_action_chain::editor_action_chain | ( | const editor_action_chain & | other | ) |
Definition at line 78 of file action.cpp.
References actions_.
|
inlineexplicit |
Create an action chain from a deque of action pointers.
Note: the action chain assumes ownership of the pointers.
Definition at line 109 of file action.hpp.
|
overridedefault |
The destructor deletes all the owned action pointers.
|
overridevirtual |
Go through the chain and add up all the action counts.
Reimplemented from editor::editor_action.
Definition at line 104 of file action.cpp.
References action_count().
Referenced by action_count().
void editor::editor_action_chain::append_action | ( | std::unique_ptr< editor_action > | a | ) |
Add an action at the end of the chain.
Definition at line 116 of file action.cpp.
References actions_.
|
overridevirtual |
Inherited from editor_action, implemented by IMPLEMENT_ACTION.
Implements editor::editor_action.
bool editor::editor_action_chain::empty | ( | ) | const |
Definition at line 126 of file action.cpp.
References actions_.
Referenced by editor::map_context::partial_undo(), pop_first_action(), and pop_last_action().
|
overridevirtual |
Reimplemented from editor::editor_action.
editor_action_chain & editor::editor_action_chain::operator= | ( | const editor_action_chain & | other | ) |
Definition at line 87 of file action.cpp.
References actions_.
|
overridevirtual |
Perform all the actions in order and create a undo action chain.
Reimplemented from editor::editor_action.
Definition at line 153 of file action.cpp.
References actions_.
|
overridevirtual |
Perform all the actions in order.
Implements editor::editor_action.
Definition at line 165 of file action.cpp.
References actions_.
std::unique_ptr< editor_action > editor::editor_action_chain::pop_first_action | ( | ) |
Remove the first added action and return it, transferring ownership to the caller.
Definition at line 142 of file action.cpp.
References actions_, and empty().
Referenced by editor::map_context::partial_undo().
std::unique_ptr< editor_action > editor::editor_action_chain::pop_last_action | ( | ) |
Remove the last added action and return it, transferring ownership to the caller.
Definition at line 131 of file action.cpp.
void editor::editor_action_chain::prepend_action | ( | std::unique_ptr< editor_action > | a | ) |
Add an action at the beginning of the chain.
Definition at line 121 of file action.cpp.
References actions_.
Referenced by editor::map_context::perform_partial_action().
|
protected |
The action pointers owned by this action chain.
Definition at line 169 of file action.hpp.
Referenced by append_action(), editor_action_chain(), empty(), operator=(), perform(), perform_without_undo(), pop_first_action(), pop_last_action(), and prepend_action().