frepple::utils::Command Class Reference

Abstract base class for all commands. More...

#include <utils.h>

Inheritance diagram for frepple::utils::Command:

Public Member Functions

 Command ()
 
virtual void commit ()
 
virtual void redo ()
 
virtual void rollback ()
 
virtual void undo ()
 
virtual ~Command ()
 

Friends

class CommandList
 
class CommandManager
 
class frepple::CommandMoveOperationPlan
 

Detailed Description

Abstract base class for all commands.

Command objects are designed for algorithms that need to keep track of their decision, efficiently undo them and redo them.

The key methods are:

  • The constructor or other methods on the concrete subclasses implement the state change.
  • commit(): Makes the change permanently. Undoing the change is no longer possible after calling this method.
  • rollback(): Reverts the change permanently. Redoing the change is no longer possible after calling this method.
  • undo(): Temporarily reverts the change. Redoing the change is still possible.
  • redo(): Reactivates the change that was previously undone.

Definition at line 3939 of file utils.h.

Constructor & Destructor Documentation

frepple::utils::Command::Command ( )
inline

Default constructor. The creation of a command should NOT execute the command yet. The execute() method needs to be called explicitly to do so.

Definition at line 3949 of file utils.h.

virtual frepple::utils::Command::~Command ( )
inlinevirtual

Destructor.

Definition at line 3986 of file utils.h.

Member Function Documentation

virtual void frepple::utils::Command::commit ( )
inlinevirtual

This method makes the change permanent.
A couple of notes on how this method should be implemented by the subclasses:

  • Calling the method multiple times is harmless. Only the first call is expected to do something.

Reimplemented in frepple::CommandMoveOperationPlan, frepple::CommandDeleteOperationPlan, frepple::CommandCreateOperationPlan, and frepple::utils::CommandList.

Definition at line 3957 of file utils.h.

virtual void frepple::utils::Command::redo ( )
inlinevirtual

This method reproduces a previously undone change.
A couple of notes on how this method should be implemented by the subclasses:

  • Calling the method multiple times is harmless and results in the same state change as calling it only once.

Reimplemented in frepple::CommandMoveOperationPlan, frepple::CommandDeleteOperationPlan, frepple::CommandCreateOperationPlan, and frepple::utils::CommandList.

Definition at line 3983 of file utils.h.

virtual void frepple::utils::Command::rollback ( )
inlinevirtual

This method permanently undoes the change.
A couple of notes on how this method should be implemented by the subclasses:

  • Calling the rollback() method multiple times is harmless. Only the first call is expected to do something.

Reimplemented in frepple::CommandMoveOperationPlan, frepple::CommandDeleteOperationPlan, frepple::CommandCreateOperationPlan, and frepple::utils::CommandList.

Definition at line 3965 of file utils.h.

virtual void frepple::utils::Command::undo ( )
inlinevirtual

This method temporarily undoes the change. The concrete subclasses most maintain information that enables redoing the changes efficiently.
A couple of notes on how this method should be implemented by the subclasses:

  • Calling the method multiple times is harmless and results in the same state change as calling it only once.

Reimplemented in frepple::CommandMoveOperationPlan, frepple::CommandDeleteOperationPlan, frepple::CommandCreateOperationPlan, and frepple::utils::CommandList.

Definition at line 3975 of file utils.h.

Friends And Related Function Documentation

friend class CommandList
friend

Definition at line 3941 of file utils.h.

friend class CommandManager
friend

Definition at line 3942 of file utils.h.

friend class frepple::CommandMoveOperationPlan
friend

Definition at line 3943 of file utils.h.


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