#include <command.H>
Inheritance diagram for COMMAND:
Command Virtual Methods | |
virtual bool | doit () |
Execute the command. | |
virtual bool | undoit () |
Undo the command. | |
virtual bool | clear () |
After doit() and undoit() were called, restore things to the way they were before (may be a no-op for most derived classes). | |
Public Member Functions | |
void | Own () const |
void | Free () const |
int | Lock () |
void | Unlock () |
int | Unique () const |
Constructors | |
COMMAND (bool done=false) | |
Protected Attributes | |
bool | _is_done |
true if doit() was executed most recently. | |
bool | _is_undone |
true if undoit() was executed most recently. |
A COMMAND can be in one of 3 possible states:
For many types of commands, there is no difference between 'undone' and 'clear'. An example of where the two WOULD be different is a command that generates a portion of mesh in doit(), but in undoit() simply hides the portion of mesh instead of destroying it. That way, redoing the command by calling doit() after undoit() would be relatively lightweight: the portion of mesh would be unhidden rather than regenerated.
The virtual method COMMAND::clear() is used to transition from state 'undone' to state 'clear'; e.g. the mesh generation command in the example above would delete the region of mesh in clear(), returning the command (and the mesh) to its initial state before the first doit() was executed. Most derived classes will not need to override COMMAND::clear().
The following are the actions that can be taken from each state:
state: 'clear' doit() changes state to 'done' undoit() is a no-op clear() is a no-op
state: 'done' doit() is a no-op undoit() changes state to 'undone' clear() is an invalid action
state: 'undone' doit() changes state to 'done' undoit() is a no-op clear() changes state to 'clear'
Definition at line 69 of file command.H.
|
|
|
After doit() and undoit() were called, restore things to the way they were before (may be a no-op for most derived classes).
Reimplemented in UNDO_CMD, and MULTI_CMD. Definition at line 24 of file command.C. References _is_done, _is_undone, and is_done(). Referenced by MULTI_CMD::clear(), and UNDO_CMD::clear(). |
|
|
|
Execute the command.
Reimplemented in UNDO_CMD, DISPLAY_CMD, MULTI_CMD, and MESH_SELECT_CMD. Definition at line 8 of file command.C. References _is_done, and _is_undone. Referenced by MESH_SELECT_CMD::doit(), MULTI_CMD::doit(), DISPLAY_CMD::doit(), and UNDO_CMD::doit(). |
|
Definition at line 76 of file ref.H. References REFcounter::_mutex, REFcounter::_u, and REF_ME. |
|
Neither doit() nor undoit() have been called.
Definition at line 91 of file command.H. References _is_done, and _is_undone. |
|
doit() was called most recently.
Definition at line 94 of file command.H. References _is_done. Referenced by clear(). |
|
undoit() was called most recently, after doit().
Definition at line 97 of file command.H. References _is_undone. |
|
Definition at line 105 of file ref.H. References REFcounter::_mutex, and REFcounter::_u. Referenced by REFlock::REFlock(). |
|
Definition at line 59 of file ref.H. References REFcounter::_mutex, REFcounter::_u, and REF_ME. |
|
Reimplemented in UNDO_CMD, DISPLAY_CMD, and MULTI_CMD. |
|
Undo the command.
Reimplemented in UNDO_CMD, DISPLAY_CMD, MULTI_CMD, and MESH_SELECT_CMD. Definition at line 16 of file command.C. References _is_done, and _is_undone. Referenced by MESH_SELECT_CMD::undoit(), MULTI_CMD::undoit(), DISPLAY_CMD::undoit(), and UNDO_CMD::undoit(). |
|
Definition at line 115 of file ref.H. References REFcounter::_mutex, and REFcounter::_u. |
|
Definition at line 111 of file ref.H. References REFcounter::_mutex, and REFcounter::_u. Referenced by REFlock::~REFlock(). |
|
Definition at line 129 of file command.H. Referenced by clear(), doit(), is_clear(), is_done(), and undoit(). |
|
Definition at line 130 of file command.H. Referenced by clear(), doit(), is_clear(), is_undone(), and undoit(). |