ChatPlexSDK-BS 1.0.1-v6.2.0
C++ ChatPlex BeatSaber SDK
Loading...
Searching...
No Matches
DelegateInvokerI.hpp
1#pragma once
2
3#include "IDelegateInvoker.hpp"
4
5#include <algorithm>
6
7namespace CP_SDK::Utils::Internals {
8
10 template<class t_Class, class t_Ret, class... t_Args>
11 class DelegateInvokerI : public IDelegateInvoker<t_Ret, t_Args...>
12 {
13 public:
17 DelegateInvokerI(t_Class* p_Owner, t_Ret(t_Class::* p_Handler)(t_Args...))
18 {
19 this->m_Kind = 2;
20
21 m_Owner = p_Owner;
22 m_Handler = p_Handler;
23 }
24
25 public:
27 bool IsValid() const override
28 {
29 return m_Handler != nullptr;
30 }
33 bool EqualTo(const IDelegateInvoker<t_Ret, t_Args...>* p_Other) const override
34 {
35 return p_Other
36 && this->m_Kind == p_Other->GetKind()
37 && m_Owner == reinterpret_cast<const DelegateInvokerI<t_Class, t_Ret, t_Args...>*>(p_Other)->m_Owner
38 && m_Handler == reinterpret_cast<const DelegateInvokerI<t_Class, t_Ret, t_Args...>*>(p_Other)->m_Handler;
39 }
42 t_Ret Invoke(t_Args... p_Args) const override
43 {
44 return (m_Owner->*m_Handler)(std::forward<t_Args>(p_Args)...);
45 }
46
47 private:
48 t_Class* m_Owner;
49 t_Ret(t_Class::* m_Handler)(t_Args...);
50
51 };
52
53}
DelegateInvokerI(t_Class *p_Owner, t_Ret(t_Class::*p_Handler)(t_Args...))
Constructor.
bool IsValid() const override
Is the delegate valid.
t_Ret Invoke(t_Args... p_Args) const override
Invoke this invoker.
bool EqualTo(const IDelegateInvoker< t_Ret, t_Args... > *p_Other) const override
Is this invoker equal to an other invoker.
int GetKind() const
Get delegate invoker kind.