OpenBarnyard
 
Loading...
Searching...
No Matches
TTask Class Reference

#include <TTask.h>

Inheritance diagram for TTask:
TObject TRefCounted TNodeTree< T >::TNode

Public Types

enum  State { State_Created = BITFLAG( 0 ) , State_Active = BITFLAG( 1 ) , State_Dying = BITFLAG( 2 ) }
 
using ThisClass = TTask
 
using BaseClass = TObject
 
- Public Types inherited from TObject
enum  { IsTObject = TTRUE }
 

Public Member Functions

virtual Toshi::TClass * GetClass () override
 
 TTask ()
 
virtual ~TTask ()
 
virtual TBOOL Create ()
 
virtual TBOOL CreateFailed ()
 
virtual TBOOL Reset ()
 
virtual TBOOL OnCreate ()
 
virtual TBOOL OnUpdate (TFLOAT a_fDeltaTime)
 
virtual void OnPreDestroy ()
 
virtual void OnDestroy ()
 
virtual TBOOL OnChildDying (TTask *child)
 
virtual void OnChildDied (TClass *a_pClass, TTask *a_pDeletedTask)
 
virtual void OnActivate ()
 
virtual void OnDeactivate ()
 
void Activate (TBOOL activate)
 
void SetParent (TTask *a_pAttachTo)
 
TUINT32GetFlags ()
 
TBOOL IsCreated () const
 
TBOOL IsActive () const
 
TBOOL IsCreatedAndActive () const
 
TBOOL IsDying () const
 
- Public Member Functions inherited from TObject
virtual void Delete ()
 
virtual ~TObject ()
 
TBOOL IsExactly (TClass *a_pClass)
 
TBOOL IsA (TClass *a_pClass)
 
- Public Member Functions inherited from TRefCounted
 TRefCounted ()
 
 ~TRefCounted ()
 
TINT DecRefCount ()
 
TINT GetRefCount ()
 
TINT IncRefCount ()
 
TRefCountedoperator= (TRefCounted const &)
 
- Public Member Functions inherited from TNodeTree< T >::TNode
TBOOL IsChildOfDefaultRoot () const
 
TBOOL IsLinked () const
 
T * Parent () const
 
T * Next () const
 
T * Prev () const
 
TNodeTree< T > * Tree () const
 
T * Child () const
 

Static Public Member Functions

static Toshi::TObject * CreateTObject ()
 
static Toshi::TObject * CreateTObjectInPlace (void *a_pPtr)
 
static void InitialiseClass ()
 
static void DeinitialiseClass ()
 
static TFORCEINLINE Toshi::TClass * GetClassStatic ()
 
- Static Public Member Functions inherited from TObject
static Toshi::TObject * CreateTObject ()
 
static Toshi::TObject * CreateTObjectInPlace (void *a_pPtr)
 
static void InitialiseClass ()
 
static void DeinitialiseClass ()
 
static TFORCEINLINE TClassGetClassStatic ()
 

Public Attributes

friend TScheduler
 
- Public Attributes inherited from TNodeTree< T >::TNode
friend TNodeTree
 

Static Public Attributes

static constexpr Toshi::TClass * PARENTCLASS = & TObject::ms_oClass
 
static Toshi::TClass ms_oClass = Toshi::TClass( "TTask", TTask::PARENTCLASS, TTask::CreateTObject, TTask::CreateTObjectInPlace, TTask::InitialiseClass, TTask::DeinitialiseClass, 0, 1, sizeof( TTask ), alignof( TTask ) )
 
- Static Public Attributes inherited from TObject
static constexpr Toshi::TClass * PARENTCLASS = TNULL
 
static constinit Toshi::TClass ms_oClass = Toshi::TClass( "TObject", TObject::CreateTObject, TObject::CreateTObjectInPlace, TObject::InitialiseClass, TObject::DeinitialiseClass, 0, 2, sizeof( TObject ), alignof( TObject ) )
 

