AuboStudio SDK  0.6.3
arcs::aubo_scope::TreeNode类 参考

\chinese 树节点 此接口表示程序树中的一个节点,可用于构建以 AuboCap 程序节点为根的子树。 更多...

#include <tree_node.h>

Public 成员函数

 TreeNode (TreeNode &f)
 TreeNode (TreeNode &&f)
virtual ~TreeNode ()
TreeNodePtr addChild (ProgramNodePtr program_node)
 \chinese 向子树添加一个子程序节点。
TreeNodePtr insertChildBefore (TreeNodePtr existingChildNode, ProgramNodePtr program_node)
 \chinese 在子树中,在现有选中子节点之前插入一个子程序节点。将选中子节点及其后的节点 移到新添加子节点之后的位置。
TreeNodePtr insertChildAfter (TreeNodePtr existingChildNode, ProgramNodePtr program_node)
 \chinese 在子树中,在现有选中子节点之后插入一个子程序节点。将后续节点移到新添加 子节点之后的位置。
TreeNodePtr cutChildNode (TreeNodePtr child)
 \chinese 剪切子树中的一个子程序节点。
bool removeChild (TreeNodePtr program_node)
 \chinese 从子树中移除子节点。注意:移除最后一个子节点将触发插入一个 <empty> 子节点。
std::vector< TreeNodePtr > getChildren ()
 \chinese
std::vector< TreeNodePtr > getChildrenNotSuppressed ()
TreeNodePtr getParent ()
 \chinese
ProgramNodePtr getProgramNode ()
 \chinese
bool isSuppressed ()
bool isInProgramTree ()
 \chinese 节点是否在程序树中;不在程序树中的节点可能已被剪切或删除。
TreeNodePtr locateDescendantTreeNode (ProgramNodePtr program_node)
 \chinese
void setChildSequenceLocked (bool isChildSequenceLocked)
 \chinese 配置子节点是否可被终端用户重新排列、删除或将其他节点插入到子节点序列中。
int traverse (std::function< int(ProgramNodePtr, int, int)> nodeVisitor)
 \chinese

Private 成员函数

 TreeNode ()

Private 属性

void * d_ { nullptr }

友元

class DataSwitch

详细描述

\chinese 树节点 此接口表示程序树中的一个节点,可用于构建以 AuboCap 程序节点为根的子树。

使用 ProgramModel#getRootTreeNode(ProgramNodeContribution) 获取子树 的根节点后,即可添加子节点。每次调用 TreeNode#addChild(ProgramNode) 都会返回一个新的 TreeNode,该节点又可以作为另一个子树的根节点。 \endchinese \english TreeNode This interface represents a node in the program tree that can be used to construct a sub-tree rooted in a AuboCap program node.

Using the ProgramModel#getRootTreeNode(ProgramNodeContribution) to obtain a root for the sub-tree, it is possible to add children. For each call to TreeNode#addChild(ProgramNode), a new TreeNode is returned, that can, in turn, act as a root for yet another sub-tree. \endenglish

在文件 tree_node.h32 行定义.

构造及析构函数说明

◆ TreeNode() [1/3]

arcs::aubo_scope::TreeNode::TreeNode ( TreeNode & f)

引用了 TreeNode().

被这些函数引用 TreeNode() , 以及 TreeNode().

函数调用图:
这是这个函数的调用关系图:

◆ TreeNode() [2/3]

arcs::aubo_scope::TreeNode::TreeNode ( TreeNode && f)

引用了 TreeNode().

函数调用图:

◆ ~TreeNode()

virtual arcs::aubo_scope::TreeNode::~TreeNode ( )
virtual

◆ TreeNode() [3/3]

arcs::aubo_scope::TreeNode::TreeNode ( )
private

成员函数说明

◆ addChild()

TreeNodePtr arcs::aubo_scope::TreeNode::addChild ( ProgramNodePtr program_node)

\chinese 向子树添加一个子程序节点。

参数
program_node使用 ProgramNodeFactory 构建的 ProgramNode
返回
返回一个 TreeNode,可用于向新添加的子节点添加子节点。
异常
TreeStructureException如果不允许在此位置插入 ProgramNode
IllegalStateException如果在 UndoableChanges 范围外从基于 Qt 的 AuboCap 调用 \endchinese \english Add a child program node to the sub-tree.
参数
program_nodethe ProgramNode constructed using the ProgramNodeFactory
返回
Returns a TreeNode that can be used to add children to the newly added child.
异常
TreeStructureExceptionIf it is not allowed to insert the ProgramNode at this position a TreeStructureException will be thrown.
IllegalStateExceptionif called from a Qt-based AuboCap outside of an UndoableChanges scope (see also UndoRedoManager). \endenglish

◆ cutChildNode()

TreeNodePtr arcs::aubo_scope::TreeNode::cutChildNode ( TreeNodePtr child)

\chinese 剪切子树中的一个子程序节点。

