Class
BasicEditingDomain
Actor providing basic editing domain functionality for model modification coordination.
@MainActor final class BasicEditingDomain
Overview
The BasicEditingDomain serves as the central coordinator for all model modifications, integrating command execution, change notification, and resource management. It provides a unified interface for creating and executing commands while maintaining model consistency and enabling undo/redo capabilities.
Overview
The editing domain manages several key aspects of model editing:
-
Command Creation: Factory methods for common editing operations
-
Command Execution: Coordinated execution through the command stack
-
Change Notification: Broadcasting of model changes to observers
-
Resource Management: Coordination with resource sets and persistence
-
Transaction Support: Atomic operation grouping (future enhancement)
Concurrency Model
The BasicEditingDomain is implemented as an actor to ensure thread-safe access to the command stack and editing state. All model modifications are serialised through the actor’s message queue to prevent race conditions.
Example Usage
let editingDomain = BasicEditingDomain(resourceSet: myResourceSet)
// Create and execute a set command
let command = editingDomain.createSetCommand(
object: person,
feature: nameAttribute,
value: "John Doe"
)
let result = try await editingDomain.execute(command)
// Undo the change
try await editingDomain.undo()
Topics
Initializers
Creates a new basic editing domain.
Instance Properties
The command stack managing command execution and history.
Flag indicating if the editing domain is read-only.
Get the current read-only state.
The resource set containing the models being edited.
Current editing session statistics.
Instance Methods
Add an observer for editing domain changes.
Check if redo operation is available.
Check if undo operation is available.
Create a command to add a value to a many-valued feature.
Create a compound command from multiple commands.
Create a command to remove a value from a many-valued feature.
Create a command to set a property value on an object.
Execute a command through the editing domain.
Flush the command stack, clearing all history.
Get current editing domain statistics.
Get description of the next command that would be redone.
Get description of the next command that would be undone.
Redo the most recent undone command.
Remove an observer from editing domain changes.
Reset editing domain statistics.
Set the read-only state of the editing domain.
Undo the most recent command.
Relationships
Conforms To
See Also
Commands and Editing
Protocol defining a command that can be executed, undone, and redone.
Actor managing the execution and undo/redo history of EMF commands.