Lomse library. API documentation  0.30.0
DocCommandExecuter Class Reference

#include <lomse_command.h>

Detailed Description

DocCommandExecuter class is responsible of maintaining the stack of executed commands and performing undo/redo.

Public Member Functions

 DocCommandExecuter (Document *target)
 
virtual ~DocCommandExecuter ()
 
 DocCommandExecuter (const ImoStyles &)=delete
 
DocCommandExecuteroperator= (const ImoStyles &)=delete
 
 DocCommandExecuter (ImoStyles &&)=delete
 
DocCommandExecuteroperator= (ImoStyles &&)=delete
 
virtual int execute (DocCursor *pCursor, DocCommand *pCmd, SelectionSet *pSelection)
 
virtual void undo (DocCursor *pCursor, SelectionSet *pSelection)
 
virtual void redo (DocCursor *pCursor, SelectionSet *pSelection)
 
std::string get_error ()
 
bool is_undo_possible ()
 
bool is_redo_possible ()
 
virtual size_t undo_stack_size ()
 

Friends

class DocCmdComposite
 

Constructor & Destructor Documentation

◆ DocCommandExecuter()

DocCommandExecuter::DocCommandExecuter ( Document *  target)

Constructor.

◆ ~DocCommandExecuter()

virtual DocCommandExecuter::~DocCommandExecuter ( )
virtual

the five special

Member Function Documentation

◆ execute()

virtual int DocCommandExecuter::execute ( DocCursor *  pCursor,
DocCommand pCmd,
SelectionSet *  pSelection 
)
virtual

Executes a command and saves the necessary information for undo/redo operations. Returns value 0 if the command successfully executed. Otherwise returns value 1 and a relevant error message can be retrieved by invoking method get_error().

◆ get_error()

std::string DocCommandExecuter::get_error ( )
inline

In case an comand failed, this method provides an string with the error message

◆ is_redo_possible()

bool DocCommandExecuter::is_redo_possible ( )
inline

Returns true if there are redo-able commands in the undo/redo stack.

◆ is_undo_possible()

bool DocCommandExecuter::is_undo_possible ( )
inline

Returns true if there are undo-able commands in the undo/redo stack.

◆ redo()

virtual void DocCommandExecuter::redo ( DocCursor *  pCursor,
SelectionSet *  pSelection 
)
virtual

Redo the last undo command.

◆ undo()

virtual void DocCommandExecuter::undo ( DocCursor *  pCursor,
SelectionSet *  pSelection 
)
virtual

Pop a command from the stack and undo it.

◆ undo_stack_size()

virtual size_t DocCommandExecuter::undo_stack_size ( )
inlinevirtual

Returns the number of undo/redo elements in the undo/redo stack.