00001 /* Orx - Portable Game Engine 00002 * 00003 * Copyright (c) 2008-2011 Orx-Project 00004 * 00005 * This software is provided 'as-is', without any express or implied 00006 * warranty. In no event will the authors be held liable for any damages 00007 * arising from the use of this software. 00008 * 00009 * Permission is granted to anyone to use this software for any purpose, 00010 * including commercial applications, and to alter it and redistribute it 00011 * freely, subject to the following restrictions: 00012 * 00013 * 1. The origin of this software must not be misrepresented; you must not 00014 * claim that you wrote the original software. If you use this software 00015 * in a product, an acknowledgment in the product documentation would be 00016 * appreciated but is not required. 00017 * 00018 * 2. Altered source versions must be plainly marked as such, and must not be 00019 * misrepresented as being the original software. 00020 * 00021 * 3. This notice may not be removed or altered from any source 00022 * distribution. 00023 */ 00024 00043 #ifndef _orxTREE_H_ 00044 #define _orxTREE_H_ 00045 00046 00047 #include "orxInclude.h" 00048 00049 #include "debug/orxDebug.h" 00050 00051 00054 typedef struct __orxTREE_NODE_t 00055 { 00056 struct __orxTREE_NODE_t *pstParent; 00057 struct __orxTREE_NODE_t *pstChild; 00058 struct __orxTREE_NODE_t *pstSibling; 00059 struct __orxTREE_t *pstTree; 00061 } orxTREE_NODE; 00062 00065 typedef struct __orxTREE_t 00066 { 00067 orxTREE_NODE *pstRoot; 00068 orxU32 u32Counter; 00070 } orxTREE; 00071 00072 00077 extern orxDLLAPI orxSTATUS orxFASTCALL orxTree_Clean(orxTREE *_pstTree); 00078 00084 extern orxDLLAPI orxSTATUS orxFASTCALL orxTree_AddRoot(orxTREE *_pstTree, orxTREE_NODE *_pstNode); 00085 00091 extern orxDLLAPI orxSTATUS orxFASTCALL orxTree_AddParent(orxTREE_NODE *_pstRefNode, orxTREE_NODE *_pstNode); 00092 00098 extern orxDLLAPI orxSTATUS orxFASTCALL orxTree_AddChild(orxTREE_NODE *_pstRefNode, orxTREE_NODE *_pstNode); 00099 00105 extern orxDLLAPI orxSTATUS orxFASTCALL orxTree_MoveAsChild(orxTREE_NODE *_pstRefNode, orxTREE_NODE *_pstNode); 00106 00111 extern orxDLLAPI orxSTATUS orxFASTCALL orxTree_Remove(orxTREE_NODE *_pstNode); 00112 00113 00114 /* *** Tree inlined accessors *** */ 00115 00116 00121 static orxINLINE orxTREE * orxTree_GetTree(const orxTREE_NODE *_pstNode) 00122 { 00123 /* Checks */ 00124 orxASSERT(_pstNode != orxNULL); 00125 00126 /* Returns it */ 00127 return(_pstNode->pstTree); 00128 } 00129 00134 static orxINLINE orxTREE_NODE * orxTree_GetParent(const orxTREE_NODE *_pstNode) 00135 { 00136 /* Checks */ 00137 orxASSERT(_pstNode != orxNULL); 00138 00139 /* Returns it */ 00140 return((_pstNode->pstTree != orxNULL) ? _pstNode->pstParent : (orxTREE_NODE *)orxNULL); 00141 } 00142 00147 static orxINLINE orxTREE_NODE * orxTree_GetChild(const orxTREE_NODE *_pstNode) 00148 { 00149 /* Checks */ 00150 orxASSERT(_pstNode != orxNULL); 00151 00152 /* Returns it */ 00153 return((_pstNode->pstTree != orxNULL) ? _pstNode->pstChild : (orxTREE_NODE *)orxNULL); 00154 } 00155 00160 static orxINLINE orxTREE_NODE * orxTree_GetSibling(const orxTREE_NODE *_pstNode) 00161 { 00162 /* Checks */ 00163 orxASSERT(_pstNode != orxNULL); 00164 00165 /* Returns it */ 00166 return((_pstNode->pstTree != orxNULL) ? _pstNode->pstSibling : (orxTREE_NODE *)orxNULL); 00167 } 00168 00169 00174 static orxINLINE orxTREE_NODE * orxTree_GetRoot(const orxTREE *_pstTree) 00175 { 00176 /* Checks */ 00177 orxASSERT(_pstTree != orxNULL); 00178 00179 /* Returns it */ 00180 return(_pstTree->pstRoot); 00181 } 00182 00187 static orxINLINE orxU32 orxTree_GetCounter(const orxTREE *_pstTree) 00188 { 00189 /* Checks */ 00190 orxASSERT(_pstTree != orxNULL); 00191 00192 /* Returns it */ 00193 return(_pstTree->u32Counter); 00194 } 00195 00196 #endif /* _orxTREE_H_ */ 00197
1.5.6