![]() |
NDEVR
API Documentation
|
Stores logic for performing, undoing, or redoing DesignCommands. More...
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< UUID > | redo () |
| 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< UUID > | undo () |
| 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< TranslatedString > | command_hint |
| A user-facing hint or description for the currently active command. | |
| Resource< UUID > | command_id |
| The UUID of the currently active command. | |
| Resource< bool > | command_lock |
| Whether the command system is currently locked, preventing new commands. | |
| Resource< TranslatedString > | command_name |
| The display name of the currently active command. | |
Protected Attributes | |
| Thread * | m_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. | |
| DesignObjectLookup * | m_lookup |
| The design object lookup used to resolve objects during command operations. | |
| Buffer< UUID > | m_pending_commands |
| Queue of command UUIDs waiting to be executed. | |
| Buffer< UUID > | m_thread_pending_commands |
| Commands posted from background threads, awaiting transfer to the main pending queue. | |
| Buffer< UUID > | m_undo_commands |
| Stack of command UUIDs available for undo (most recent last). | |
| Buffer< UUID > | m_undone_commands |
| Stack of command UUIDs that have been undone and are available for redo. | |
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.
Definition at line 20 of file DesignCommandManager.h.
| DesignCommandManager::DesignCommandManager | ( | DesignObjectLookup * | lookup, |
| InfoPipe * | log ) |
Constructs a DesignCommandManager.
| [in] | lookup | The design object lookup used to resolve design objects during command execution. |
| [in] | log | The logging pipe for recording command activity and diagnostics. |
|
virtual |
Virtual destructor for proper cleanup of derived classes.
|
inline |
Checks whether there are any commands available to redo.
Definition at line 138 of file DesignCommandManager.h.
References m_undone_commands.
|
inline |
Checks whether there are any commands available to undo.
Definition at line 132 of file DesignCommandManager.h.
References m_undo_commands.
| void DesignCommandManager::clear | ( | ) |
Clears all stored commands, including undo, redo, and pending command histories.
| WLock DesignCommandManager::commandLock | ( | ) |
Acquires a write lock on the command system.
| RLock DesignCommandManager::commandReadLock | ( | ) |
Acquires a read lock on the command system.
|
virtual |
Executes a command immediately within the command system.
| [in] | command | The command to execute. |
| void DesignCommandManager::executePendingCommands | ( | ) |
Executes all commands that have been posted but not yet run.
|
virtual |
Marks a command as finished after execution completes.
| [in] | command | The command that has finished executing. |
| const DynamicPointer< DesignCommand > & DesignCommandManager::getCommand | ( | UUID | command_id | ) | const |
Retrieves a command by its UUID.
| [in] | command_id | The UUID of the command to retrieve. |
References command_id.
| bool DesignCommandManager::hasCommand | ( | UUID | id | ) |
| bool DesignCommandManager::hasPendingCommands | ( | ) | const |
Checks whether there are any commands waiting to be executed.
| const DynamicPointer< DesignCommand > & DesignCommandManager::lastPendingCommand | ( | ) | const |
Returns the most recently posted pending command.
|
virtual |
Posts a command for deferred execution.
The command will be queued and executed later when executePendingCommands() is called.
| [in] | command | The command to post. |
|
inline |
Posts a typed command for deferred execution.
Template convenience overload that casts the command to DesignCommand before posting.
| [in] | command | The typed command to post. |
Definition at line 84 of file DesignCommandManager.h.
References postCommand().
Referenced by postCommand().
Redoes the most recently undone command.
|
virtual |
Runs a command immediately within the command system.
| [in] | command | The command to run. |
|
inline |
Runs a typed command immediately.
Template convenience overload that casts the command to DesignCommand before running.
| [in] | command | The typed command to run. |
Definition at line 104 of file DesignCommandManager.h.
References runCommand().
Referenced by runCommand().
| WLock DesignCommandManager::tryCommandLock | ( | ) |
Attempts to acquire a write lock on the command system without blocking.
Undoes the most recent command.
|
virtual |
Returns the list of command UUIDs that have been undone and are available for redo.
Definition at line 75 of file DesignCommandManager.h.
References m_undone_commands.