TexGen
ShinyNode.h
Go to the documentation of this file.
1/*
2The zlib/libpng License
3
4Copyright (c) 2007 Aidin Abedi (www.*)
5
6This software is provided 'as-is', without any express or implied warranty. In no event will
7the authors be held liable for any damages arising from the use of this software.
8
9Permission is granted to anyone to use this software for any purpose, including commercial
10applications, and to alter it and redistribute it freely, subject to the following
11restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not claim that
14 you wrote the original software. If you use this software in a product,
15 an acknowledgment in the product documentation would be appreciated but is
16 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 distribution.
22*/
23
24#ifndef SHINY_NODE_H
25#define SHINY_NODE_H
26
27#include "ShinyData.h"
28#include "ShinyTools.h"
29
30#if SHINY_PROFILER == TRUE
31namespace Shiny {
32
33
34//-----------------------------------------------------------------------------
35
36 struct ProfileNode {
37
38 //NOTE: data-members are intentionally public because the
39 // class needs to fulfil the definition of an aggregate
40
41
43
47
50
51 uint32_t childCount;
52 uint32_t entryLevel;
53
55
57
59
60 //
61
62 void init(ProfileNode* a_parent, ProfileZone* a_zone, ProfileNodeCache* a_cache) {
63 // NOTE: all member variables are assumed to be zero when allocated
64
65 zone = a_zone;
66 parent = a_parent;
67
68 entryLevel = a_parent->entryLevel + 1;
69 a_parent->addChild(this);
70
71 _cache = a_cache;
72 }
73
74 void addChild(ProfileNode* a_child) {
75 if (childCount++) {
76 lastChild->nextSibling = a_child;
77 lastChild = a_child;
78
79 } else {
80 lastChild = a_child;
81 firstChild = a_child;
82 }
83 }
84
85 void updateTree(float a_damping);
86
87 void destroy(void) { *_cache = &_dummy; }
88
89 SHINY_INLINE void appendTicks(tick_t a_elapsedTicks) { _last.selfTicks += a_elapsedTicks; }
91
92 bool isRoot(void) const { return (entryLevel == 0); }
93 bool isDummy(void) const { return (this == &_dummy); }
94
95 bool isEqual(const ProfileNode* a_parent, const ProfileZone* a_zone) const {
96 return (parent == a_parent && zone == a_zone);
97 }
98
99 const ProfileNode* findNextInTree(void) const;
100
101 void clear(void);
102 };
103
104} // namespace Shiny
105#endif // if SHINY_PROFILER == TRUE
106
107#endif // ifndef SHINY_*_H
#define SHINY_INLINE
Definition: ShinyPrereqs.h:55
uint64_t tick_t
Definition: ShinyPrereqs.h:77
SHINY_INLINE void appendTicks(tick_t a_elapsedTicks)
Definition: ShinyNode.h:89
uint32_t entryLevel
Definition: ShinyNode.h:52
ProfileLastData _last
Definition: ShinyNode.h:42
ProfileNode * firstChild
Definition: ShinyNode.h:48
SHINY_INLINE void beginEntry(void)
Definition: ShinyNode.h:90
static ProfileNode _dummy
Definition: ShinyNode.h:58
ProfileNode * nextSibling
Definition: ShinyNode.h:46
const ProfileNode * findNextInTree(void) const
bool isRoot(void) const
Definition: ShinyNode.h:92
void updateTree(float a_damping)
bool isEqual(const ProfileNode *a_parent, const ProfileZone *a_zone) const
Definition: ShinyNode.h:95
ProfileData data
Definition: ShinyNode.h:56
uint32_t childCount
Definition: ShinyNode.h:51
ProfileNode * parent
Definition: ShinyNode.h:45
void addChild(ProfileNode *a_child)
Definition: ShinyNode.h:74
void destroy(void)
Definition: ShinyNode.h:87
ProfileNode * lastChild
Definition: ShinyNode.h:49
ProfileNodeCache * _cache
Definition: ShinyNode.h:54
ProfileZone * zone
Definition: ShinyNode.h:44
void init(ProfileNode *a_parent, ProfileZone *a_zone, ProfileNodeCache *a_cache)
Definition: ShinyNode.h:62
bool isDummy(void) const
Definition: ShinyNode.h:93