sead
Loading...
Searching...
No Matches
aglEnvObjBuffer.h
Go to the documentation of this file.
1#pragma once
2
3#include <container/seadBuffer.h>
4#include <container/seadSafeArray.h>
5#include <environment/aglEnvObj.h>
6
7namespace agl { namespace env {
8
10{
11public:
13 {
14 public:
16
17 virtual ~AllocateArg()
18 {
19 }
20
21 void setContainMax(s32 type, s32 max);
22
23 template <typename T>
24 void setContainMax(s32 max)
25 {
26 setContainMax(T::getType(), max);
27 }
28
29 s32 getContainMax(s32 type) const
30 {
31 return mTypeMax[type];
32 }
33
34 template <typename T>
36 {
37 return getContainMax(T::getType());
38 }
39
41 {
42 return mTotal;
43 }
44
45 protected:
48 };
49 static_assert(sizeof(AllocateArg) == 0x108);
50
51public:
53 virtual ~EnvObjBuffer();
54
55 virtual void allocBuffer(const AllocateArg& arg, sead::Heap* heap);
56 virtual void freeBuffer();
57
59 {
60 return mEnvObjPtrBuffer.size();
61 }
62
63 void sort(s32 type);
64
65 s32 searchBufferIndex(s32 type, const sead::SafeString& name) const;
66
67 template <typename T>
69 {
70 return searchBufferIndex(T::getType(), name);
71 }
72
73 s32 searchTypeIndex(s32 type, const sead::SafeString& name) const;
74
75 template <typename T>
76 s32 searchTypeIndex(const sead::SafeString& name) const
77 {
78 return searchTypeIndex(T::getType(), name);
79 }
80
81 s32 searchType(s32 buffer_index) const;
82
83 EnvObj* getEnvObj(s32 type, s32 index)
84 {
85 if (0 <= index && index < mTypeInfo[type].mMaxNum)
86 return *mEnvObjPtrBuffer.get(mTypeInfo[type].mStartIndex + index);
87
88 else
89 return nullptr;
90 }
91
92 const EnvObj* getEnvObj(s32 type, s32 index) const
93 {
94 if (0 <= index && index < mTypeInfo[type].mMaxNum)
95 return *mEnvObjPtrBuffer.get(mTypeInfo[type].mStartIndex + index);
96
97 else
98 return nullptr;
99 }
100
101 template <typename T>
102 T* getEnvObj(s32 index)
103 {
104 return sead::DynamicCast<T>(getEnvObj(T::getType(), index));
105 }
106
107 template <typename T>
108 const T* getEnvObj(s32 index) const
109 {
110 return sead::DynamicCast<T>(getEnvObj(T::getType(), index));
111 }
112
113 s32 getEnvObjStartIndex(s32 type) const
114 {
115 return mTypeInfo[type].mStartIndex;
116 }
117
118 template <typename T>
119 s32 getEnvObjStartIndex(s32 type) const
120 {
121 return getEnvObjStartIndex(T::getType());
122 }
123
124 s32 getEnvObjMaxNum(s32 type) const
125 {
126 return mTypeInfo[type].mMaxNum;
127 }
128
129 template <typename T>
130 s32 getEnvObjMaxNum(s32 type) const
131 {
132 return getEnvObjMaxNum(T::getType());
133 }
134
135protected:
141 static_assert(sizeof(TypeInfo) == 4);
142
147 u32 _18[4 / sizeof(u32)];
148};
149static_assert(sizeof(EnvObjBuffer) == 0x20, "agl::env::EnvObjBuffer size mismatch");
150
151} }
Definition aglEnvObjBuffer.h:13
s32 getContainMax(s32 type) const
Definition aglEnvObjBuffer.h:29
sead::SafeArray< s32, EnvObj::cTypeMax > mTypeMax
Definition aglEnvObjBuffer.h:46
void setContainMax(s32 max)
Definition aglEnvObjBuffer.h:24
virtual ~AllocateArg()
Definition aglEnvObjBuffer.h:17
void setContainMax(s32 type, s32 max)
Definition aglEnvObjBuffer.cpp:116
AllocateArg()
Definition aglEnvObjBuffer.cpp:110
s32 getContainTotal() const
Definition aglEnvObjBuffer.h:40
s32 getContainMax() const
Definition aglEnvObjBuffer.h:35
s32 mTotal
Definition aglEnvObjBuffer.h:47
Definition aglEnvObjBuffer.h:10
EnvObjBuffer()
Definition aglEnvObjBuffer.cpp:12
u32 _18[4/sizeof(u32)]
Definition aglEnvObjBuffer.h:147
s32 searchBufferIndex(const sead::SafeString &name) const
Definition aglEnvObjBuffer.h:68
s32 getEnvObjStartIndex(s32 type) const
Definition aglEnvObjBuffer.h:113
virtual ~EnvObjBuffer()
Definition aglEnvObjBuffer.cpp:18
s32 searchBufferIndex(s32 type, const sead::SafeString &name) const
Definition aglEnvObjBuffer.cpp:74
virtual void freeBuffer()
Definition aglEnvObjBuffer.cpp:56
s32 searchTypeIndex(s32 type, const sead::SafeString &name) const
Definition aglEnvObjBuffer.cpp:92
const EnvObj * getEnvObj(s32 type, s32 index) const
Definition aglEnvObjBuffer.h:92
s32 getEnvObjMaxNum(s32 type) const
Definition aglEnvObjBuffer.h:130
T * getEnvObj(s32 index)
Definition aglEnvObjBuffer.h:102
const T * getEnvObj(s32 index) const
Definition aglEnvObjBuffer.h:108
s32 searchTypeIndex(const sead::SafeString &name) const
Definition aglEnvObjBuffer.h:76
u32 _4
Definition aglEnvObjBuffer.h:144
EnvObj * getEnvObj(s32 type, s32 index)
Definition aglEnvObjBuffer.h:83
sead::Buffer< TypeInfo > mTypeInfo
Definition aglEnvObjBuffer.h:145
virtual void allocBuffer(const AllocateArg &arg, sead::Heap *heap)
Definition aglEnvObjBuffer.cpp:23
s32 getEnvObjMaxNum(s32 type) const
Definition aglEnvObjBuffer.h:124
sead::Buffer< EnvObj * > mEnvObjPtrBuffer
Definition aglEnvObjBuffer.h:146
void sort(s32 type)
Definition aglEnvObjBuffer.cpp:62
s32 getContainTotal() const
Definition aglEnvObjBuffer.h:58
s32 searchType(s32 buffer_index) const
Definition aglEnvObjBuffer.cpp:101
u32 _0
Definition aglEnvObjBuffer.h:143
s32 getEnvObjStartIndex(s32 type) const
Definition aglEnvObjBuffer.h:119
Definition aglEnvObj.h:17
Definition seadBuffer.h:13
Definition seadHeap.h:23
Definition aglEnvObj.cpp:21
Definition aglDisplayList.cpp:5
Definition seadAssert.h:44
SafeStringBase< char > SafeString
Definition seadSafeString.h:409
Definition aglEnvObjBuffer.h:137
u16 mStartIndex
Definition aglEnvObjBuffer.h:138
u16 mMaxNum
Definition aglEnvObjBuffer.h:139