VAPoR  3.0.0
Public Member Functions | Static Public Member Functions | List of all members
VAPoR::Command Class Reference

Provides support for maintaining a queue of recently issued commands, performing UnDo, ReDo, etc. The parent Command class supports a queue of Params changes; each entry has a clone of the previous and next Params instance associated with a change. More...

#include <command.h>

Public Member Functions

void setDescription (const char *str)
 
string getDescription ()
 
ParamsCopyParams (ParamNode *rootNode)
 
ParamsCopyAuxParams (ParamNode *rootNode)
 

Static Public Member Functions

static CommandCaptureStart (Params *prevParams, const char *desc, UndoRedoHelpCB_T helper=0, Params *prevAuxParams=0)
 
static void CaptureEnd (Command *pCom, Params *nextParams, Params *nextAuxParams=0)
 

Internal

Internal methods not intended for general use

 Command (Params *, const char *descr, UndoRedoHelpCB_T helper=0, Params *auxParams=0)
 
virtual ~Command ()
 
static ParamsBackupQueue ()
 
static ParamsAdvanceQueue ()
 
static void resetCommandQueue ()
 Static method to put command queue in initial state. More...
 
static bool isRecording ()
 static method to tell if commands are being inserted in the queue More...
 
static CommandCurrentCommand (int offset)
 

Detailed Description

Provides support for maintaining a queue of recently issued commands, performing UnDo, ReDo, etc. The parent Command class supports a queue of Params changes; each entry has a clone of the previous and next Params instance associated with a change.

Author
Alan Norton
Version
3.0
Date
February, 2014

The Command class automatically provides the functionality needed for Undo and Redo. Each Command instance contains two ParamNode roots, corresponding to the state of the Params before and after a state change. Command instances are inserted into the Undo/Redo queue by invoking Command::CaptureStart and then Command::CaptureEnd. The CaptureStart and CaptureEnd methods are generated by the methods Params::SetValueLong(), Params::SetValueDouble(), Params::SetValueString(), so is it only necessary to directly use Command::CaptureStart() and CaptureEnd() when more than one state change occurs in a single entry of the Undo/Redo queue.

Typedef for callback functions that help during Undo and Redo

Definition at line 50 of file command.h.

Constructor & Destructor Documentation

VAPoR::Command::Command ( Params ,
const char *  descr,
UndoRedoHelpCB_T  helper = 0,
Params auxParams = 0 
)
virtual VAPoR::Command::~Command ( )
inlinevirtual

Definition at line 57 of file command.h.

Member Function Documentation

static Params* VAPoR::Command::AdvanceQueue ( )
static

Static method to go forward one position (i.e. redo) in the queue. Returns the params instance that now is current

Returns
Params instance that is newly current, null if we are at end of queue
static Params* VAPoR::Command::BackupQueue ( )
static

Static method to go back one position (i.e. undo) in the queue. Returns the params instance that now is current

Returns
Params instance that is newly current, null if nothing left to backup.
static void VAPoR::Command::CaptureEnd ( Command pCom,
Params nextParams,
Params nextAuxParams = 0 
)
inlinestatic

Static method used to capture the next Params state (after the state change) and then to insert the command into the command queue

Parameters
[in]CommandA Command instance, previously initialized by CaptureStart
[in]nextParamspoints to next Params instance
[in]nextAuxParamsadditional Params instance whose state is captured.
See also
CaptureStart

Definition at line 127 of file command.h.

References VAPoR::ParamNode::deepCopy(), VAPoR::Params::GetInstanceIndex(), VAPoR::ParamsBase::GetName(), VAPoR::ParamsBase::GetRootNode(), and VAPoR::Params::GetVizNum().

Referenced by VAPoR::ViewpointParams::setCurrentViewpoint(), and VAPoR::ViewpointParams::setHomeViewpoint().

static Command* VAPoR::Command::CaptureStart ( Params prevParams,
const char *  desc,
UndoRedoHelpCB_T  helper = 0,
Params prevAuxParams = 0 
)
inlinestatic

Static method used to capture the previous Params state (before the state change). It returns a Command instance that is not yet inserted in the command queue. Command::CaptureEnd() must be invoked to complete the Command instance.

Note
If the returned command is abandoned without calling CaptureEnd(), then the command should be deleted.
Parameters
[in]prevParamspoints to previous Params instance
[in]descTextual description of the change
[in]helperoptional argument specifying a helper function (UndoRedoHelpCB_T) that is invoked during Undo and Redo.
[in]prevAuxParamsoptional additional Params instance whose state change is being captured.
Returns
cmd A new command initialized with prevParams.
See also
CaptureEnd

Definition at line 115 of file command.h.

Referenced by VAPoR::ViewpointParams::setCurrentViewpoint(), and VAPoR::ViewpointParams::setHomeViewpoint().

Params* VAPoR::Command::CopyAuxParams ( ParamNode rootNode)

Obtain a copy of the auxiliary params in the queue with specified rootNode Useful if additional processing is needed during Undo or Redo Note that the returned Params copy should be deleted after it is used

Return values
Params*that was "next" in the command
Params* VAPoR::Command::CopyParams ( ParamNode rootNode)

Obtain a copy of the params in the queue with specified rootNode Useful if additional processing is needed during Undo or Redo Note that the returned Params copy should be deleted after it is used

Return values
Params*that was "next" in the command
static Command* VAPoR::Command::CurrentCommand ( int  offset)
inlinestatic

static method retrieves a command from the queue, with index relative to the last executed command.

Parameters
[in]offsetposition relative to last command, positive offsets were executed earlier.
Returns
Command* pointer to specified command, null if invalid.

Definition at line 88 of file command.h.

References MAX_HISTORY.

string VAPoR::Command::getDescription ( )
inline

Get the description associated with this command instance

Returns
string Description text identifying the state change of this command.

Definition at line 101 of file command.h.

static bool VAPoR::Command::isRecording ( )
inlinestatic

static method to tell if commands are being inserted in the queue

Definition at line 83 of file command.h.

static void VAPoR::Command::resetCommandQueue ( )
static

Static method to put command queue in initial state.

void VAPoR::Command::setDescription ( const char *  str)
inline

Specify the description of a command

Parameters
[in]char*_description

Definition at line 96 of file command.h.


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