PanoCommand::CommandHistory Class Reference

A history for Command, provides undo/redo functionality. More...

#include <CommandHistory.h>

Inheritance diagram for PanoCommand::CommandHistory:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 CommandHistory ()
 ctor.
virtual ~CommandHistory ()
 dtor.
void clear ()
 Erases all the undo/redo history.
void addCommand (PanoCommand *command, bool execute=true)
 Adds a command to the history.
virtual void undo ()
 Undoes the last action.
virtual void redo ()
 Redoes the last undone action.
bool canUndo () const
 Return true iff there is a command to undo.
bool canRedo () const
 Return true iff there is a command to redo.
std::string getLastCommandName () const
 returns the name of the last command

Private Attributes

std::vector< PanoCommand * > commands
size_t nextCmd

Detailed Description

A history for Command, provides undo/redo functionality.

To use this, all modifications to the model have to be done through commands that are executed with addCommand();

Definition at line 38 of file CommandHistory.h.


Constructor & Destructor Documentation

CommandHistory::CommandHistory (  ) 

ctor.

Definition at line 38 of file CommandHistory.cpp.

CommandHistory::~CommandHistory (  )  [virtual]

dtor.

Definition at line 43 of file CommandHistory.cpp.

References CommandHistory::commands.


Member Function Documentation

void CommandHistory::addCommand ( PanoCommand command,
bool  execute = true 
)

Adds a command to the history.

Call this for each command you create. Unless you set execute to false, this will also execute the command. This means, most of the application's code will look like

    MyCommand * cmd = new MyCommand(...);
    m_historyCommand.addCommand( cmd );

Ownership of command is transfered to CommandHistory

Definition at line 63 of file CommandHistory.cpp.

References CommandHistory::commands, DEBUG_FATAL, and CommandHistory::nextCmd.

bool CommandHistory::canRedo (  )  const

Return true iff there is a command to redo.

Definition at line 154 of file CommandHistory.cpp.

References CommandHistory::commands, and CommandHistory::nextCmd.

bool CommandHistory::canUndo (  )  const

Return true iff there is a command to undo.

Definition at line 149 of file CommandHistory.cpp.

References CommandHistory::nextCmd.

void CommandHistory::clear (  ) 

Erases all the undo/redo history.

Use this when reloading the data, for instance, since this invalidates all the commands.

Definition at line 52 of file CommandHistory.cpp.

References CommandHistory::commands, and CommandHistory::nextCmd.

std::string CommandHistory::getLastCommandName (  )  const

returns the name of the last command

Definition at line 159 of file CommandHistory.cpp.

References CommandHistory::canUndo(), CommandHistory::commands, and CommandHistory::nextCmd.

void CommandHistory::redo (  )  [virtual]

Redoes the last undone action.

Definition at line 124 of file CommandHistory.cpp.

References CommandHistory::commands, DEBUG_DEBUG, DEBUG_ERROR, PanoCommand::execute(), PanoCommand::getName(), HUGIN_SMART_UNDO, and CommandHistory::nextCmd.

void CommandHistory::undo (  )  [virtual]

Undoes the last action.

Definition at line 95 of file CommandHistory.cpp.

References CommandHistory::commands, DEBUG_DEBUG, DEBUG_ERROR, PanoCommand::getName(), HUGIN_SMART_UNDO, and CommandHistory::nextCmd.


Member Data Documentation

std::vector<PanoCommand*> PanoCommand::CommandHistory::commands [private]

Definition at line 89 of file CommandHistory.h.

size_t PanoCommand::CommandHistory::nextCmd [private]

Definition at line 90 of file CommandHistory.h.


The documentation for this class was generated from the following files:
Generated on 25 Apr 2018 for Hugintrunk by  doxygen 1.4.7