TreeNode
Description
Note: Unlike most of the other documents in this SDK, this document is purely for educational purposes. You should not sub-class the TreeNode, nor access its members. You should instead use the standard commands available in FlexSim for manipulating and traversing FlexSim's tree.
The TreeNode class is the structure that makes up the backbone of FlexSim's tree structure. The treenode (all lower-case) type is defined (using a typedef) as a TreeNode*, so that the following lines are exactly equivalent.
TreeNode* someNode; treenode someNode;
An extremely simplified version of the TreeNode class is shown below.
Structure
A TreeNode object contains several pointers to other TreeNodes, including:
- A pointer to the "list head" or "owner" of the node. In the Flexsim tree view the list heads are not displayed. They would be the "0th" ranked object in a node's sub-tree.
- A pointer to a "branch" node if the node has sub-nodes. The branch node is the list head (0th ranked) node of the node's sub-tree.
- A pointer to a "parent" node. This points to the "up" node of the given node.
- A pointer to an array of treenodes, which represent the array of "owned" nodes. The list head's array member will point to the 0th index of the array, the next node will point to the 1st index, etc.
Below is an example diagram of a node with three sub-nodes.
Data
A TreeNode object also contains a void* called data that can point to any of the following types:
Data Type | Associated Macro |
---|---|
Number | DATA_FLOAT |
String | DATA_BYTEBLOCK |
Coupling | DATA_POINTERCOUPLING |
Object | DATA_OBJECT |
Bundle | DATA_BUNDLE |
Simple | DATA_SIMPLE |
Below is an example of a TreeNode pointing to number data. However, the number in this example could be replaced with any of the types listed above.