Ult3D
Implementation of "Ultimate 3D Game Engine Design & Architecture" by Allan Sherrod
Loading...
Searching...
No Matches
Node.h
Go to the documentation of this file.
1#ifndef ULT_NODE_H_INCLUDED
2#define ULT_NODE_H_INCLUDED
3
4namespace Ult
5{
6
11class Node
12{
13public:
17 Node() :
18 mNext(nullptr),
19 mPrev(nullptr),
20 mChild(nullptr)
21 {}
22
25 virtual ~Node() {
26 mPrev = nullptr;
27 if (mChild) {
28 delete mChild;
29 mChild = nullptr;
30 }
31 if (mNext) {
32 delete mNext;
33 mNext = nullptr;
34 }
35 }
36
40 void AddChild(Node* node) {
41 if (mChild == nullptr) {
42 mChild = node;
43 } else {
44 mChild->AddSibling(node);
45 }
46 }
47
50 void AddSibling(Node* node) {
51 Node* ptr = mNext;
52 if (mNext == nullptr) {
53 mNext = node;
54 node->mPrev = this;
55 } else {
56 while (ptr->mNext) {
57 ptr = ptr->mNext;
58 }
59 ptr->mNext = node;
60 node->mPrev = ptr;
61 }
62 }
63
67 virtual void Process() {
68 if (mChild) {
69 mChild->Process();
70 }
71 if (mNext) {
72 mNext->Process();
73 }
74 }
75protected:
79};
80
81} // namespace Ult
82
83#endif // ULT_NODE_H_INCLUDED
84
Node()
Definition Node.h:17
virtual ~Node()
Definition Node.h:25
Node * mNext
Definition Node.h:76
Node * mPrev
Definition Node.h:77
void AddSibling(Node *node)
Definition Node.h:50
Node * mChild
Definition Node.h:78
virtual void Process()
Definition Node.h:67
void AddChild(Node *node)
Definition Node.h:40
Definition Archive.h:13