Main Page   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

ACT_ActionStack Class Reference

A stack with actions that implements undo/redo capabilities. More...

#include <ACT_ActionStack.h>

List of all members.

Public Methods

 ACT_ActionStack (unsigned int maxStackDepth=1)
 Constructs an action stack. More...

 ~ACT_ActionStack ()
 Destructs an action stack.

virtual unsigned int getStackDepth ()const
 Returns the current depth of the stack. More...

virtual unsigned int getMaxStackDepth ()const
 Returns the current maximum depth of the stack. More...

virtual void setMaxStackDepth (unsigned int maxStackDepth)
 Sets new maximum depth of the stack. More...

virtual void push (ACT_Action &action)
 Pushes an action on the stack. More...

virtual ACT_ActionpeekUndo ()
 Returns pointer to the current undo item. More...

virtual ACT_ActionpeekRedo ()
 Returns pointer to the current redo item. More...

virtual void flush ()
 Flushes the action stack. More...

virtual bool canUndo ()const
 Returns whether we can undo the current action. More...

virtual void undo ()
 Undos the current action. More...

virtual bool canRedo ()const
 Returns whether we can redo the current action. More...

virtual void redo ()
 Redos the current action. More...


Protected Methods

virtual unsigned int popBack (unsigned int numActions=1)
 Removes numItem actions from the back of the stack. More...

virtual unsigned int popFront (unsigned int numActions=1)
 Removes numItem actions from the front of the stack. More...

virtual bool getUndoIndex (unsigned int &index)const
 Returns the index of the current undo action. More...

virtual bool getRedoIndex (unsigned int &index)const
 Returns the index of the current redo action. More...


Protected Attributes

unsigned int m_maxStackDepth
 The maximum depth of this stack.

unsigned int m_undoIndex
 The index of the current undo action in the stack.

bool m_undoIndexValid
 Is the index of the current undo action in the stack valid.

unsigned int m_redoIndex
 The index of the current redo action in the stack.

bool m_redoIndexValid
 Is the index of the current redo action in the stack valid.

deque<ACT_Action*> m_stack
 The stack with actions.


Detailed Description

A stack with actions that implements undo/redo capabilities.

A stack can grow to a maximum number of actions by pushing actions on the stack. By calling undo and redo the apply and undo members of the actions on the stack are called. In addition, this will move the stackIndex up and down the stack. When a new action is pushed onto the stack, the actions above the current action are removed from the stack. Actions pushed onto the stack are applied if they are not applied already.

Todo:
implement error handling (e.g. memory errors)
Author(s):
Maarten Gribnau
Date:
March 31, 2001


Constructor & Destructor Documentation

ACT_ActionStack::ACT_ActionStack ( unsigned int maxStackDepth = 1 )
 

Constructs an action stack.

Author(s):
Maarten Gribnau
Date:
March 31, 2001 Version:
Id:


Member Function Documentation

bool ACT_ActionStack::canRedo ( ) const [virtual]
 

Returns whether we can redo the current action.

Returns:
Indication of the possibility to redo.

bool ACT_ActionStack::canUndo ( ) const [virtual]
 

Returns whether we can undo the current action.

Returns:
Indication of the possibility to undo.

void ACT_ActionStack::flush ( ) [virtual]
 

Flushes the action stack.

All actions are removed from the stack and their reference counts decreased.

unsigned int ACT_ActionStack::getMaxStackDepth ( ) const [virtual]
 

Returns the current maximum depth of the stack.

Returns:
the maximum stack depth.

bool ACT_ActionStack::getRedoIndex ( unsigned int & index ) const [protected, virtual]
 

Returns the index of the current redo action.

Parameters:
index   The index of the action.
Returns:
Indication as to whether the index is valid (==true).

unsigned int ACT_ActionStack::getStackDepth ( ) const [virtual]
 

Returns the current depth of the stack.

Returns:
the current stack depth.

bool ACT_ActionStack::getUndoIndex ( unsigned int & index ) const [protected, virtual]
 

Returns the index of the current undo action.

Parameters:
index   The index of the action.
Returns:
Indication as to whether the index is valid (==true).

ACT_Action * ACT_ActionStack::peekRedo ( ) [virtual]
 

Returns pointer to the current redo item.

Returns:
The action scheduled for redo (0 if there is none).

ACT_Action * ACT_ActionStack::peekUndo ( ) [virtual]
 

Returns pointer to the current undo item.

Returns:
The action scheduled for undo (0 if there is none).

unsigned int ACT_ActionStack::popBack ( unsigned int numActions = 1 ) [protected, virtual]
 

Removes numItem actions from the back of the stack.

Parameters:
numActions   number of items to remove.
Returns:
the number of actions removed.

unsigned int ACT_ActionStack::popFront ( unsigned int numActions = 1 ) [protected, virtual]
 

Removes numItem actions from the front of the stack.

Parameters:
numActions   number of items to remove.
Returns:
the number of actions removed.

void ACT_ActionStack::push ( ACT_Action & action ) [virtual]
 

Pushes an action on the stack.

If the action has not been applied yet, it will be applied here. This will increase the reference count of the action. If there is not enough capacity, the action at the bottom of the stack is removed (and its reference count decreased).

Parameters:
action   the action that is pushed onto the stack.

void ACT_ActionStack::redo ( ) [virtual]
 

Redos the current action.

This will move the action index up (if the stack depth allows it).

void ACT_ActionStack::setMaxStackDepth ( unsigned int maxStackDepth ) [virtual]
 

Sets new maximum depth of the stack.

Parameters:
maxStackDepth   The new stack depth.

void ACT_ActionStack::undo ( ) [virtual]
 

Undos the current action.

This will move the current undo index down (if the stack depth allows it).


The documentation for this class was generated from the following files:
Generated at Thu May 3 18:16:00 2001 for ActionLib by doxygen1.2.4 written by Dimitri van Heesch, © 1997-2000