Cadabra
Computer algebra system for field theory problems
Public Member Functions | Public Attributes | Protected Attributes | List of all members
cadabra::ActionBase Class Referenceabstract

Description

All actions derive from the ActionBase object, which defines the interface they need to implement.

These objects are used to pass (user) action instructions around. They can be stored in undo/redo stacks. All actions run on the GUI thread. The update_gui members typically call members of the GUIBase class. Action objects are allowed to modify the DTree document doc, since they essentially contain code which is part of the DocumentThread object.

All modifications to the document are done by calling 'perform' with an action object. This enables us to implement an undo stack. This method will take care of making the actual change to the DTree document, and call back on the 'change' methods above to inform the derived class that a change has been made.

#include <Actions.hh>

Inheritance diagram for cadabra::ActionBase:
cadabra::ActionAddCell cadabra::ActionCompleteText cadabra::ActionEraseText cadabra::ActionInsertText cadabra::ActionPositionCursor cadabra::ActionRemoveCell cadabra::ActionReplaceCell cadabra::ActionSetRunStatus cadabra::ActionSplitCell

Public Member Functions

 ActionBase (DataCell::id_t ref_id)
 
virtual void execute (DocumentThread &, GUIBase &)
 Perform the action. More...
 
virtual void revert (DocumentThread &, GUIBase &)=0
 Revert the change to the DTree document and the GUI. More...
 
virtual bool undoable () const
 Can this action be undone? More...
 

Public Attributes

DataCell::id_t ref_id
 

Protected Attributes

DTree::iterator ref
 

Constructor & Destructor Documentation

◆ ActionBase()

ActionBase::ActionBase ( DataCell::id_t  ref_id)

Member Function Documentation

◆ execute()

void ActionBase::execute ( DocumentThread cl,
GUIBase  
)
virtual

Perform the action.

This should update both the document tree data structure and the GUI. The latter is updated by calling relevant methods on the GUIBase object passed in.

Reimplemented in cadabra::ActionEraseText, cadabra::ActionCompleteText, cadabra::ActionInsertText, cadabra::ActionSplitCell, cadabra::ActionReplaceCell, cadabra::ActionRemoveCell, cadabra::ActionSetRunStatus, cadabra::ActionPositionCursor, and cadabra::ActionAddCell.

◆ revert()

virtual void cadabra::ActionBase::revert ( DocumentThread ,
GUIBase  
)
pure virtual

◆ undoable()

bool ActionBase::undoable ( ) const
virtual

Can this action be undone?

Reimplemented in cadabra::ActionReplaceCell, cadabra::ActionSetRunStatus, and cadabra::ActionAddCell.

Member Data Documentation

◆ ref

DTree::iterator cadabra::ActionBase::ref
protected

◆ ref_id

DataCell::id_t cadabra::ActionBase::ref_id

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