Additional Inherited Members

- Protected Member Functions inherited from TNodeTree< T >::TNode
 TNode ()
 
- Protected Attributes inherited from TRefCounted
TINT m_iRefCount
 
- Protected Attributes inherited from TNodeTree< T >::TNode
TNodeTree< T > * m_Tree
 
T * m_Next
 
T * m_Prev
 
T * m_Parent
 
T * m_Child
 

Detailed Description

Definition at line 10 of file TTask.h.

Member Typedef Documentation

◆ BaseClass

Definition at line 15 of file TTask.h.

◆ ThisClass

Definition at line 15 of file TTask.h.

Member Enumeration Documentation

◆ State

Enumerator
State_Created 
State_Active 
State_Dying 

Definition at line 20 of file TTask.h.

21 {
23 State_Active = BITFLAG( 1 ),
24 State_Dying = BITFLAG( 2 ),
25 };
#define BITFLAG(x)
Definition Defines.h:10
@ State_Dying
Definition TTask.h:24
@ State_Created
Definition TTask.h:22
@ State_Active
Definition TTask.h:23

Constructor & Destructor Documentation

◆ TTask()

TTask::TTask ( )

Definition at line 14 of file TTask.cpp.

15{
16 m_State = 0;
17}

◆ ~TTask()

TTask::~TTask ( )
virtual

Definition at line 19 of file TTask.cpp.

20{
21 TASSERT( IsLinked() == TFALSE );
22}
#define TASSERT(X,...)
Definition Defines.h:138
#define TFALSE
Definition Typedefs.h:24
TBOOL IsLinked() const
Definition TNodeTree.h:32

Member Function Documentation

◆ Activate()

void TTask::Activate ( TBOOL activate)

Definition at line 110 of file TTask.cpp.

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}
uint8_t TUINT8
Definition Typedefs.h:17
virtual void OnDeactivate()
Definition TTask.cpp:106
virtual void OnActivate()
Definition TTask.cpp:102

◆ Create()

TBOOL TTask::Create ( )
virtual

Definition at line 24 of file TTask.cpp.

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}
uint32_t TUINT32
Definition Typedefs.h:13
#define TTRUE
Definition Typedefs.h:25
TNodeTree< T > * m_Tree
Definition TNodeTree.h:40
virtual void Delete()
Definition TObject.cpp:14
void Activate(TBOOL activate)
Definition TTask.cpp:110
virtual void OnDestroy()
Definition TTask.cpp:89
virtual TBOOL OnCreate()
Definition TTask.cpp:75
TBOOL IsCreated() const
Definition TTask.h:47

◆ CreateFailed()

TBOOL TTask::CreateFailed ( )
virtual

Definition at line 47 of file TTask.cpp.

48{
49 TASSERT( IsCreated() == TFALSE );
50
51 if ( !IsCreated() )
52 {
53 m_Tree->Remove( this, TFALSE );
54 Delete();
55 }
56
57 return TFALSE;
58}

◆ CreateTObject()

Toshi::TObject * TTask::CreateTObject ( )
static

Definition at line 12 of file TTask.cpp.

◆ CreateTObjectInPlace()

Toshi::TObject * TTask::CreateTObjectInPlace ( void * a_pPtr)
static

Definition at line 12 of file TTask.cpp.

◆ DeinitialiseClass()

void TTask::DeinitialiseClass ( )
static

Definition at line 12 of file TTask.cpp.

◆ GetClass()

Toshi::TClass * TTask::GetClass ( )
overridevirtual

Reimplemented from TObject.

Definition at line 12 of file TTask.cpp.

◆ GetClassStatic()

static TFORCEINLINE Toshi::TClass * TTask::GetClassStatic ( )
inlinestatic

Definition at line 15 of file TTask.h.

◆ GetFlags()

TUINT32 & TTask::GetFlags ( )
inline

