The most commonly used change operation in SModel is the act of changing a feature. In order to set a value of a property, or assign a child or reference node of 0..1 or 1 cardinality, you can use straight assignment (with =) or the set operation. In order to add a child to 0..n or 1..n children collection, you can either use the.add operation from the collection language or call add next-sibling/add prev-sibling operations on a node<> passing another node as a parameter.
New node creation
There are several ways to create a new node:
- new operation: new node<Concept>()
- new instance operation on a model: model.newInstance()
- add new(Concept) and set new(Concept) operations applied to feature expressions
- replace with new(Concept) operation
- new root node(Concept) operation applied to a model. In this case the concept should be rootable
- new next-sibling<Concept>/new prev-sibling<Concept> operations adding new sibling to an existing node
To create a copy of an existing node, you can use the copy operation.
To replace a node with an instance of another node, you can use the 'replace with' operation. If you want to replace and create at the same time, there is a shortcut operation 'replace with new(Concept)', which takes a concept as a parameter.
Delete and detach operations
If you want to completely delete a node from the model, you can use the delete operation. In order to detach a node from it's parent only, so that you can for example attach the node to another parent later, you use the detach operation.