The Battle for Wesnoth  1.19.0-dev
Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes | List of all members
editor::editor_action Class Referenceabstract

Base class for all editor actions. More...

#include <action_base.hpp>

Inheritance diagram for editor::editor_action:

Public Member Functions

 editor_action ()
 
virtual ~editor_action ()
 
virtual std::unique_ptr< editor_actionclone () const =0
 Action cloning. More...
 
virtual std::unique_ptr< editor_actionperform (map_context &) const
 Perform the action, returning an undo action that, when performed, shall reverse any effects of this action. More...
 
virtual void perform_without_undo (map_context &) const =0
 Perform the action without creating an undo action. More...
 
virtual int action_count () const
 
virtual const std::string & get_name () const
 
virtual std::string get_description () const
 A textual description of the action. More...
 
int get_id () const
 Debugging aid. More...
 

Static Public Member Functions

static int get_instance_count ()
 Debugging aid. More...
 

Private Attributes

const int id_
 

Static Private Attributes

static int next_id_ = 1
 
static int instance_count_ = 0
 

Detailed Description

Base class for all editor actions.

An editor_action object encapsulates the action to be performed on a map, in separation from the user interface or display, and provides a way of reversing its affects by creating an "undo" action. All the actions can be processed via this base class' virtual functions.

Definition at line 41 of file action_base.hpp.

Constructor & Destructor Documentation

◆ editor_action()

editor::editor_action::editor_action ( )

Definition at line 35 of file action.cpp.

References id_, instance_count_, and LOG_ED.

◆ ~editor_action()

editor::editor_action::~editor_action ( )
virtual

Definition at line 45 of file action.cpp.

References id_, instance_count_, and LOG_ED.

Member Function Documentation

◆ action_count()

int editor::editor_action::action_count ( ) const
virtual
Returns
the actual number of actions contained within

Reimplemented in editor::editor_action_chain.

Definition at line 54 of file action.cpp.

◆ clone()

virtual std::unique_ptr<editor_action> editor::editor_action::clone ( ) const
pure virtual

◆ get_description()

std::string editor::editor_action::get_description ( ) const
virtual

A textual description of the action.

For use e.g. in the undo menu, to have a "Undo: Fill with Grassland" item rather than just "Undo". Should be overridden by derived Actions, defaults to a debug message.

Definition at line 59 of file action.cpp.

◆ get_id()

int editor::editor_action::get_id ( ) const
inline

Debugging aid.

Return an unique identifier of this Action.

Definition at line 93 of file action_base.hpp.

References id_.

Referenced by editor::map_context::perform_action(), and editor::map_context::perform_partial_action().

◆ get_instance_count()

static int editor::editor_action::get_instance_count ( )
inlinestatic

Debugging aid.

Return number of existing instances of Actions.

Definition at line 101 of file action_base.hpp.

References instance_count_.

Referenced by editor::map_context::perform_action(), editor::map_context::perform_partial_action(), and editor::start().

◆ get_name()

virtual const std::string& editor::editor_action::get_name ( ) const
inlinevirtual

◆ perform()

std::unique_ptr< editor_action > editor::editor_action::perform ( map_context mc) const
virtual

◆ perform_without_undo()

virtual void editor::editor_action::perform_without_undo ( map_context ) const
pure virtual

Member Data Documentation

◆ id_

const int editor::editor_action::id_
private

Definition at line 110 of file action_base.hpp.

Referenced by editor_action(), get_id(), and ~editor_action().

◆ instance_count_

int editor::editor_action::instance_count_ = 0
staticprivate

Definition at line 108 of file action_base.hpp.

Referenced by editor_action(), get_instance_count(), and ~editor_action().

◆ next_id_

int editor::editor_action::next_id_ = 1
staticprivate

Definition at line 107 of file action_base.hpp.


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