sead
Loading...
Searching...
No Matches
aglDrawMethod.h
Go to the documentation of this file.
1#pragma once
2
3#include <heap/seadDisposer.h>
4#include <prim/seadDelegate.h>
5#include <prim/seadNamable.h>
6
7namespace agl { namespace lyr {
8
9class RenderInfo;
10
11class DrawMethod : public sead::IDisposer, public sead::INamable
12{
13private:
20
21 class Dummy
22 {
23 };
24
25public:
28 , sead::INamable("")
30 , mPriority(0)
31 {
32 new (&mDelegateHolder) sead::Delegate<Dummy>();
33 }
34
35 virtual ~DrawMethod();
36
37 template <typename T>
38 void bind(T* obj, typename sead::Delegate1Const<T, const RenderInfo&>::MethodPtr method, const sead::SafeString& name)
39 {
40 new (&mDelegateHolder) sead::Delegate1Const<T, const RenderInfo&>(obj, method);
42 setName(name);
43 }
44
45 template <typename T>
46 void bind(T* obj, typename sead::Delegate1<T, const RenderInfo&>::MethodPtr method, const sead::SafeString& name)
47 {
48 new (&mDelegateHolder) sead::Delegate1<T, const RenderInfo&>(obj, method);
50 setName(name);
51 }
52
53 void setPriority(s32 priority)
54 {
55 mPriority = priority;
56 }
57
59 {
60 return mPriority;
61 }
62
63 void invoke(const RenderInfo& render_info)
64 {
65 return reinterpret_cast<sead::Delegate1<Dummy, const RenderInfo&>*>(&mDelegateHolder)->invoke(render_info);
66 }
67
68 void operator() (const RenderInfo& render_info)
69 {
70 return invoke(render_info);
71 }
72
73 static s32 compare(const DrawMethod* a, const DrawMethod* b);
74
75private:
78 struct
79 {
80 u32 data_[8]; // Nintendo: "32 bytes... must be enough :)"
81 // (Note: they didn't change it for Switch, which results in misalignment)
82 } mDelegateHolder;
83};
84static_assert(sizeof(DrawMethod) == 0x40, "agl::lyr::DrawMethod size mismatch");
85
86} }
Definition aglDrawMethod.h:22
Definition aglDrawMethod.h:12
void operator()(const RenderInfo &render_info)
Definition aglDrawMethod.h:68
void bind(T *obj, typename sead::Delegate1Const< T, const RenderInfo & >::MethodPtr method, const sead::SafeString &name)
Definition aglDrawMethod.h:38
s32 mPriority
Definition aglDrawMethod.h:77
DrawMethod()
Definition aglDrawMethod.h:26
s32 getPriority() const
Definition aglDrawMethod.h:58
static s32 compare(const DrawMethod *a, const DrawMethod *b)
virtual ~DrawMethod()
Definition aglDrawMethod.cpp:6
void invoke(const RenderInfo &render_info)
Definition aglDrawMethod.h:63
DelegateType
Definition aglDrawMethod.h:15
@ cDelegateType_Dummy
Definition aglDrawMethod.h:16
@ cDelegateType_Const
Definition aglDrawMethod.h:17
@ cDelegateType_NonConst
Definition aglDrawMethod.h:18
u32 data_[8]
Definition aglDrawMethod.h:80
DelegateType mDelegateType
Definition aglDrawMethod.h:76
void setPriority(s32 priority)
Definition aglDrawMethod.h:53
void bind(T *obj, typename sead::Delegate1< T, const RenderInfo & >::MethodPtr method, const sead::SafeString &name)
Definition aglDrawMethod.h:46
Definition aglRenderInfo.h:23
Definition seadDelegate.h:348
Definition seadDelegate.h:278
friend IDisposer::IDisposer()
Definition seadDisposer.h:12
Definition seadNamable.h:9
void setName(const SafeString &name)
Definition seadNamable.h:21
Definition aglDrawMethod.cpp:4
Definition aglDisplayList.cpp:5
Definition seadAssert.h:44
SafeStringBase< char > SafeString
Definition seadSafeString.h:409