NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
ef_referencedobject.h
1#ifndef NW4R_EF_REFERENCED_OBJECT_H
2#define NW4R_EF_REFERENCED_OBJECT_H
3#include <nw4r/types_nw4r.h>
4
5#include <nw4r/ef/ef_linkedobject.h>
6
7#include <nw4r/math.h>
8#include <nw4r/ut.h>
9
10namespace nw4r {
11namespace ef {
12
14public:
15 enum LifeStatus {
16 NW4R_EF_LS_CLOSED,
17 NW4R_EF_LS_ACTIVE,
18 NW4R_EF_LS_WAIT,
19 NW4R_EF_LS_CLOSING,
20 };
21
22protected:
23 LifeStatus mLifeStatus; // at 0xC
24 ulong mRefCount; // at 0x10
25
26public:
27 ut::Link mActivityLink; // at 0x14
28
29public:
30 virtual void SendClosing() {} // at 0x8
31 virtual void DestroyFunc() {} // at 0xC
32
33 void ChangeLifeStatus(LifeStatus status) {
34 mLifeStatus = status;
35 }
36 LifeStatus GetLifeStatus() const {
37 return mLifeStatus;
38 }
39
40 ulong GetRefCount() const {
41 return mRefCount;
42 }
43
44 bool Initialize() {
45 mRefCount = 0;
46 mLifeStatus = NW4R_EF_LS_ACTIVE;
47 return true;
48 }
49 void Destroy() {
50 DestroyFunc();
51 mLifeStatus = NW4R_EF_LS_WAIT;
52
53 if (mRefCount == 0) {
54 SendClosing();
55 }
56 }
57
58 ulong Ref() {
59 return mRefCount++;
60 }
61 ulong UnRef() {
62 if (--mRefCount == 0 && mLifeStatus == NW4R_EF_LS_WAIT) {
63 SendClosing();
64 }
65
66 return mRefCount;
67 }
68};
69
70} // namespace ef
71} // namespace nw4r
72
73#endif