orx  stable
Portable Game Engine
orxTree.h
Go to the documentation of this file.
1 /* Orx - Portable Game Engine
2  *
3  * Copyright (c) 2008-2017 Orx-Project
4  *
5  * This software is provided 'as-is', without any express or implied
6  * warranty. In no event will the authors be held liable for any damages
7  * arising from the use of this software.
8  *
9  * Permission is granted to anyone to use this software for any purpose,
10  * including commercial applications, and to alter it and redistribute it
11  * freely, subject to the following restrictions:
12  *
13  * 1. The origin of this software must not be misrepresented; you must not
14  * claim that you wrote the original software. If you use this software
15  * in a product, an acknowledgment in the product documentation would be
16  * appreciated but is not required.
17  *
18  * 2. Altered source versions must be plainly marked as such, and must not be
19  * misrepresented as being the original software.
20  *
21  * 3. This notice may not be removed or altered from any source
22  * distribution.
23  */
24 
43 #ifndef _orxTREE_H_
44 #define _orxTREE_H_
45 
46 
47 #include "orxInclude.h"
48 
49 #include "debug/orxDebug.h"
50 
51 
54 typedef struct __orxTREE_NODE_t
55 {
56  struct __orxTREE_NODE_t *pstParent;
57  struct __orxTREE_NODE_t *pstChild;
58  struct __orxTREE_NODE_t *pstSibling;
59  struct __orxTREE_NODE_t *pstPrevious;
60  struct __orxTREE_t *pstTree;
62 } orxTREE_NODE;
63 
66 typedef struct __orxTREE_t
67 {
69  orxU32 u32Counter;
71 } orxTREE;
72 
73 
78 extern orxDLLAPI orxSTATUS orxFASTCALL orxTree_Clean(orxTREE *_pstTree);
79 
85 extern orxDLLAPI orxSTATUS orxFASTCALL orxTree_AddRoot(orxTREE *_pstTree, orxTREE_NODE *_pstNode);
86 
92 extern orxDLLAPI orxSTATUS orxFASTCALL orxTree_AddParent(orxTREE_NODE *_pstRefNode, orxTREE_NODE *_pstNode);
93 
99 extern orxDLLAPI orxSTATUS orxFASTCALL orxTree_AddSibling(orxTREE_NODE *_pstRefNode, orxTREE_NODE *_pstNode);
100 
106 extern orxDLLAPI orxSTATUS orxFASTCALL orxTree_AddChild(orxTREE_NODE *_pstRefNode, orxTREE_NODE *_pstNode);
107 
113 extern orxDLLAPI orxSTATUS orxFASTCALL orxTree_MoveAsChild(orxTREE_NODE *_pstRefNode, orxTREE_NODE *_pstNode);
114 
119 extern orxDLLAPI orxSTATUS orxFASTCALL orxTree_Remove(orxTREE_NODE *_pstNode);
120 
121 
122 /* *** Tree inlined accessors *** */
123 
124 
129 static orxINLINE orxTREE * orxTree_GetTree(const orxTREE_NODE *_pstNode)
130 {
131  /* Checks */
132  orxASSERT(_pstNode != orxNULL);
133 
134  /* Returns it */
135  return(_pstNode->pstTree);
136 }
137 
142 static orxINLINE orxTREE_NODE * orxTree_GetParent(const orxTREE_NODE *_pstNode)
143 {
144  /* Checks */
145  orxASSERT(_pstNode != orxNULL);
146 
147  /* Returns it */
148  return((_pstNode->pstTree != orxNULL) ? _pstNode->pstParent : (orxTREE_NODE *)orxNULL);
149 }
150 
155 static orxINLINE orxTREE_NODE * orxTree_GetChild(const orxTREE_NODE *_pstNode)
156 {
157  /* Checks */
158  orxASSERT(_pstNode != orxNULL);
159 
160  /* Returns it */
161  return((_pstNode->pstTree != orxNULL) ? _pstNode->pstChild : (orxTREE_NODE *)orxNULL);
162 }
163 
168 static orxINLINE orxTREE_NODE * orxTree_GetSibling(const orxTREE_NODE *_pstNode)
169 {
170  /* Checks */
171  orxASSERT(_pstNode != orxNULL);
172 
173  /* Returns it */
174  return((_pstNode->pstTree != orxNULL) ? _pstNode->pstSibling : (orxTREE_NODE *)orxNULL);
175 }
176 
181 static orxINLINE orxTREE_NODE * orxTree_GetPrevious(const orxTREE_NODE *_pstNode)
182 {
183  /* Checks */
184  orxASSERT(_pstNode != orxNULL);
185 
186  /* Returns it */
187  return((_pstNode->pstTree != orxNULL) ? _pstNode->pstPrevious : (orxTREE_NODE *)orxNULL);
188 }
189 
190 
195 static orxINLINE orxTREE_NODE * orxTree_GetRoot(const orxTREE *_pstTree)
196 {
197  /* Checks */
198  orxASSERT(_pstTree != orxNULL);
199 
200  /* Returns it */
201  return(_pstTree->pstRoot);
202 }
203 
208 static orxINLINE orxU32 orxTree_GetCounter(const orxTREE *_pstTree)
209 {
210  /* Checks */
211  orxASSERT(_pstTree != orxNULL);
212 
213  /* Returns it */
214  return(_pstTree->u32Counter);
215 }
216 
217 #endif /* _orxTREE_H_ */
218 
orxDLLAPI orxSTATUS orxFASTCALL orxTree_AddChild(orxTREE_NODE *_pstRefNode, orxTREE_NODE *_pstNode)
struct __orxTREE_t * pstTree
Definition: orxTree.h:60
static orxINLINE orxTREE_NODE * orxTree_GetParent(const orxTREE_NODE *_pstNode)
Definition: orxTree.h:142
static orxINLINE orxTREE_NODE * orxTree_GetRoot(const orxTREE *_pstTree)
Definition: orxTree.h:195
orxDLLAPI orxSTATUS orxFASTCALL orxTree_Clean(orxTREE *_pstTree)
orxDLLAPI orxSTATUS orxFASTCALL orxTree_AddParent(orxTREE_NODE *_pstRefNode, orxTREE_NODE *_pstNode)
static orxINLINE orxTREE_NODE * orxTree_GetSibling(const orxTREE_NODE *_pstNode)
Definition: orxTree.h:168
struct __orxTREE_NODE_t * pstSibling
Definition: orxTree.h:58
static orxINLINE orxTREE_NODE * orxTree_GetChild(const orxTREE_NODE *_pstNode)
Definition: orxTree.h:155
struct __orxTREE_NODE_t * pstPrevious
Definition: orxTree.h:59
orxDLLAPI orxSTATUS orxFASTCALL orxTree_Remove(orxTREE_NODE *_pstNode)
orxDLLAPI orxSTATUS orxFASTCALL orxTree_MoveAsChild(orxTREE_NODE *_pstRefNode, orxTREE_NODE *_pstNode)
struct __orxTREE_NODE_t * pstParent
Definition: orxTree.h:56
orxSTATUS
Definition: orxType.h:243
orxDLLAPI orxSTATUS orxFASTCALL orxTree_AddSibling(orxTREE_NODE *_pstRefNode, orxTREE_NODE *_pstNode)
#define orxDLLAPI
Definition: orxDecl.h:387
orxDLLAPI orxSTATUS orxFASTCALL orxTree_AddRoot(orxTREE *_pstTree, orxTREE_NODE *_pstNode)
orxTREE_NODE * pstRoot
Definition: orxTree.h:68
static orxINLINE orxTREE * orxTree_GetTree(const orxTREE_NODE *_pstNode)
Definition: orxTree.h:129
static orxINLINE orxU32 orxTree_GetCounter(const orxTREE *_pstTree)
Definition: orxTree.h:208
orxU32 u32Counter
Definition: orxTree.h:69
static orxINLINE orxTREE_NODE * orxTree_GetPrevious(const orxTREE_NODE *_pstNode)
Definition: orxTree.h:181
#define orxASSERT(TEST,...)
Definition: orxDebug.h:298
struct __orxTREE_NODE_t * pstChild
Definition: orxTree.h:57

Generated for orx by doxygen 1.5.6