参数
childTreeNode 的现有 TreeNode 子节点
返回
返回被剪切掉的 TreeNode
异常
TreeStructureException如果不允许剪切此 ProgramNode 或子节点不是 此 TreeNode 的子节点
IllegalStateException如果在 UndoableChanges 范围外调用 \endchinese \english Cut a child program node under in the sub-tree directly after the existing selected child node. Shifts any subsequent nodes to positions after the newly added child.
参数
childexisting TreeNode child of this TreeNode.
返回
Returns the TreeNode that has been cut off.
异常
TreeStructureExceptionIf it is not allowed to cut the ProgramNode or if the selected child node is not a child of this TreeNode a TreeStructureException will be thrown.
IllegalStateExceptionif called from a Qt-based AuboCap outside of an UndoableChanges scope (see also UndoRedoManager). \endenglish

◆ getChildren()

std::vector< TreeNodePtr > arcs::aubo_scope::TreeNode::getChildren ( )

\chinese

返回
TreeNode 对象列表,表示此 TreeNode 的所有子节点(包括以编程方式 添加的和终端用户插入的) \endchinese \english
a list of TreeNode objects that represents all the children of this TreeNode (both programmatically added as well as inserted by the end user). \endenglish

◆ getChildrenNotSuppressed()

std::vector< TreeNodePtr > arcs::aubo_scope::TreeNode::getChildrenNotSuppressed ( )

◆ getParent()

TreeNodePtr arcs::aubo_scope::TreeNode::getParent ( )

\chinese

返回
节点的父 TreeNode \endchinese \english
Parent treenode of the node \endenglish

◆ getProgramNode()

ProgramNodePtr arcs::aubo_scope::TreeNode::getProgramNode ( )

\chinese

返回
返回子树中此位置的 ProgramNode。可以是内置 AuboScope 程序节点 或 AuboCap 程序节点。 \endchinese \english
Returns the ProgramNode at this position in the sub-tree. Can either be a built-in AuboScope program node (provided by AUBO Robots) or a AuboCap program node. \endenglish

◆ insertChildAfter()

TreeNodePtr arcs::aubo_scope::TreeNode::insertChildAfter ( TreeNodePtr existingChildNode,
ProgramNodePtr program_node )

\chinese 在子树中,在现有选中子节点之后插入一个子程序节点。将后续节点移到新添加 子节点之后的位置。

参数
existingChildNodeTreeNode 的现有 TreeNode 子节点
program_node使用 ProgramNodeFactory 构建的 ProgramNode
返回
返回一个 TreeNode,可用于向新添加的子节点添加子节点。
异常
TreeStructureException如果不允许在此位置插入或选中子节点不是 此 TreeNode 的子节点
IllegalStateException如果在 UndoableChanges 范围外调用 \endchinese \english Inserts a child program node under in the sub-tree directly after the existing selected child node. Shifts any subsequent nodes to positions after the newly added child.
参数
existingChildNodeexisting TreeNode child of this TreeNode.
program_nodethe ProgramNode constructed using the ProgramNodeFactory.
返回
Returns a TreeNode that can be used to add children to the newly added child.
异常
TreeStructureExceptionIf it is not allowed to insert the ProgramNode at this position or if the selected child node is not a child of this TreeNode a TreeStructureException will be thrown.
IllegalStateExceptionif called from a Qt-based AuboCap outside of an UndoableChanges scope (see also UndoRedoManager). \endenglish

◆ insertChildBefore()

TreeNodePtr arcs::aubo_scope::TreeNode::insertChildBefore ( TreeNodePtr existingChildNode,
ProgramNodePtr program_node )

\chinese 在子树中,在现有选中子节点之前插入一个子程序节点。将选中子节点及其后的节点 移到新添加子节点之后的位置。

参数
existingChildNodeTreeNode 的现有 TreeNode 子节点
program_node使用 ProgramNodeFactory 构建的 ProgramNode
返回
返回一个 TreeNode,可用于向新添加的子节点添加子节点。
异常
TreeStructureException如果不允许在此位置插入或选中子节点不是 此 TreeNode 的子节点
IllegalStateException如果在 UndoableChanges 范围外调用 \endchinese \english Inserts a child program node in the sub-tree directly before the existing selected child node. Shifts the selected child node and any subsequent nodes to positions after the newly added child.
参数
existingChildNodeexisting TreeNode child of this TreeNode.
program_nodethe ProgramNode constructed using the ProgramNodeFactory.
返回
Returns a TreeNode that can be used to add children to the newly added child.
异常
TreeStructureExceptionIf it is not allowed to insert the ProgramNode at this position or if the selected child node is not a child of this TreeNode a TreeStructureException will be thrown.
IllegalStateExceptionif called from a Qt-based AuboCap outside of an UndoableChanges scope (see also UndoRedoManager). \endenglish

◆ isInProgramTree()

bool arcs::aubo_scope::TreeNode::isInProgramTree ( )

\chinese 节点是否在程序树中;不在程序树中的节点可能已被剪切或删除。

