ChildrenNodes
- class ChildrenNodes
Container that stores a vector of children nodes.
This is the primary object to modify the model through. In order to maintain type invariants, relationships can only be constructed internally by this container using the provided relationship type. The related element type is then checked against the types supported by the relationship and the container. However, due to limitations in the Python type system, this check can only be done at runtime. In addition, type system limitations do not allow generic
TypeVarconstraints which prevents fully resolved return types in this generic implementation. Children
Members defined in
ChildrenNodes(11 members)
Append a new owned or referenced element, inferred from the relationship type and this container. Returns a pair of (relationship, element), only the relationship is newly constructed.
Clear all nodes from this container. Size is reset to 0 afterwards.
Extracts and returns the element from this container at the specified index without clearing its subtree. The relationship may be reused internally when constructing a new relationship of the same type, while the related element will not.
Extracts a related element from this container without clearing its subtree.
Removes a relationship and extracts its related element from this container without clearing its subtree.
Insert a relationship and a related element at the specified index. The related element may be owned or referenced depending on the relationship type and this container, see
appendfor more details.
Removes and returns a pair (relationship, element) from this container at the specified index. The relationship may be reused internally when constructing a new relationship of the same type, while the related element will only be reused if it was and owned related element. In this case, the related element may be assigned to a new owner in the same document. Note that removed owned related elements will have all the elements in the subtree removed as well.
Removes a related element from this container. Returns
Trueif the related element was removed, andFalseotherwise. Note that removed owned related elements will have all the elements in the subtree removed as well.
Removes a relationship and its related element from this container. Returns
Trueif the relationship was removed, andFalseotherwise. Note that removed owned related elements will have all the elements in the subtree removed as well.
Replace the relationship and its related element at the specified index. The relationship may be reused if its type matches the current relationship at that index. The related element may be owned or referenced depending on the relationship type and this container, see
appendfor more details.
Increase the capacity of the container. Size is not changed.
Members inherited from
ChildrenNodesView(6 members)
RThe related elements in this container.
RThe relationships in this container.
Methods
- append(relationship: type[syside.R], element: syside.M, name: syside.NameID = ...) tuple[syside.R, syside.M]
Append a new owned or referenced element, inferred from the relationship type and this container. Returns a pair of (relationship, element), only the relationship is newly constructed.
- clear() None
Clear all nodes from this container. Size is reset to 0 afterwards.
- extract(index: int = -1) syside.M
Extracts and returns the element from this container at the specified index without clearing its subtree. The relationship may be reused internally when constructing a new relationship of the same type, while the related element will not.
Note that it is up to the user to ensure that the returned orphan element is not leaked.
Raises
IndexErrorif index is out of bounds.
- extract_element(arg: syside.M, /) syside.M
Extracts a related element from this container without clearing its subtree.
Note that it is up to the user to ensure that the returned orphan element is not leaked.
Raises
ValueErrorif there is no such related element.
- extract_with_relationship(arg: syside.R, /) syside.M
Removes a relationship and extracts its related element from this container without clearing its subtree.
Note that it is up to the user to ensure that the returned orphan element is not leaked.
Raises
ValueErrorif there is no such relationship.
- insert(index: int, relationship: type[syside.R], element: syside.M, name: syside.NameID = ...) tuple[syside.R, syside.M]
Insert a relationship and a related element at the specified index. The related element may be owned or referenced depending on the relationship type and this container, see
appendfor more details.
- pop(index: int = -1) tuple[syside.R, syside.M]
Removes and returns a pair (relationship, element) from this container at the specified index. The relationship may be reused internally when constructing a new relationship of the same type, while the related element will only be reused if it was and owned related element. In this case, the related element may be assigned to a new owner in the same document. Note that removed owned related elements will have all the elements in the subtree removed as well.
- remove_element(arg: syside.M, /) bool
Removes a related element from this container. Returns
Trueif the related element was removed, andFalseotherwise. Note that removed owned related elements will have all the elements in the subtree removed as well.
- remove_relationship(arg: syside.R, /) bool
Removes a relationship and its related element from this container. Returns
Trueif the relationship was removed, andFalseotherwise. Note that removed owned related elements will have all the elements in the subtree removed as well.
- replace(index: int, relationship: type[syside.R], element: syside.M, name: syside.NameID = ...) tuple[syside.R, syside.M]
Replace the relationship and its related element at the specified index. The relationship may be reused if its type matches the current relationship at that index. The related element may be owned or referenced depending on the relationship type and this container, see
appendfor more details.
- reserve(arg: int, /) None
Increase the capacity of the container. Size is not changed.