MorphologicalAttributeFilters
Public API documentation
Loading...
Searching...
No Matches
Classes | Public Member Functions | Friends | List of all members
mmcfilters::TreeEditor Class Reference

Thin edit-session facade for multi-step topology updates. More...

#include <TreeEditor.hpp>

Public Member Functions

 TreeEditor (const TreeEditor &)=delete
 
TreeEditoroperator= (const TreeEditor &)=delete
 
 TreeEditor (TreeEditor &&other) noexcept
 Transfers the open edit-session handle without closing it.
 
TreeEditoroperator= (TreeEditor &&)=delete
 
 ~TreeEditor ()=default
 Leaves an unfinished edit session open.
 
NodeId createDetachedNode ()
 Creates a live detached node in the topological hierarchy.
 
void detach (NodeId nodeId)
 Detaches one non-root node from the connected rooted component.
 
void reparent (NodeId nodeId, NodeId newParentId)
 Reparents one live non-root node under another live node.
 
void attach (NodeId parentId, NodeId detachedNodeId)
 Attaches one detached node back under the connected rooted tree.
 
void moveChildren (NodeId parentId, NodeId sourceId)
 Transfers every direct child of sourceId under parentId.
 
void moveProperPart (NodeId targetNodeId, NodeId sourceNodeId, NodeId properPartId)
 Transfers one direct proper part from sourceNodeId to targetNodeId.
 
void moveProperParts (NodeId targetNodeId, NodeId sourceNodeId)
 Transfers every direct proper part from sourceNodeId to targetNodeId.
 
void removeChild (NodeId parentNodeId, NodeId childId, bool releaseNodeFlag)
 Detaches a direct child from its parent and optionally releases an empty detached slot.
 
void releaseNode (NodeId nodeId)
 Releases an empty detached non-root node slot.
 
void setRoot (NodeId nodeId)
 Promotes nodeId to become the connected root.
 
void pruneNode (NodeId nodeId)
 Applies the committed-safe subtree prune inside the staged edit.
 
void mergeNodeIntoParent (NodeId nodeId)
 Applies the committed-safe parent merge inside the staged edit.
 
bool hasDetachedAliveNodes () const noexcept
 Returns whether the staged edit still has detached alive nodes.
 
TreeValidationResult validate () const noexcept
 Runs strong validation without closing the session.
 
TreeValidationResult validateAndCommit () noexcept
 Validates and closes the edit session on success.
 
void commit ()
 Finalizes the edit by validating that the tree is connected again.
 
void commitUnchecked () noexcept
 Finalizes a staged edit without running the linear validation.
 

Friends

class MorphologicalTree
 

Detailed Description

Thin edit-session facade for multi-step topology updates.

TreeEditor intentionally does not implement transactions or rollback. Its role is to make explicit that the caller is performing a staged edit where the tree may become temporarily disconnected, and to centralize the final strong validation in validateAndCommit() / commit().

Callers cannot construct TreeEditor directly. Use MorphologicalTree::edit() so the edit boundary remains explicit at the call site.

Definition at line 21 of file TreeEditor.hpp.

Constructor & Destructor Documentation

◆ TreeEditor()

mmcfilters::TreeEditor::TreeEditor ( TreeEditor &&  other)
inlinenoexcept

Transfers the open edit-session handle without closing it.

Definition at line 75 of file TreeEditor.hpp.

◆ ~TreeEditor()

mmcfilters::TreeEditor::~TreeEditor ( )
default

Leaves an unfinished edit session open.

There is intentionally no rollback in the destructor. Destroying an active editor without commit(), validateAndCommit(), or commitUnchecked() keeps the tree in editing mode so committed-tree APIs continue to reject it.

Member Function Documentation

◆ attach()

void mmcfilters::TreeEditor::attach ( NodeId  parentId,
NodeId  detachedNodeId 
)
inline

Attaches one detached node back under the connected rooted tree.

The node must be self-parented. Full connectivity and cycle validation remains the responsibility of commit() / validateAndCommit().

Definition at line 143 of file TreeEditor.hpp.

◆ commit()

void mmcfilters::TreeEditor::commit ( )
inline

Finalizes the edit by validating that the tree is connected again.

This validation is linear in the current dense internal-node domain plus the direct proper-part domain.

Definition at line 311 of file TreeEditor.hpp.

◆ commitUnchecked()

