ufe 6.2
Universal Front End is a DCC-agnostic component that will allow a DCC to browse and edit data in multiple data models
Ufe::BatchCompositeCommand Class Reference

Composite command affecting a batch (selection) of items. For each item run-time, allow the run-time to wrap the execution of the composite commmand with arbitrary prelude and cleanup code. More...

#include <batchCompositeCommand.h>

Inheritance diagram for Ufe::BatchCompositeCommand:
Collaboration diagram for Ufe::BatchCompositeCommand:

Public Member Functions

 BatchCompositeCommand (const BatchCompositeCommand &)=delete
 
const BatchCompositeCommandoperator= (const BatchCompositeCommand &)=delete
 
 BatchCompositeCommand (const Selection &selection, const std::string &operationName)
 Constructor. More...
 
const CodeWrapperContainercodeWrappers () const
 Retrieves the container of code-wrappers, one per run-time found in the selection. More...
 
void execute () override
 Wraps execution of sub-command with the command wrappers. More...
 
void undo () override
 Wraps undoing of sub-command with the command wrappers. More...
 
void redo () override
 Wraps redoing of sub-command with the command wrappers. More...
 
- Public Member Functions inherited from Ufe::CompositeUndoableCommand
 CompositeUndoableCommand ()
 Constructors. More...
 
 CompositeUndoableCommand (std::initializer_list< Ptr > undoableCommands)
 
 CompositeUndoableCommand (const std::list< Ptr > &undoableCommands)
 
 CompositeUndoableCommand (const Ptr &undoableCommand)
 
 ~CompositeUndoableCommand () override
 Destructor. More...
 
void execute () override
 Calls execute() on each command in the list, in forward order. More...
 
void undo () override
 Calls undo() on each command in the list, in reverse order. More...
 
void redo () override
 Calls redo() on each command in the list, in forward order. More...
 
void append (const Ptr &cmd)
 Append the argument to the list of commands. More...
 
const CmdListcmdsList () const
 Returns the list of undoable commands. More...
 
- Public Member Functions inherited from Ufe::UndoableCommand
virtual ~UndoableCommand ()
 Destructor. More...
 
virtual std::string commandString () const
 Get a user friendly string representation of the command. More...
 
virtual void execute ()
 
virtual void undo ()=0
 
virtual void redo ()=0
 

Static Public Member Functions

static std::shared_ptr< BatchCompositeCommandcreate (const Selection &selection, const std::string &operationName)
 Creates a BatchCompositeCommand. More...
 
- Static Public Member Functions inherited from Ufe::CompositeUndoableCommand
static std::shared_ptr< CompositeUndoableCommandcreate (std::initializer_list< Ptr > undoableCommands)
 
static std::shared_ptr< CompositeUndoableCommandcreate (const std::list< Ptr > &undoableCommands)
 
static std::shared_ptr< CompositeUndoableCommandcreate (const Ptr &undoableCommand)
 

Static Public Attributes

static const std::string execSubOp
 The sub-operations for the code wrappers associated with the execute, undo and redo. More...
 
static const std::string undoSubOp
 
static const std::string redoSubOp
 

Private Attributes

CodeWrapperContainer fWrappers
 

Additional Inherited Members

- Public Types inherited from Ufe::CompositeUndoableCommand
typedef std::list< PtrCmdList
 
- Public Types inherited from Ufe::UndoableCommand
typedef std::shared_ptr< UndoableCommandPtr
 
- Protected Member Functions inherited from Ufe::UndoableCommand
 UndoableCommand ()
 Constructor. More...
 
 UndoableCommand (const UndoableCommand &)=delete
 Deleting copy constructor. More...
 

Detailed Description

Composite command affecting a batch (selection) of items. For each item run-time, allow the run-time to wrap the execution of the composite commmand with arbitrary prelude and cleanup code.

Intended usage of the class in this file and in codeWrapperContext:

