NDEVR
API Documentation
DesignCommandManager

Stores logic for performing, undoing, or redoing DesignCommands. More...

Collaboration diagram for DesignCommandManager:
[legend]

Public Member Functions

 DesignCommandManager (DesignObjectLookup *lookup, InfoPipe *log)
 Constructs a DesignCommandManager.
virtual ~DesignCommandManager ()
 Virtual destructor for proper cleanup of derived classes.
bool canRedo () const
 Checks whether there are any commands available to redo.
bool canUndo () const
 Checks whether there are any commands available to undo.
void clear ()
 Clears all stored commands, including undo, redo, and pending command histories.
WLock commandLock ()
 Acquires a write lock on the command system.
RLock commandReadLock ()
 Acquires a read lock on the command system.
virtual void executeCommand (DynamicPointer< DesignCommand > command)
 Executes a command immediately within the command system.
void executePendingCommands ()
 Executes all commands that have been posted but not yet run.
virtual void finishCommand (const DynamicPointer< DesignCommand > &command)
 Marks a command as finished after execution completes.
const DynamicPointer< DesignCommand > & getCommand (UUID command_id) const
 Retrieves a command by its UUID.
bool hasCommand (UUID id)
 Checks whether a command with the given UUID exists in the manager.
bool hasPendingCommands () const
 Checks whether there are any commands waiting to be executed.
const DynamicPointer< DesignCommand > & lastPendingCommand () const
 Returns the most recently posted pending command.
virtual void postCommand (const DynamicPointer< DesignCommand > &command)
 Posts a command for deferred execution.
template<class t_type>
void postCommand (const DynamicPointer< t_type > &command)
 Posts a typed command for deferred execution.
Buffer< UUIDredo ()
 Redoes the most recently undone command.
virtual void runCommand (const DynamicPointer< DesignCommand > &command)
 Runs a command immediately within the command system.
template<class t_type>
void runCommand (const DynamicPointer< t_type > &command)
 Runs a typed command immediately.
WLock tryCommandLock ()
 Attempts to acquire a write lock on the command system without blocking.
Buffer< UUIDundo ()
 Undoes the most recent command.
virtual void undoCommand (UUID command)
 Undoes a specific command identified by its UUID.
const Buffer< UUID > & undoneCommands () const
 Returns the list of command UUIDs that have been undone and are available for redo.

Public Attributes

Resource< TranslatedStringcommand_hint
 A user-facing hint or description for the currently active command.
Resource< UUIDcommand_id
 The UUID of the currently active command.
Resource< bool > command_lock
 Whether the command system is currently locked, preventing new commands.
Resource< TranslatedStringcommand_name
 The display name of the currently active command.

Protected Attributes

Threadm_command_thread
 The thread used for asynchronous command execution.
Dictionary< UUID, DynamicPointer< DesignCommand > > m_commands
 Map of all known commands keyed by their UUID.
LogPtr m_log
 Logger for recording command execution, undo, and redo activity.
DesignObjectLookupm_lookup
 The design object lookup used to resolve objects during command operations.
Buffer< UUIDm_pending_commands
 Queue of command UUIDs waiting to be executed.
Buffer< UUIDm_thread_pending_commands
 Commands posted from background threads, awaiting transfer to the main pending queue.
Buffer< UUIDm_undo_commands
 Stack of command UUIDs available for undo (most recent last).
Buffer< UUIDm_undone_commands
 Stack of command UUIDs that have been undone and are available for redo.

Detailed Description

Stores logic for performing, undoing, or redoing DesignCommands.


Manages a queue of DesignCommand objects, providing execute, undo, and redo functionality. Commands can be posted for deferred execution or run immediately. Thread-safe locking is provided for concurrent command access when threading is supported.

See also
DesignCommand, ManagedDesignCommand, DesignObjectLookup

Definition at line 20 of file DesignCommandManager.h.

Constructor & Destructor Documentation

◆ DesignCommandManager()

DesignCommandManager::DesignCommandManager ( DesignObjectLookup * lookup,
InfoPipe * log )

Constructs a DesignCommandManager.


Parameters
[in]lookupThe design object lookup used to resolve design objects during command execution.
[in]logThe logging pipe for recording command activity and diagnostics.

◆ ~DesignCommandManager()

virtual DesignCommandManager::~DesignCommandManager ( )
virtual

Virtual destructor for proper cleanup of derived classes.


Member Function Documentation

◆ canRedo()

bool DesignCommandManager::canRedo ( ) const
inline

Checks whether there are any commands available to redo.


Returns
True if at least one undone command can be redone.

Definition at line 138 of file DesignCommandManager.h.