void mmcfilters::TreeEditor::commitUnchecked ( )
inlinenoexcept

Finalizes a staged edit without running the linear validation.

This is intended for internal algorithms that preserve the tree invariants by construction and may commit inside a hot loop. Public and test-facing edit sessions should keep using commit().

Definition at line 325 of file TreeEditor.hpp.

◆ createDetachedNode()

NodeId mmcfilters::TreeEditor::createDetachedNode ( )
inline

Creates a live detached node in the topological hierarchy.

The caller must attach or release the node before a checked commit can succeed.

Definition at line 98 of file TreeEditor.hpp.

◆ detach()

void mmcfilters::TreeEditor::detach ( NodeId  nodeId)
inline

Detaches one non-root node from the connected rooted component.

Definition at line 106 of file TreeEditor.hpp.

◆ hasDetachedAliveNodes()

bool mmcfilters::TreeEditor::hasDetachedAliveNodes ( ) const
inlinenoexcept

Returns whether the staged edit still has detached alive nodes.

Definition at line 278 of file TreeEditor.hpp.

◆ mergeNodeIntoParent()

void mmcfilters::TreeEditor::mergeNodeIntoParent ( NodeId  nodeId)
inline

Applies the committed-safe parent merge inside the staged edit.

Definition at line 269 of file TreeEditor.hpp.

◆ moveChildren()

void mmcfilters::TreeEditor::moveChildren ( NodeId  parentId,
NodeId  sourceId 
)
inline

Transfers every direct child of sourceId under parentId.

This keeps the operation local and does not run an ancestry check; callers that move children inside a subtree must repair or reject cycles before committing.

Definition at line 164 of file TreeEditor.hpp.

◆ moveProperPart()

void mmcfilters::TreeEditor::moveProperPart ( NodeId  targetNodeId,
NodeId  sourceNodeId,
NodeId  properPartId 
)
inline

Transfers one direct proper part from sourceNodeId to targetNodeId.

Moving one proper part is proportional to the linked-list update only; it does not rebuild the full ownership index.

Definition at line 181 of file TreeEditor.hpp.

◆ moveProperParts()

void mmcfilters::TreeEditor::moveProperParts ( NodeId  targetNodeId,
NodeId  sourceNodeId 
)
inline

Transfers every direct proper part from sourceNodeId to targetNodeId.

The underlying splice is linear only in the number of moved direct proper parts.

Definition at line 201 of file TreeEditor.hpp.

◆ pruneNode()

void mmcfilters::TreeEditor::pruneNode ( NodeId  nodeId)
inline

Applies the committed-safe subtree prune inside the staged edit.

Definition at line 260 of file TreeEditor.hpp.

◆ releaseNode()

void mmcfilters::TreeEditor::releaseNode ( NodeId  nodeId)
inline

Releases an empty detached non-root node slot.

Definition at line 229 of file TreeEditor.hpp.

◆ removeChild()

void mmcfilters::TreeEditor::removeChild ( NodeId  parentNodeId,
NodeId  childId,
bool  releaseNodeFlag 
)
inline

Detaches a direct child from its parent and optionally releases an empty detached slot.

Definition at line 215 of file TreeEditor.hpp.

◆ reparent()

void mmcfilters::TreeEditor::reparent ( NodeId  nodeId,
NodeId  newParentId 
)
inline

Reparents one live non-root node under another live node.

This is a staged structural edit: cycle freedom is enforced at commit time rather than by an ancestry walk on every call.

Definition at line 123 of file TreeEditor.hpp.

◆ setRoot()

void mmcfilters::TreeEditor::setRoot ( NodeId  nodeId)
inline

Promotes nodeId to become the connected root.

The previous root becomes detached; callers must reconnect or explicitly tolerate that state before a checked commit.

Definition at line 249 of file TreeEditor.hpp.

◆ validate()

TreeValidationResult mmcfilters::TreeEditor::validate ( ) const
inlinenoexcept

Runs strong validation without closing the session.

Definition at line 285 of file TreeEditor.hpp.

◆ validateAndCommit()

TreeValidationResult mmcfilters::TreeEditor::validateAndCommit ( )
inlinenoexcept

Validates and closes the edit session on success.

Definition at line 295 of file TreeEditor.hpp.

Friends And Related Symbol Documentation

◆ MorphologicalTree

Definition at line 22 of file TreeEditor.hpp.


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