Lomse library. API documentation  0.30.0
DocCommand Class Referenceabstract

#include <lomse_command.h>

Inheritance diagram for DocCommand:
DocCmdComposite DocCmdSimple CmdAddChordNote CmdAddNoteRest CmdAddTie CmdAddTuplet CmdBreakBeam CmdChangeAccidentals CmdChangeAttribute CmdChangeDots CmdCursor CmdDelete CmdInsert CmdJoinBeam CmdMoveObjectPoint CmdSelection CmdTranspose

Detailed Description

Abstract base class from which all commands must derive. Represents an edition command.

Public Types

enum  ECmdCursorPolicy
 
enum  ECmdUndoPolicy
 
enum  ECmdSelectionPolicy
 

Public Member Functions

virtual ~DocCommand ()
 
virtual int get_cursor_update_policy ()=0
 
virtual int get_undo_policy ()=0
 
virtual int get_selection_update_policy ()=0
 
std::string get_name ()
 
bool is_reversible ()
 
bool is_recordable ()
 
std::string get_error ()
 
virtual bool is_composite ()=0
 

Member Enumeration Documentation

◆ ECmdCursorPolicy

This enum describes the policies for updating the cursor after executing a command.

Enumerator
k_do_nothing 

Do nothing. All cursor data remains valid after command execution.

k_update_after_deletion 

Update the cursor. Current pointed object has been deleted and cursor must now point to next object.

k_update_after_insertion 

Update the cursor. Cursor must point to inserted object.

k_refresh 

Refresh cursor. Pointed object is valid but other related info. could have changed.

◆ ECmdSelectionPolicy

This enum describes the available policies for updating the SelectionSet after executing a command.

Enumerator
k_sel_do_nothing 

Do nothing. The selection is not changed after command execution.

k_sel_clear 

Clear the selection after executing the command.

k_sel_command_specific 

Specific. The command will do whatever is needed.

◆ ECmdUndoPolicy

This enum describes the available undo policies for commands.

Enumerator
k_undo_policy_full_checkpoint 

Undo based on a full checkpoint.

k_undo_policy_partial_checkpoint 

Undo based on a partial checkpoint.

k_undo_policy_specific 

Undo implemented by the command.

k_undo_policy_replay_from_start 

Undo based on replaying commands.

Constructor & Destructor Documentation

◆ ~DocCommand()

virtual DocCommand::~DocCommand ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ get_cursor_update_policy()

◆ get_error()

std::string DocCommand::get_error ( )
inline

Returns an error message with the error explanation. This method should be invoked after executing a command that fails. Otherwise it will return an empty string.

◆ get_name()

std::string DocCommand::get_name ( )
inline

Returns the name of the command.

Remarks
For some commands, if this method is invoked before executing the command, the name could have not been set and the returned value could be empty or could be an incomplete string.

◆ get_selection_update_policy()

◆ get_undo_policy()

◆ is_composite()

virtual bool DocCommand::is_composite ( )
pure virtual

Returns true if the command is composite.

Implemented in DocCmdComposite, and DocCmdSimple.

◆ is_recordable()

bool DocCommand::is_recordable ( )
inline

Returns true if the command is recordable.

Command sequences can be recorded and replayed at other point or on another document, allowing the creation of macros or scripts. But not all commands are suitable to be recorded and replayed. Recordable commands are those that can be recorded and replayed safely. All reversible commands are recordable by nature, as this is required for supporting redo. See is_reversible().

◆ is_reversible()

bool DocCommand::is_reversible ( )
inline

Returns true if the command is reversible, that is, if the command supports undo/redo (e.g. insert object), and false if it does not support undo/redo (e.g. print).