返回
true 节点在程序树中, false 节点不在程序树中(可能已被剪切或删除) \endchinese \english Whether the node is in the program tree; nodes not in the program tree may have been cut or deleted.
Returns true The node is in the program tree. false The node is not in the program tree; such nodes may have been cut or deleted. \endenglish

◆ isSuppressed()

bool arcs::aubo_scope::TreeNode::isSuppressed ( )

◆ locateDescendantTreeNode()

TreeNodePtr arcs::aubo_scope::TreeNode::locateDescendantTreeNode ( ProgramNodePtr program_node)

\chinese

获取此 TreeNode 下子树中子程序节点(ProgramNode 实例)对应的 TreeNode 实例。

此方法可用于在遍历父节点子树时,获取遇到子程序节点下的子树访问权限。

参数
program_node需要获取对应 TreeNode 表示的程序节点,不能为 null
返回
指定程序节点的 TreeNode 实例
异常
ProgramNodeNotInSubTreeException当程序节点不在子树中时 \endchinese \english

Gets a corresponding TreeNode instance for a child program node (a ProgramNode instance) in the sub-tree under this TreeNode.

This method can for instance be used to gain access to the sub-tree under a child program node encountered when iterating the sub-tree of the parent node using the ProgramNodeVisitor (or any derived sub class thereof).

参数
program_nodeprogram node to get a corresponding TreeNode representation for, not null. Can either be a built-in AuboScope program node (provided by AUBO Robots) or a AuboCap program node.
返回
the TreeNode instance for the specified program node.
异常
ProgramNodeNotInSubTreeExceptionwhen the program node cannot be found because it is not in the sub-tree. \endenglish

◆ removeChild()

bool arcs::aubo_scope::TreeNode::removeChild ( TreeNodePtr program_node)

\chinese 从子树中移除子节点。注意:移除最后一个子节点将触发插入一个 <empty> 子节点。

参数
program_node要移除的 TreeNode 子节点
返回
成功移除返回 true,否则返回 false
异常
TreeStructureException如果移除子节点会使树处于非法状态
IllegalStateException如果在 UndoableChanges 范围外调用 \endchinese \english Removes a child node from the sub-tree. Be aware that removing the last child will trigger the insertion of an <empty> child node.
参数
program_nodeThe TreeNode child to be removed.
返回
Returns true if removed successfully. false otherwise.
异常
TreeStructureExceptionIf the removed child would leave the tree in an illegal state a TreeStructureException will be thrown.
IllegalStateExceptionif called from a Qt-based AuboCap outside of an UndoableChanges scope (see also UndoRedoManager). \endenglish

◆ setChildSequenceLocked()

void arcs::aubo_scope::TreeNode::setChildSequenceLocked ( bool isChildSequenceLocked)

\chinese 配置子节点是否可被终端用户重新排列、删除或将其他节点插入到子节点序列中。

参数
isChildSequenceLocked如果为 true,则此 TreeNode 下的直接子节点将被锁定 \endchinese \english Configures whether or not child nodes can be rearranged, deleted or have other nodes inserted into the child sequence by the end user.
isChildSequenceLockedIf true then the immediate children under this TreeNode will be locked. \endenglish

◆ traverse()

int arcs::aubo_scope::TreeNode::traverse ( std::function< int(ProgramNodePtr, int, int)> nodeVisitor)

\chinese

此方法以深度优先方式遍历此树节点下的整个子树(对应于程序树中的自顶向下方式)。

使用节点访问器进行回调,回调的重载取决于遇到的节点类型。

所有 visit 方法都具有程序节点、兄弟索引和深度作为参数,以便在需要时过滤节点。

参数
nodeVisitor回调实例
返回
0 表示正常退出,非零表示异常或错误导致提前退出 \endchinese \english

This method traverses the entire sub-tree under this tree node in a depth-first fashion (this corresponds to a top-down approach in the program tree).

A node visitor is used for callbacks to the visit-overloads you choose to override. The overload called depends on the node type encountered. Override the overloads for the node types you are concerned with. All visit-methods have the program node, sibling index and depth as arguments to help filter nodes if needed.

The node visitor can be either a ProgramNodeVisitor implementation with optional overrides or a ProgramNodeInterfaceVisitor implementation. In the latter case, the ProgramNodeInterfaceVisitor#visitAs(Object, int, int) method must be implemented.

The ProgramNodeInterfaceVisitor can be used when targeting AuboCap program nodes implementing the (generic) type parameter specified in ProgramNodeInterfaceVisitor (see also ProgramNode#getAs(Class)).

Note that this method is sometimes called accept() in the Visitor software design pattern.

参数
nodeVisitorthe instance callbacks are made to.
返回
0 for normal exit. non-zero for exception or error causing premature exit. \endenglish

◆ DataSwitch

friend class DataSwitch
friend

在文件 tree_node.h342 行定义.

引用了 DataSwitch.

被这些函数引用 DataSwitch.

类成员变量说明

◆ d_

void* arcs::aubo_scope::TreeNode::d_ { nullptr }
private

在文件 tree_node.h344 行定义.


该类的文档由以下文件生成:
  • include/aubo_caps/domain/program/structure/tree_node.h