References m_undone_commands.

◆ canUndo()

bool DesignCommandManager::canUndo ( ) const
inline

Checks whether there are any commands available to undo.


Returns
True if at least one command can be undone.

Definition at line 132 of file DesignCommandManager.h.

References m_undo_commands.

◆ clear()

void DesignCommandManager::clear ( )

Clears all stored commands, including undo, redo, and pending command histories.


◆ commandLock()

WLock DesignCommandManager::commandLock ( )

Acquires a write lock on the command system.


Returns
A WLock object that holds the write lock for its lifetime.

◆ commandReadLock()

RLock DesignCommandManager::commandReadLock ( )

Acquires a read lock on the command system.


Returns
An RLock object that holds the read lock for its lifetime.

◆ executeCommand()

virtual void DesignCommandManager::executeCommand ( DynamicPointer< DesignCommand > command)
virtual

Executes a command immediately within the command system.


Parameters
[in]commandThe command to execute.

◆ executePendingCommands()

void DesignCommandManager::executePendingCommands ( )

Executes all commands that have been posted but not yet run.


◆ finishCommand()

virtual void DesignCommandManager::finishCommand ( const DynamicPointer< DesignCommand > & command)
virtual

Marks a command as finished after execution completes.


Parameters
[in]commandThe command that has finished executing.

◆ getCommand()

const DynamicPointer< DesignCommand > & DesignCommandManager::getCommand ( UUID command_id) const

Retrieves a command by its UUID.


Parameters
[in]command_idThe UUID of the command to retrieve.
Returns
A const reference to the command pointer.

References command_id.

◆ hasCommand()

bool DesignCommandManager::hasCommand ( UUID id)

Checks whether a command with the given UUID exists in the manager.


Parameters
[in]idThe UUID of the command to look up.
Returns
True if the command exists, false otherwise.

◆ hasPendingCommands()

bool DesignCommandManager::hasPendingCommands ( ) const

Checks whether there are any commands waiting to be executed.


Returns
True if there are pending commands in the queue.

◆ lastPendingCommand()

const DynamicPointer< DesignCommand > & DesignCommandManager::lastPendingCommand ( ) const

Returns the most recently posted pending command.


Returns
A const reference to the last pending command pointer.

◆ postCommand() [1/2]

virtual void DesignCommandManager::postCommand ( const DynamicPointer< DesignCommand > & command)
virtual

Posts a command for deferred execution.


The command will be queued and executed later when executePendingCommands() is called.

Parameters
[in]commandThe command to post.

◆ postCommand() [2/2]

template<class t_type>
void DesignCommandManager::postCommand ( const DynamicPointer< t_type > & command)
inline

Posts a typed command for deferred execution.


Template convenience overload that casts the command to DesignCommand before posting.

Parameters
[in]commandThe typed command to post.

Definition at line 84 of file DesignCommandManager.h.

References postCommand().

Referenced by postCommand().

◆ redo()

Buffer< UUID > DesignCommandManager::redo ( )

Redoes the most recently undone command.


Returns
A buffer of UUIDs of design objects affected by the redo operation.

◆ runCommand() [1/2]

virtual void DesignCommandManager::runCommand ( const DynamicPointer< DesignCommand > & command)
virtual

Runs a command immediately within the command system.


Parameters
[in]commandThe command to run.

◆ runCommand() [2/2]

template<class t_type>
void DesignCommandManager::runCommand ( const DynamicPointer< t_type > & command)
inline

Runs a typed command immediately.


Template convenience overload that casts the command to DesignCommand before running.

Parameters
[in]commandThe typed command to run.

Definition at line 104 of file DesignCommandManager.h.

References runCommand().

Referenced by runCommand().

◆ tryCommandLock()

WLock DesignCommandManager::tryCommandLock ( )

Attempts to acquire a write lock on the command system without blocking.


Returns
A WLock object that may or may not hold the lock; caller should check validity.

◆ undo()

Buffer< UUID > DesignCommandManager::undo ( )

Undoes the most recent command.


Returns
A buffer of UUIDs of design objects affected by the undo operation.

◆ undoCommand()

virtual void DesignCommandManager::undoCommand ( UUID command)
virtual

Undoes a specific command identified by its UUID.


Parameters
[in]commandThe UUID of the command to undo.

◆ undoneCommands()

const Buffer< UUID > & DesignCommandManager::undoneCommands ( ) const
inline

Returns the list of command UUIDs that have been undone and are available for redo.


Returns
A const reference to the buffer of undone command UUIDs.

Definition at line 75 of file DesignCommandManager.h.

References m_undone_commands.


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