Isle
Loading...
Searching...
No Matches
LegoTree Class Reference

[AI] Represents an N-ary tree of LegoTreeNode objects, with support for recursive reading and writing of tree structures. More...

#include <legotree.h>

Inheritance diagram for LegoTree:
Collaboration diagram for LegoTree:

Public Member Functions

 LegoTree ()
 [AI] Constructs an empty tree (root not allocated). [AI] More...
 
virtual ~LegoTree ()
 [AI] Recursively destroys all tree nodes and their payloads. [AI] More...
 
LegoTreeNodeGetRoot ()
 [AI] Returns a pointer to the root node of the tree. [AI] More...
 
void SetRoot (LegoTreeNode *p_root)
 [AI] Assigns the root node pointer for the tree (takes ownership). More...
 
virtual LegoResult Read (LegoStorage *p_storage)
 [AI] Loads the tree structure recursively from the given storage. More...
 
virtual LegoResult Write (LegoStorage *p_storage)
 [AI] Serializes the tree structure recursively to the given storage. More...
 

Protected Member Functions

LegoResult Read (LegoStorage *p_storage, LegoTreeNode *&p_node)
 [AI] Reads a subtree recursively from storage, creating a new node and reading its data/children. More...
 
LegoResult Write (LegoStorage *p_storage, LegoTreeNode *p_node)
 [AI] Writes a subtree recursively to storage from the given node. More...
 
void Delete (LegoTreeNode *p_node)
 [AI] Recursively deletes an entire subtree starting at the given node. More...
 
virtual LegoTreeNodeDataCreateData ()
 [AI] Virtual function to instantiate node payload objects for the tree structure. More...
 

Protected Attributes

LegoTreeNodem_root
 [AI] Root node of the tree. nullptr if tree is empty. Owned by the tree instance. [AI] More...
 

Detailed Description

[AI] Represents an N-ary tree of LegoTreeNode objects, with support for recursive reading and writing of tree structures.

[AI]

[AI] This class owns its root node and manages serialization/deserialization of the entire tree to a LegoStorage stream via virtual node data creation. [AI] Size: 0x08 bytes [AI]

Definition at line 102 of file legotree.h.

Constructor & Destructor Documentation

◆ LegoTree()

LegoTree::LegoTree ( )

[AI] Constructs an empty tree (root not allocated). [AI]

Definition at line 32 of file legotree.cpp.

◆ ~LegoTree()

LegoTree::~LegoTree ( )
virtual

[AI] Recursively destroys all tree nodes and their payloads. [AI]

Definition at line 38 of file legotree.cpp.

Member Function Documentation

◆ CreateData()

virtual LegoTreeNodeData * LegoTree::CreateData ( )
inlineprotectedvirtual

[AI] Virtual function to instantiate node payload objects for the tree structure.

[AI]

[AI] Intended for overriding in derived tree classes to allocate node data of specific subclass types; default returns new LegoTreeNodeData().

Reimplemented in LegoAnim.

Definition at line 151 of file legotree.h.

◆ Delete()

void LegoTree::Delete ( LegoTreeNode p_node)
protected

[AI] Recursively deletes an entire subtree starting at the given node.

[AI]

Parameters
p_nodeNode at which to begin deletion (includes all children). [AI]

Definition at line 106 of file legotree.cpp.

◆ GetRoot()

LegoTreeNode * LegoTree::GetRoot ( )
inline

[AI] Returns a pointer to the root node of the tree. [AI]

Definition at line 112 of file legotree.h.

◆ Read() [1/2]

LegoResult LegoTree::Read ( LegoStorage p_storage)
virtual

[AI] Loads the tree structure recursively from the given storage.

[AI]

Parameters
p_storageStorage stream to read from. [AI]

[AI] Recursively constructs tree structure and node payloads using CreateData() and each node's Read(). [AI]

Definition at line 46 of file legotree.cpp.

◆ Read() [2/2]

LegoResult LegoTree::Read ( LegoStorage p_storage,
LegoTreeNode *&  p_node 
)
protected

[AI] Reads a subtree recursively from storage, creating a new node and reading its data/children.

[AI]

Parameters
p_storageReading source. [AI]
p_nodeReference to pointer which will be assigned to the created node. [AI]

[AI] Called internally for recursive loading; constructs nodes and their payloads and child pointers. [AI]

Definition at line 58 of file legotree.cpp.

◆ SetRoot()

void LegoTree::SetRoot ( LegoTreeNode p_root)
inline

[AI] Assigns the root node pointer for the tree (takes ownership).

[AI]

Parameters
p_rootPointer to a LegoTreeNode heap object. [AI]

Definition at line 117 of file legotree.h.

◆ Write() [1/2]

LegoResult LegoTree::Write ( LegoStorage p_storage)
virtual

[AI] Serializes the tree structure recursively to the given storage.

[AI]

Parameters
p_storageStorage stream to write to. [AI]

[AI] Recursively traverses all nodes and their children, writing data and structure. [AI]

Reimplemented in LegoAnim.

Definition at line 52 of file legotree.cpp.

◆ Write() [2/2]

LegoResult LegoTree::Write ( LegoStorage p_storage,
LegoTreeNode p_node 
)
protected

[AI] Writes a subtree recursively to storage from the given node.

[AI]

Parameters
p_storageTarget for writing. [AI]
p_nodeNode from which to begin recursive writing. [AI]

Definition at line 85 of file legotree.cpp.

Member Data Documentation

◆ m_root

LegoTreeNode* LegoTree::m_root
protected

[AI] Root node of the tree. nullptr if tree is empty. Owned by the tree instance. [AI]

Definition at line 153 of file legotree.h.


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