TrinityCore
SpellScript::CastHandler Class Referencefinal

#include <SpellScript.h>

Public Types

using SpellCastFnType = void(SpellScript::*)()
 
using SafeWrapperType = void(*)(SpellScript *spellScript, SpellCastFnType callImpl)
 

Public Member Functions

template<typename ScriptFunc >
 CastHandler (ScriptFunc handler)
 
void Call (SpellScript *spellScript) const
 

Private Attributes

SpellCastFnType _callImpl
 
SafeWrapperType _safeWrapper
 

Detailed Description

Definition at line 251 of file SpellScript.h.

Member Typedef Documentation

◆ SafeWrapperType

Definition at line 256 of file SpellScript.h.

◆ SpellCastFnType

using SpellScript::CastHandler::SpellCastFnType = void(SpellScript::*)()

Definition at line 254 of file SpellScript.h.

Constructor & Destructor Documentation

◆ CastHandler()

template<typename ScriptFunc >
SpellScript::CastHandler::CastHandler ( ScriptFunc  handler)
inlineexplicit

Definition at line 259 of file SpellScript.h.

260 {
261 using ScriptClass = GetScriptClass_t<ScriptFunc>;
262
263 static_assert(sizeof(SpellCastFnType) >= sizeof(ScriptFunc));
264 static_assert(alignof(SpellCastFnType) >= alignof(ScriptFunc));
265
266 static_assert(std::is_invocable_r_v<void, ScriptFunc, ScriptClass>,
267 "CastHandler signature must be \"void HandleCast()\"");
268
269 _callImpl = reinterpret_cast<SpellCastFnType>(handler);
270 _safeWrapper = [](SpellScript* spellScript, SpellCastFnType callImpl) -> void
271 {
272 return (static_cast<ScriptClass*>(spellScript)->*reinterpret_cast<ScriptFunc>(callImpl))();
273 };
274 }
SafeWrapperType _safeWrapper
Definition: SpellScript.h:282
void(SpellScript::*)() SpellCastFnType
Definition: SpellScript.h:254
SpellCastFnType _callImpl
Definition: SpellScript.h:281

Member Function Documentation

◆ Call()

void SpellScript::CastHandler::Call ( SpellScript spellScript) const
inline

Definition at line 276 of file SpellScript.h.

277 {
278 return _safeWrapper(spellScript, _callImpl);
279 }
+ Here is the caller graph for this function:

Member Data Documentation

◆ _callImpl

SpellCastFnType SpellScript::CastHandler::_callImpl
private

Definition at line 281 of file SpellScript.h.

◆ _safeWrapper

SafeWrapperType SpellScript::CastHandler::_safeWrapper
private

Definition at line 282 of file SpellScript.h.


The documentation for this class was generated from the following file: