12#include <Common/assertion.h>
19template<
typename MethodStruct,
typename TargetType>
24template<
typename MethodStruct,
typename TargetType>
34 throw_formatted<SdlLoadError>(
35 "cannot call SDL method without target resource ({})",
39 auto const targetRes =
dynamic_cast<TargetType*
>(resource);
42 throw_formatted<SdlLoadError>(
43 "incompatible target resource, given {}, expected {}",
49 callMethod(*targetRes, clauses, ctx);
52template<
typename MethodStruct,
typename TargetType>
54 TargetType& targetType,
58 static_assert(!std::is_abstract_v<MethodStruct> && std::is_default_constructible_v<MethodStruct>,
59 "MethodStruct must be non-abstract and default-constructible.");
61 static_assert(std::is_invocable_v<MethodStruct, TargetType&>,
62 "MethodStruct must contain an operator() that can take a TargetType instance.");
64 MethodStruct methodStructObj{};
70 methodStructObj(targetType);
73template<
typename MethodStruct,
typename TargetType>
75 MethodStruct& parameterStruct,
97template<
typename MethodStruct,
typename TargetType>
100 return m_fields.numFields();
103template<
typename MethodStruct,
typename TargetType>
106 return m_fields.getField(index);
109template<
typename MethodStruct,
typename TargetType>
115 static_assert(std::is_base_of_v<SdlField, T>,
116 "T is not a SdlField thus cannot be added.");
118 m_fields.addField(std::move(sdlField));
123template<
typename MethodStruct,
typename TargetType>
127 setDescription(std::move(descriptionStr));
Interface for all SDL resource.
Definition ISdlResource.h:22
virtual const SdlClass * getDynamicSdlClass() const
Get runtime SDL class of the resource.
Definition ISdlResource.h:54
Definition SdlFunction.h:18
Data that SDL input process can rely on.
Definition SdlInputContext.h:19
SDL binding type for a canonical SDL method.
Definition TSdlMethod.h:26
void call(ISdlResource *resource, SdlInputClauses &clauses, const SdlInputContext &ctx) const override
Definition TSdlMethod.ipp:25
const SdlField * getParam(std::size_t index) const override
Definition TSdlMethod.ipp:104
std::size_t numParams() const override
Definition TSdlMethod.ipp:98
void callMethod(TargetType &targetType, SdlInputClauses &clauses, const SdlInputContext &ctx) const
Definition TSdlMethod.ipp:53
auto description(std::string descriptionStr) -> TSdlMethod &
Definition TSdlMethod.ipp:124
TSdlMethod(std::string name)
Definition TSdlMethod.ipp:20
void loadParameters(MethodStruct ¶meterStruct, SdlInputClauses &clauses, const SdlInputContext &ctx) const
Definition TSdlMethod.ipp:74
TSdlMethod & addParam(T sdlField)
Whether T is a well-defined SDL class.
Definition sdl_traits.h:29
void load_fields_from_sdl(Owner &owner, FieldSet &fieldSet, SdlInputClauses &clauses, const SdlInputContext &ctx, NoticeReceiver noticeReceiver=NoOpNoticeReceiver())
Definition field_set_op.ipp:21
std::string gen_pretty_name(const SdlClass *const clazz)
Generate a human-readable name for the SDL types. These helpers allow input types to be null.
Definition sdl_helpers.cpp:24
The root for all renderer implementations.
Definition EEngineProject.h:6
EFieldImportance
Definition EFieldImportance.h:7
Low-level helpers for SDL. Helpers are in an additional sdl namespace.