BatchCompositeCommand Holds wrappers to do prelude and cleanup around the execution, undoing or redoing of a composite command.

CodeWrapperContext (from codeWrapperContext.h) Supports the prelude and cleanup when executing sub-commands before adding them to a composite command.

The necessity of two classes is to support the two coding patterns when creating a composite command:

- Creating all sub-commands and adding them to the composite without
  executing them, and then executing the whole composite command.

- Creating all sub-commands and executing them immediately *before*
  adding them to the composite command and *not* executing the
  composite command.

So, if the sub-commands are all created but not executed and are added to the composite command, then the composite command will automatically do the prelude and cleanup and thus, with this coding pattern, the context class is not needed. In pseudo-code:

auto composite = new BatchCompositeCommand(selection, "op-name") for each sub-command: auto subCmd = new SomeOtherUfeCommand(); composite->append(subCmd); composite->execute()

In contrast, if the individual sub-commands are executed before adding them to the composite command, then the context class must be used in order for these individually-executed commands to be properly surrounded by the intended prelude and cleanup code. In pseudo-code, the pattern this supports is:

auto composite = new BatchCompositeCommand(selection, "op-name") CodeWrapperContext ctx(composite->codeWrappers(), BatchCompositeCommand::executeSubOperation); for each sub-command: auto subCmd = new SomeOtherUfeCommand(); subCmd->execute() composite->append(subCmd);

see the full documentation

Definition at line 72 of file batchCompositeCommand.h.

Constructor & Destructor Documentation

◆ BatchCompositeCommand() [1/2]

Ufe::BatchCompositeCommand::BatchCompositeCommand ( const BatchCompositeCommand )
delete

◆ BatchCompositeCommand() [2/2]

Ufe::BatchCompositeCommand::BatchCompositeCommand ( const Selection selection,
const std::string &  operationName 
)

Constructor.

Parameters
selectionthe selection of items that is affected by the command.
operationNamethe name of the composite command.

Member Function Documentation

◆ codeWrappers()

const CodeWrapperContainer & Ufe::BatchCompositeCommand::codeWrappers ( ) const
inline

Retrieves the container of code-wrappers, one per run-time found in the selection.

Definition at line 93 of file batchCompositeCommand.h.

◆ create()

static std::shared_ptr< BatchCompositeCommand > Ufe::BatchCompositeCommand::create ( const Selection selection,
const std::string &  operationName 
)
static

Creates a BatchCompositeCommand.

Parameters
selectionthe selection of items that is affected by the command.
operationNamethe name of the composite command.

◆ execute()

void Ufe::BatchCompositeCommand::execute ( )
overridevirtual

Wraps execution of sub-command with the command wrappers.

Reimplemented from Ufe::UndoableCommand.

◆ operator=()

const BatchCompositeCommand & Ufe::BatchCompositeCommand::operator= ( const BatchCompositeCommand )
delete

◆ redo()

void Ufe::BatchCompositeCommand::redo ( )
overridevirtual

Wraps redoing of sub-command with the command wrappers.

Implements Ufe::UndoableCommand.

◆ undo()

void Ufe::BatchCompositeCommand::undo ( )
overridevirtual

Wraps undoing of sub-command with the command wrappers.

Implements Ufe::UndoableCommand.

Member Data Documentation

◆ execSubOp

const std::string Ufe::BatchCompositeCommand::execSubOp
static

The sub-operations for the code wrappers associated with the execute, undo and redo.

Definition at line 98 of file batchCompositeCommand.h.

◆ fWrappers

CodeWrapperContainer Ufe::BatchCompositeCommand::fWrappers
private

Definition at line 112 of file batchCompositeCommand.h.

◆ redoSubOp

const std::string Ufe::BatchCompositeCommand::redoSubOp
static

Definition at line 100 of file batchCompositeCommand.h.

◆ undoSubOp

const std::string Ufe::BatchCompositeCommand::undoSubOp
static

Definition at line 99 of file batchCompositeCommand.h.


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