ChatPlexSDK-BS 1.0.1-v6.2.0
C++ ChatPlex BeatSaber SDK
All Classes Namespaces Functions Variables Typedefs Enumerations Concepts
DelegateInvokerS.hpp
1#pragma once
2
3#include "IDelegateInvoker.hpp"
4
5#include <algorithm>
6
7namespace CP_SDK::Utils::Internals {
8
10 template<class t_Ret, class... t_Args>
11 class DelegateInvokerS : public IDelegateInvoker<t_Ret, t_Args...>
12 {
13 public:
16 DelegateInvokerS(t_Ret(*p_Handler)(t_Args...))
17 {
18 this->m_Kind = 1;
19
20 m_Handler = p_Handler;
21 }
22
23 public:
25 bool IsValid() const override
26 {
27 return m_Handler != nullptr;
28 }
31 bool EqualTo(const IDelegateInvoker<t_Ret, t_Args...>* p_Other) const override
32 {
33 return p_Other
34 && this->m_Kind == p_Other->GetKind()
35 && m_Handler == reinterpret_cast<const DelegateInvokerS<t_Ret, t_Args...>*>(p_Other)->m_Handler;
36 }
39 t_Ret Invoke(t_Args... p_Args) const override
40 {
41 return m_Handler(std::forward<t_Args>(p_Args)...);
42 }
43
44 private:
45 t_Ret(*m_Handler)(t_Args...);
46
47 };
48
49}
bool EqualTo(const IDelegateInvoker< t_Ret, t_Args... > *p_Other) const override
Is this invoker equal to an other invoker.
DelegateInvokerS(t_Ret(*p_Handler)(t_Args...))
bool IsValid() const override
Is the delegate valid.
t_Ret Invoke(t_Args... p_Args) const override
Invoke this invoker.
int GetKind() const
Get delegate invoker kind.