OpenBarnyard
 
Loading...
Searching...
No Matches
TTask.cpp
Go to the documentation of this file.
1#include "ToshiPCH.h"
2#include "TTask.h"
3
4//-----------------------------------------------------------------------------
5// Enables memory debugging.
6// Note: Should be the last include!
7//-----------------------------------------------------------------------------
9
11
13
15{
16 m_State = 0;
17}
18
20{
21 TASSERT( IsLinked() == TFALSE );
22}
23
25{
26 TASSERT( IsCreated() == TFALSE );
27
28 if ( !IsCreated() )
29 {
30 if ( !OnCreate() )
31 {
32 OnDestroy();
33 m_Tree->Remove( this, TFALSE );
34 Delete();
35
36 return TFALSE;
37 }
38
39 TUINT32 oldState = m_State;
40 m_State |= State_Created;
41 Activate( TTRUE );
42 }
43
44 return TTRUE;
45}
46
48{
49 TASSERT( IsCreated() == TFALSE );
50
51 if ( !IsCreated() )
52 {
53 m_Tree->Remove( this, TFALSE );
54 Delete();
55 }
56
57 return TFALSE;
58}
59
61{
62 TTask* firstAttached = Child();
63 TTask* node = firstAttached;
64 TBOOL result = TTRUE;
65
66 while ( node != TNULL && node != firstAttached )
67 {
68 result &= node->Reset();
69 node = node->Next();
70 }
71
72 return result;
73}
74
76{
77 return TTRUE;
78}
79
81{
82 return TTRUE;
83}
84
86{
87}
88
90{
91}
92
94{
95 return TTRUE;
96}
97
98void TTask::OnChildDied( TClass* pClass, TTask* deletedTask )
99{
100}
101
103{
104}
105
107{
108}
109
110void TTask::Activate( TBOOL activate )
111{
112 TUINT8 oldState = m_State;
113 TUINT8 newFlags = activate ? State_Active : 0;
114
115 m_State = ( m_State & ~State_Active ) | newFlags;
116
117 if ( oldState != m_State )
118 {
119 if ( activate )
120 {
121 OnActivate();
122 }
123 else
124 {
125 OnDeactivate();
126 }
127 }
128}
129
130void TTask::SetParent( TTask* a_pAttachTo )
131{
132 if ( this != Parent() && a_pAttachTo != TNULL )
133 {
134 Tree()->ReInsert( this != Parent() ? a_pAttachTo : TNULL, this );
135 }
136}
137
#define TASSERT(X,...)
Definition Defines.h:138
#define TOSHI_NAMESPACE_START
Definition Defines.h:47
#define TOSHI_NAMESPACE_END
Definition Defines.h:50
#define TDEFINE_CLASS_NORUNTIME(...)
Definition TObject.h:138
uint8_t TUINT8
Definition Typedefs.h:17
float TFLOAT
Definition Typedefs.h:4
#define TNULL
Definition Typedefs.h:23
uint32_t TUINT32
Definition Typedefs.h:13
#define TFALSE
Definition Typedefs.h:24
#define TTRUE
Definition Typedefs.h:25
bool TBOOL
Definition Typedefs.h:6
Definition TClass.h:8
T * Parent() const
Definition TNodeTree.h:33
T * Child() const
Definition TNodeTree.h:37
T * Next() const
Definition TNodeTree.h:34
TBOOL IsLinked() const
Definition TNodeTree.h:32
TNodeTree< T > * Tree() const
Definition TNodeTree.h:36
TNodeTree< T > * m_Tree
Definition TNodeTree.h:40
virtual void Delete()
Definition TObject.cpp:14
virtual void OnChildDied(TClass *a_pClass, TTask *a_pDeletedTask)
Definition TTask.cpp:98
void Activate(TBOOL activate)
Definition TTask.cpp:110
virtual void OnDestroy()
Definition TTask.cpp:89
virtual void OnDeactivate()
Definition TTask.cpp:106
virtual ~TTask()
Definition TTask.cpp:19
virtual void OnPreDestroy()
Definition TTask.cpp:85
void SetParent(TTask *a_pAttachTo)
Definition TTask.cpp:130
virtual TBOOL Reset()
Definition TTask.cpp:60
virtual TBOOL Create()
Definition TTask.cpp:24
TTask()
Definition TTask.cpp:14
virtual TBOOL OnUpdate(TFLOAT a_fDeltaTime)
Definition TTask.cpp:80
virtual void OnActivate()
Definition TTask.cpp:102
virtual TBOOL OnCreate()
Definition TTask.cpp:75
@ State_Created
Definition TTask.h:22
@ State_Active
Definition TTask.h:23
virtual TBOOL OnChildDying(TTask *child)
Definition TTask.cpp:93
TBOOL IsCreated() const
Definition TTask.h:47
virtual TBOOL CreateFailed()
Definition TTask.cpp:47