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

Container action wrapping several actions into one. More...

#include <action.hpp>

Inheritance diagram for editor::editor_action_chain:
Inheritance graph

Public Member Functions

 editor_action_chain ()
 Create an empty action chain. More...
 
 editor_action_chain (const editor_action_chain &other)
 
editor_action_chainoperator= (const editor_action_chain &other)
 
editor_action_chainclone () const
 Action cloning. More...
 
 editor_action_chain (std::deque< editor_action * > actions)
 Create an action chain from a deque of action pointers. More...
 
 editor_action_chain (editor_action *action)
 Create an action chain by wrapping around a single action pointer. More...
 
 ~editor_action_chain ()
 The destructor deletes all the owned action pointers. More...
 
int action_count () const
 Go through the chain and add up all the action counts. More...
 
void append_action (editor_action *a)
 Add an action at the end of the chain. More...
 
void prepend_action (editor_action *a)
 Add an action at the beginning of the chain. More...
 
bool empty () const
 
editor_actionpop_last_action ()
 Remove the last added action and return it, transferring ownership to the caller. More...
 
editor_actionpop_first_action ()
 Remove the first added action and return it, transferring ownership to the caller. More...
 
editor_action_chainperform (map_context &m) const
 Perform all the actions in order and create a undo action chain. More...
 
void perform_without_undo (map_context &m) const
 Perform all the actions in order. More...
 
const char * get_name () const
 
- 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< 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...
 

Detailed Description

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 79 of file action.hpp.

Constructor & Destructor Documentation

editor::editor_action_chain::editor_action_chain ( )
inline

Create an empty action chain.

Definition at line 85 of file action.hpp.

Referenced by clone(), and perform().

editor::editor_action_chain::editor_action_chain ( const editor_action_chain other)

Definition at line 75 of file action.cpp.

References actions_, and editor::editor_action::clone().

editor::editor_action_chain::editor_action_chain ( std::deque< editor_action * >  actions)
inlineexplicit

Create an action chain from a deque of action pointers.

Note: the action chain assumes ownership of the pointers.

Definition at line 100 of file action.hpp.

editor::editor_action_chain::editor_action_chain ( editor_action action)
inlineexplicit

Create an action chain by wrapping around a single action pointer.

Note: the action chain assumes ownership of the pointer.

Definition at line 109 of file action.hpp.

editor::editor_action_chain::~editor_action_chain ( )

The destructor deletes all the owned action pointers.

Definition at line 94 of file action.cpp.

References actions_.

Member Function Documentation

int editor::editor_action_chain::action_count ( ) const
virtual

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 actions_.

void editor::editor_action_chain::append_action ( editor_action a)

Add an action at the end of the chain.

Definition at line 113 of file action.cpp.

References actions_.

Referenced by editor::mouse_action_map_label::drag_left(), and editor::editor_action_starting_position::perform().

editor_action_chain * editor::editor_action_chain::clone ( ) const
virtual

Action cloning.

Implements editor::editor_action.

Definition at line 100 of file action.cpp.

References editor_action_chain().

bool editor::editor_action_chain::empty ( ) const
Returns
true when there are no actions in the chain. Empty action chains should usually be discarded as to not keep "empty" actions around.

Definition at line 119 of file action.cpp.

References actions_.

Referenced by editor::map_context::partial_undo(), pop_first_action(), and pop_last_action().

const char* editor::editor_action_chain::get_name ( ) const
inlinevirtual
Returns
a short name of this action type, defaults to unknown

Reimplemented from editor::editor_action.

Definition at line 163 of file action.hpp.

editor_action_chain & editor::editor_action_chain::operator= ( const editor_action_chain other)

Definition at line 82 of file action.cpp.

References actions_, and editor::editor_action::clone().

editor_action_chain * editor::editor_action_chain::perform ( map_context m) const
virtual

Perform all the actions in order and create a undo action chain.

Reimplemented from editor::editor_action.

Definition at line 134 of file action.cpp.

References actions_, editor_action_chain(), and util::unique_ptr< T >::release().

void editor::editor_action_chain::perform_without_undo ( map_context m) const
virtual

Perform all the actions in order.

Implements editor::editor_action.

Definition at line 144 of file action.cpp.

References actions_.

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 128 of file action.cpp.

References actions_, and empty().

Referenced by editor::map_context::partial_undo().

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 122 of file action.cpp.

References actions_, and empty().

void editor::editor_action_chain::prepend_action ( editor_action a)

Add an action at the beginning of the chain.

Definition at line 116 of file action.cpp.

References actions_.

Referenced by editor::map_context::perform_partial_action().

Member Data Documentation

std::deque<editor_action*> editor::editor_action_chain::actions_
protected

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