Isle
Loading...
Searching...
No Matches
legotree.h
Go to the documentation of this file.
1#ifndef __LEGOTREE_H
2#define __LEGOTREE_H
3
4#ifdef _DEBUG
5#include <stdio.h>
6#endif
7#include "legotypes.h"
8
9class LegoStorage;
10
16public:
19
21 // FUNCTION: LEGO1 0x1009a0e0
22 virtual ~LegoTreeNodeData() {}
23
27 // FUNCTION: LEGO1 0x10099fe0
28 virtual LegoResult Read(LegoStorage* p_storage) { return SUCCESS; } // vtable+0x04
29
33 // FUNCTION: LEGO1 0x10099ff0
34 virtual LegoResult Write(LegoStorage* p_storage) { return SUCCESS; } // vtable+0x08
35
36 // SYNTHETIC: LEGO1 0x1009a000
37 // LegoTreeNodeData::`scalar deleting destructor'
38};
39
45public:
48
50 virtual ~LegoTreeNode();
51
53 // FUNCTION: BETA10 0x100595a0
55
58 // FUNCTION: BETA10 0x100736f0
59 void SetData(LegoTreeNodeData* p_data) { m_data = p_data; }
60
62 // FUNCTION: BETA10 0x10012150
64
67 // FUNCTION: BETA10 0x10073370
68 void SetNumChildren(LegoU32 p_numChildren) { m_numChildren = p_numChildren; }
69
72 LegoTreeNode* GetChild(LegoU32 p_i) { return m_children[p_i]; }
73
77 void SetChild(LegoU32 p_i, LegoTreeNode* p_child) { m_children[p_i] = p_child; }
78
80 // FUNCTION: BETA10 0x100733a0
82
85 // FUNCTION: BETA10 0x10073720
86 void SetChildren(LegoTreeNode** p_children) { m_children = p_children; }
87
88 // SYNTHETIC: LEGO1 0x10099d80
89 // SYNTHETIC: BETA10 0x10188cb0
90 // LegoTreeNode::`scalar deleting destructor'
91
92protected:
96};
97
102class LegoTree {
103public:
105 LegoTree();
106
108 virtual ~LegoTree();
109
111 // FUNCTION: BETA10 0x100121b0
113
116 // FUNCTION: BETA10 0x10073750
117 void SetRoot(LegoTreeNode* p_root) { m_root = p_root; }
118
122 virtual LegoResult Read(LegoStorage* p_storage); // vtable+0x04
123
127 virtual LegoResult Write(LegoStorage* p_storage); // vtable+0x08
128
129 // SYNTHETIC: LEGO1 0x10099de0
130 // LegoTree::`scalar deleting destructor'
131
132protected:
137 LegoResult Read(LegoStorage* p_storage, LegoTreeNode*& p_node);
138
142 LegoResult Write(LegoStorage* p_storage, LegoTreeNode* p_node);
143
146 void Delete(LegoTreeNode* p_node);
147
150 // FUNCTION: LEGO1 0x10099f70
151 virtual LegoTreeNodeData* CreateData() { return new LegoTreeNodeData(); } // vtable+0x0c
152
154};
155
156#endif // __LEGOTREE_H
Abstract base class providing an interface for file-like storage with binary and text read/write oper...
Definition: legostorage.h:16
[AI] Abstract base class for storing data payloads inside nodes of a tree structure,...
Definition: legotree.h:15
LegoTreeNodeData()
[AI] Default constructor.
Definition: legotree.h:18
virtual LegoResult Read(LegoStorage *p_storage)
[AI] Virtual function for deserializing node data from a generic LegoStorage device.
Definition: legotree.h:28
virtual LegoResult Write(LegoStorage *p_storage)
[AI] Virtual function for serializing node data to a generic LegoStorage device.
Definition: legotree.h:34
virtual ~LegoTreeNodeData()
[AI] Virtual destructor for safe polymorphic deletion of derived classes.
Definition: legotree.h:22
[AI] Represents a node within a general, N-ary tree structure.
Definition: legotree.h:44
void SetData(LegoTreeNodeData *p_data)
[AI] Associates a data payload with this node.
Definition: legotree.h:59
LegoTreeNode()
[AI] Constructs an empty tree node with no children or data. [AI]
Definition: legotree.cpp:12
void SetChild(LegoU32 p_i, LegoTreeNode *p_child)
[AI] Assigns a child node pointer at the specified index in this node's children array.
Definition: legotree.h:77
LegoTreeNodeData * GetData()
[AI] Returns the data payload stored at this node (may be nullptr). [AI]
Definition: legotree.h:54
LegoTreeNode ** m_children
[AI] Pointer to array of tree node children (size = m_numChildren). nullptr if no children allocated....
Definition: legotree.h:95
LegoU32 GetNumChildren()
[AI] Returns the number of direct children of this node. [AI]
Definition: legotree.h:63
void SetChildren(LegoTreeNode **p_children)
[AI] Assigns the entire children pointer array.
Definition: legotree.h:86
LegoTreeNode * GetChild(LegoU32 p_i)
[AI] Gets the child node at the specified index (no bounds checking).
Definition: legotree.h:72
void SetNumChildren(LegoU32 p_numChildren)
[AI] Sets the number of children for this node (does not resize pointer array).
Definition: legotree.h:68
virtual ~LegoTreeNode()
[AI] Destructor cleans up node data and children recursively. [AI]
Definition: legotree.cpp:21
LegoU32 m_numChildren
[AI] Number of valid child pointers in m_children. [AI]
Definition: legotree.h:94
LegoTreeNodeData * m_data
[AI] Pointer to node data payload, owned by node. nullptr indicates no data present....
Definition: legotree.h:93
LegoTreeNode ** GetChildren()
[AI] Returns the pointer to the children array. [AI]
Definition: legotree.h:81
[AI] Represents an N-ary tree of LegoTreeNode objects, with support for recursive reading and writing...
Definition: legotree.h:102
LegoTreeNode * m_root
[AI] Root node of the tree. nullptr if tree is empty. Owned by the tree instance. [AI]
Definition: legotree.h:153
LegoTreeNode * GetRoot()
[AI] Returns a pointer to the root node of the tree. [AI]
Definition: legotree.h:112
virtual LegoResult Write(LegoStorage *p_storage)
[AI] Serializes the tree structure recursively to the given storage.
Definition: legotree.cpp:52
virtual LegoTreeNodeData * CreateData()
[AI] Virtual function to instantiate node payload objects for the tree structure.
Definition: legotree.h:151
LegoTree()
[AI] Constructs an empty tree (root not allocated). [AI]
Definition: legotree.cpp:32
void Delete(LegoTreeNode *p_node)
[AI] Recursively deletes an entire subtree starting at the given node.
Definition: legotree.cpp:106
virtual ~LegoTree()
[AI] Recursively destroys all tree nodes and their payloads. [AI]
Definition: legotree.cpp:38
void SetRoot(LegoTreeNode *p_root)
[AI] Assigns the root node pointer for the tree (takes ownership).
Definition: legotree.h:117
virtual LegoResult Read(LegoStorage *p_storage)
[AI] Loads the tree structure recursively from the given storage.
Definition: legotree.cpp:46
[AI] Defines basic fixed-width data types and platform-neutral constants for LEGO Island codebase.
unsigned long LegoU32
[AI] Unsigned 32-bit integer type for cross-platform compatibility.
Definition: legotypes.h:71
LegoS32 LegoResult
[AI] Function result type (return code): typically SUCCESS (0) or FAILURE (-1).
Definition: legotypes.h:101
#define SUCCESS
[AI] Used to indicate a successful operation in result codes.
Definition: legotypes.h:30