Definition at line 46 of file TTask.h.

46{ return m_State; }

◆ InitialiseClass()

void TTask::InitialiseClass ( )
static

Definition at line 12 of file TTask.cpp.

◆ IsActive()

TBOOL TTask::IsActive ( ) const
inline

Definition at line 48 of file TTask.h.

48{ return m_State & State_Active; }

◆ IsCreated()

TBOOL TTask::IsCreated ( ) const
inline

Definition at line 47 of file TTask.h.

47{ return m_State & State_Created; }

◆ IsCreatedAndActive()

TBOOL TTask::IsCreatedAndActive ( ) const
inline

Definition at line 49 of file TTask.h.

49{ return ( m_State & ( State_Created | State_Active ) ) == ( State_Created | State_Active ); }

◆ IsDying()

TBOOL TTask::IsDying ( ) const
inline

Definition at line 50 of file TTask.h.

50{ return m_State & State_Dying; }

◆ OnActivate()

void TTask::OnActivate ( )
virtual

Definition at line 102 of file TTask.cpp.

103{
104}

◆ OnChildDied()

void TTask::OnChildDied ( TClass * a_pClass,
TTask * a_pDeletedTask )
virtual

Definition at line 98 of file TTask.cpp.

99{
100}

◆ OnChildDying()

TBOOL TTask::OnChildDying ( TTask * child)
virtual

Definition at line 93 of file TTask.cpp.

94{
95 return TTRUE;
96}

◆ OnCreate()

TBOOL TTask::OnCreate ( )
virtual

Definition at line 75 of file TTask.cpp.

76{
77 return TTRUE;
78}

◆ OnDeactivate()

void TTask::OnDeactivate ( )
virtual

Definition at line 106 of file TTask.cpp.

107{
108}

◆ OnDestroy()

void TTask::OnDestroy ( )
virtual

Definition at line 89 of file TTask.cpp.

90{
91}

◆ OnPreDestroy()

void TTask::OnPreDestroy ( )
virtual

Definition at line 85 of file TTask.cpp.

86{
87}

◆ OnUpdate()

TBOOL TTask::OnUpdate ( TFLOAT a_fDeltaTime)
virtual

Definition at line 80 of file TTask.cpp.

81{
82 return TTRUE;
83}

◆ Reset()

TBOOL TTask::Reset ( )
virtual

Definition at line 60 of file TTask.cpp.

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}
#define TNULL
Definition Typedefs.h:23
bool TBOOL
Definition Typedefs.h:6
T * Child() const
Definition TNodeTree.h:37
T * Next() const
Definition TNodeTree.h:34
virtual TBOOL Reset()
Definition TTask.cpp:60
TTask()
Definition TTask.cpp:14

◆ SetParent()

void TTask::SetParent ( TTask * a_pAttachTo)

Definition at line 130 of file TTask.cpp.

131{
132 if ( this != Parent() && a_pAttachTo != TNULL )
133 {
134 Tree()->ReInsert( this != Parent() ? a_pAttachTo : TNULL, this );
135 }
136}
T * Parent() const
Definition TNodeTree.h:33
TNodeTree< T > * Tree() const
Definition TNodeTree.h:36

Member Data Documentation

◆ ms_oClass

Toshi::TClass TTask::ms_oClass = Toshi::TClass( "TTask", TTask::PARENTCLASS, TTask::CreateTObject, TTask::CreateTObjectInPlace, TTask::InitialiseClass, TTask::DeinitialiseClass, 0, 1, sizeof( TTask ), alignof( TTask ) )
static

Definition at line 15 of file TTask.h.

◆ PARENTCLASS

Toshi::TClass* TTask::PARENTCLASS = & TObject::ms_oClass
staticconstexpr

Definition at line 15 of file TTask.h.

◆ TScheduler

friend TTask::TScheduler

Definition at line 18 of file TTask.h.


The documentation for this class was generated from the following files: