CMvcCommand Class

class CMvcCommand: public IMessage

A CMvcCommand is an abstract base class that defines the interface for all command objects. A command object is essentially a persistent form of a verb. Graphical User Interfaces typically adhere to what is known as the "Object-Verb" paradigm, which simply means you select an object and then apply a verb to that object. Fundamentally, each command object represents a verb and classes which you derive from MvcCommand define specific verbs as appropriate for your application. Basically, you are expected to derive multiple command classes from this class and implement the Execute function such that it performs whatever function the derived command class encapsulates. In MVC, the model defines a set of verbs, or command objects, that make sense within the triad.

The CMvcCommand class is central to the undo/redo architecture defined by MVC. Typically, a controller will respond to user input by calling some operation defined by the model it observes. That model operation should create a command object of the required type, log the command and execute it. Logging the commands prior to executing them creates a history buffer so that a record exist for undo/redo purposes. This history buffer is maintained internal to the transaction model.

Defined in: MvcCommand.h

Class Members

CMvcCommand()

Construct an MVC command object

virtual  ~CMvcCommand()

Destroy an MVC command object

BOOL m_bUndoable

Flag to indicate if command supports Unexecute

virtual BOOL  IsUndoable() const

Determines if this command can be undone

BOOL  CMvcCommandSetUndoable

Sets if this command can be undone

virtual BOOL  Execute()

Execute this command

virtual BOOL  Unexecute()

Reverse the effects of this command